Skip to content

Commit

Permalink
feat: update Makevars to support vendoring
Browse files Browse the repository at this point in the history
  • Loading branch information
eitsupi committed Jul 26, 2023
1 parent 7aacf78 commit 03cf910
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
^Taskfile\.yml$
^\.task$
^src/\.cargo$
^src/rust/vendor$
10 changes: 9 additions & 1 deletion src/Makevars
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ all: C_clean
$(SHLIB): $(STATLIB)

CARGOTMP = $(CURDIR)/.cargo
VENDOR_DIR = ./rust/vendor

$(STATLIB):
if [ -f ./rust/vendor.tar.xz ]; then \
mkdir -p $(VENDOR_DIR) && \
$(TAR) --extract --xz --file ./rust/vendor.tar.xz -C $(VENDOR_DIR) && \
mkdir -p ./rust/.cargo && \
cp ./rust/vendor-config.toml ./rust/.cargo/config.toml; \
fi

# 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.
Expand All @@ -28,4 +36,4 @@ C_clean:
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS)

clean:
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) rust/target
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) $(VENDOR_DIR) ./rust/target
10 changes: 9 additions & 1 deletion src/Makevars.win
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ all: C_clean
$(SHLIB): $(STATLIB)

CARGOTMP = $(CURDIR)/.cargo
VENDOR_DIR = ./rust/vendor

$(STATLIB):
if [ -f ./rust/vendor.tar.xz ]; then \
mkdir -p $(VENDOR_DIR) && \
$(TAR) --extract --xz --file ./rust/vendor.tar.xz -C $(VENDOR_DIR) && \
mkdir -p ./rust/.cargo && \
cp ./rust/vendor-config.toml ./rust/.cargo/config.toml; \
fi

mkdir -p $(TARGET_DIR)/libgcc_mock
# `rustc` adds `-lgcc_eh` flags to the compiler, but Rtools' GCC doesn't have
# `libgcc_eh` due to the compilation settings. So, in order to please the
Expand All @@ -38,4 +46,4 @@ C_clean:
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS)

clean:
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) rust/target
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) $(VENDOR_DIR) ./rust/target

0 comments on commit 03cf910

Please sign in to comment.