Skip to content

Commit 73e38fc

Browse files
authored
fix(r/sedonadb): Fix build on Windows for path restriction (#208)
This PR allows a developer to override the target path for Cargo, which is useful on Windows where most paths a user might build this under fail (e.g., I run into the path length restriction for CMake in my usual home directory/documents folder). This allows overriding that (for local development it one can put SEDONADB_TARGET_DIR=C:/sedonadb_tmp in their .Rprofile), and automatically overrides it on GitHub actions (where R Universe Windows packages are built).
1 parent f79d821 commit 73e38fc

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

r/sedonadb/configure.win

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@ RUSTC_VERSION="$(rustc --version || true)"
5656
echo "using Rust package manager: '${CARGO_VERSION}'"
5757
echo "using Rust compiler: '${RUSTC_VERSION}'"
5858

59+
# If we are in GitHub actions (e.g., R Universe), set the target directory
60+
# to a very, very short path. If we don't do this, we run out of path length
61+
# to compile components of the aws-lc-sys crate. This also lets us better
62+
# cache the compilation.
63+
if [ -n "$SEDONADB_TARGET_DIR" ];then
64+
TARGET_DIR="$SEDONADB_TARGET_DIR"
65+
elif [ -n "$GITHUB_ACTIONS" ]; then
66+
mkdir C:/sedonadb_tmp
67+
TARGET_DIR="C:/sedonadb_tmp"
68+
else
69+
TARGET_DIR="$(pwd)/src/rust/target"
70+
fi
71+
72+
5973
# allow overriding profile externally (e.g. on CI)
6074
if [ -n "${SAVVY_PROFILE}" ]; then
6175
PROFILE="${SAVVY_PROFILE}"
@@ -74,6 +88,7 @@ fi
7488
sed \
7589
-e "s/@TARGET@/x86_64-pc-windows-gnu/" \
7690
-e "s/@PROFILE@/${PROFILE}/" \
91+
-e "s|@TARGET_DIR@|${TARGET_DIR}|" \
7792
-e "s/@FEATURE_FLAGS@/${FEATURE_FLAGS}/" \
7893
-e "s|@PKG_LIBS@|${PKG_LIBS}|" \
7994
src/Makevars.win.in > src/Makevars.win

r/sedonadb/src/Makevars.win.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ FEATURE_FLAGS = @FEATURE_FLAGS@
2323
# Add flags if necessary
2424
RUSTFLAGS =
2525

26-
TARGET_DIR = $(CURDIR)/rust/target
26+
# We set this in configure to work around a Windows path length restriction
27+
TARGET_DIR = @TARGET_DIR@
2728
LIBDIR = $(TARGET_DIR)/$(TARGET)/$(subst dev,debug,$(PROFILE))
2829
STATLIB = $(LIBDIR)/libsedonadbr.a
2930
PKG_LIBS = -L$(LIBDIR) -lsedonadbr -lws2_32 -ladvapi32 -luserenv -lbcrypt -lntdll @PKG_LIBS@
@@ -57,7 +58,6 @@ $(STATLIB):
5758
export PKG_CONFIG_SYSROOT_DIR="$(PKG_CONFIG_SYSROOT_DIR)" && \
5859
export CC="$(CC)" && \
5960
export CFLAGS="$(CFLAGS_TWEAKED)" && \
60-
export CMAKE_TOOLCHAIN_FILE="$(CURDIR)/rust/aws-lc-sys-win-toolchain.cmake" && \
6161
export RUSTFLAGS="$(RUSTFLAGS)" && \
6262
cargo build --target $(TARGET) --lib --profile $(PROFILE) $(FEATURE_FLAGS) --manifest-path ./rust/Cargo.toml --target-dir $(TARGET_DIR)
6363

r/sedonadb/src/rust/aws-lc-sys-win-toolchain.cmake

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)