Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the Makevars files not to write files in user's HOME directory #25

Merged
merged 3 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Makevars
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ all: C_clean

$(SHLIB): $(STATLIB)

CARGOTMP = $(PWD)/.cargo

$(STATLIB):
# In some environments, ~/.cargo/bin might not be included in PATH, so we need
# to set it here to ensure cargo can be invoked. It is appended to PATH and
# therefore is only used if cargo is absent from the user's PATH.
if [ "$(NOT_CRAN)" != "true" ] && [ "$(NOT_CRAN)" != "TRUE" ]; then \
CARGO_HOME=$(CARGOTMP); \
fi && \
export PATH="$(PATH):$(HOME)/.cargo/bin" && \
cargo build --lib --release --manifest-path=./rust/Cargo.toml --target-dir $(TARGET_DIR)
rm -Rf $(CARGOTMP)
rm -Rf $(LIBDIR)/build

C_clean:
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS)
Expand Down
7 changes: 7 additions & 0 deletions src/Makevars.win
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ all: C_clean

$(SHLIB): $(STATLIB)

CARGOTMP = $(PWD)/.cargo

$(STATLIB):
mkdir -p $(TARGET_DIR)/libgcc_mock
cd $(TARGET_DIR)/libgcc_mock && \
Expand All @@ -21,9 +23,14 @@ $(STATLIB):
cp libgcc_eh.a libgcc_s.a

# CARGO_LINKER is provided in Makevars.ucrt for R >= 4.2
if [ "$(NOT_CRAN)" != "true" ] && [ "$(NOT_CRAN)" != "TRUE" ]; then \
CARGO_HOME=$(CARGOTMP); \
fi && \
export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="$(CARGO_LINKER)" && \
export LIBRARY_PATH="$${LIBRARY_PATH};$(CURDIR)/$(TARGET_DIR)/libgcc_mock" && \
cargo build --target=$(TARGET) --lib --release --manifest-path=./rust/Cargo.toml --target-dir $(TARGET_DIR)
rm -Rf $(CARGOTMP)
rm -Rf $(LIBDIR)/build

C_clean:
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS)
Expand Down