Skip to content

Commit 552286b

Browse files
committed
Vendors sources
1 parent 333af6a commit 552286b

7 files changed

Lines changed: 49 additions & 8 deletions

File tree

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
^src/\.cargo$
2+
^src/\.short_build_path$
23
^src/rust/vendor$
34
^src/rust/target$
45
^src/Makevars$

.github/workflows/R-CMD-check.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
env:
2929
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
3030
R_KEEP_PKG_SOURCE: yes
31+
NOT_CRAN: true
3132

3233
steps:
3334
- uses: actions/checkout@v4

src/Makevars.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ all: $(SHLIB) rust_clean
1111

1212
$(SHLIB): $(STATLIB)
1313

14-
CARGOTMP = $(CURDIR)/.cargo
14+
# CARGO_HOME is set dynamically by tools/config.R
15+
# On Unix, this uses the current directory (no path length issues)
16+
CARGOTMP = @CARGO_HOME@
1517
VENDOR_DIR = $(CURDIR)/vendor
1618

1719

src/Makevars.win.in

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ all: $(SHLIB) rust_clean
1313

1414
$(SHLIB): $(STATLIB)
1515

16-
CARGOTMP = $(CURDIR)/.cargo
16+
# CARGO_HOME is set dynamically by tools/config.R
17+
# On Windows, this uses the same short base path as TARGET_DIR
18+
# so that relative paths in aws-lc-sys CMake builds resolve correctly
19+
CARGOTMP = @CARGO_HOME@
1720
VENDOR_DIR = vendor
1821

1922
$(STATLIB):
23+
# Clean any previous build artifacts to avoid conflicts
24+
rm -Rf $(TARGET_DIR) $(CARGOTMP)
2025
mkdir -p $(TARGET_DIR)/libgcc_mock
2126
touch $(TARGET_DIR)/libgcc_mock/libgcc_eh.a
2227

@@ -27,8 +32,9 @@ $(STATLIB):
2732
fi
2833

2934
# Build the project using Cargo with additional flags
35+
# Note: TARGET_DIR is an absolute short path, so don't prepend CURDIR
3036
export CARGO_HOME=$(CARGOTMP) && \
31-
export LIBRARY_PATH="$(LIBRARY_PATH);$(CURDIR)/$(TARGET_DIR)/libgcc_mock" && \
37+
export LIBRARY_PATH="$(LIBRARY_PATH);$(TARGET_DIR)/libgcc_mock" && \
3238
RUSTFLAGS="$(RUSTFLAGS) --print=native-static-libs" cargo build @CRAN_FLAGS@ --target=$(TARGET) --lib @PROFILE@ --manifest-path=rust/Cargo.toml --target-dir=$(TARGET_DIR)
3339

3440
# Always clean up CARGOTMP

src/rust/vendor-config.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[source.crates-io]
2+
replace-with = "vendored-sources"
3+
4+
[source.vendored-sources]
5+
directory = "vendor"

src/rust/vendor.tar.xz

47.4 MB
Binary file not shown.

tools/config.R

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,39 @@ is_windows <- .Platform[["OS.type"]] == "windows"
99

1010
# Generate a short target directory for Windows to avoid MAX_PATH issues
1111
# aws-lc-sys builds fail when paths exceed ~250 characters
12+
# IMPORTANT: Both CARGO_HOME and TARGET_DIR must be in the same short path
13+
# so that relative paths in aws-lc-sys CMake builds resolve correctly
1214
if (is_windows) {
13-
# Use R's temp directory but with a short subdirectory name
14-
# This is CRAN-compliant as it uses the session temp directory
15-
short_tmp <- file.path(tempdir(), "dR")
15+
# For CI builds (NOT_CRAN set), we can use a fixed short path
16+
17+
# For CRAN builds, we use tempdir but write the path to a file so that
18+
19+
# subsequent R sessions (configure vs build) use the same directory
20+
21+
env_not_cran_check <- Sys.getenv("NOT_CRAN")
22+
23+
if (env_not_cran_check != "") {
24+
# CI build - use fixed short path (no CRAN policy concerns)
25+
short_base <- "C:/tmp/dR"
26+
} else {
27+
# CRAN build - use tempdir but persist the path choice
28+
# Create a marker file in the source directory to ensure consistency
29+
marker_file <- "src/.short_build_path"
30+
if (file.exists(marker_file)) {
31+
short_base <- readLines(marker_file, n = 1)
32+
} else {
33+
short_base <- gsub("\\\\", "/", file.path(tempdir(), "dR"))
34+
writeLines(short_base, marker_file)
35+
}
36+
}
37+
1638
# Normalize to forward slashes for Make compatibility
17-
.target_dir <- gsub("\\\\", "/", short_tmp)
39+
.target_dir <- paste0(short_base, "/target")
40+
.cargo_home <- paste0(short_base, "/.cargo")
41+
message("Using short build path: ", short_base)
1842
} else {
1943
.target_dir <- "./rust/target"
44+
.cargo_home <- "$(CURDIR)/.cargo"
2045
}
2146

2247
# check DEBUG and NOT_CRAN environment variables
@@ -117,7 +142,8 @@ new_txt <- gsub("@CRAN_FLAGS@", .cran_flags, mv_txt) |>
117142
gsub("@LIBDIR@", .libdir, x = _) |>
118143
gsub("@TARGET@", .target, x = _) |>
119144
gsub("@PANIC_EXPORTS@", .panic_exports, x = _) |>
120-
gsub("@TARGET_DIR@", .target_dir, x = _)
145+
gsub("@TARGET_DIR@", .target_dir, x = _) |>
146+
gsub("@CARGO_HOME@", .cargo_home, x = _)
121147

122148
message("Writing `", mv_ofp, "`.")
123149
con <- file(mv_ofp, open = "wb")

0 commit comments

Comments
 (0)