Skip to content

Commit

Permalink
use tabs instead of spaces for Makevars.win.in
Browse files Browse the repository at this point in the history
  • Loading branch information
JosiahParry committed Nov 17, 2024
1 parent 38323f5 commit 37df69f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
60 changes: 30 additions & 30 deletions inst/templates/Makevars.win.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,37 @@ $(SHLIB): $(STATLIB)
CARGOTMP = $(CURDIR)/.cargo

$(STATLIB):
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
# compiler, we need to add empty `libgcc_eh` to the library search paths.
#
# For more details, please refer to
# https://github.com/r-windows/rtools-packages/blob/2407b23f1e0925bbb20a4162c963600105236318/mingw-w64-gcc/PKGBUILD#L313-L316
touch $(TARGET_DIR)/libgcc_mock/libgcc_eh.a

# When the NOT_CRAN flag is *not* set, the vendor.tar.xz, if present,
# is unzipped and used for offline compilation.
if [ "$(NOT_CRAN)" != "true" ]; then \
if [ -f ./rust/vendor.tar.xz ]; then \
tar xf rust/vendor.tar.xz && \
mkdir -p $(CARGOTMP) && \
cp rust/vendor-config.toml $(CARGOTMP)/config.toml; \
fi; \
fi

# CARGO_LINKER is provided in Makevars.ucrt for R >= 4.2
# Build the project using Cargo with additional flags
export CARGO_HOME=$(CARGOTMP) && \
export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="$(CARGO_LINKER)" && \
export LIBRARY_PATH="$${LIBRARY_PATH};$(CURDIR)/$(TARGET_DIR)/libgcc_mock" && \
RUSTFLAGS="$(RUSTFLAGS) --print=native-static-libs" cargo @CRAN_FLAGS@ build --target=$(TARGET) --lib --release --manifest-path=./rust/Cargo.toml --target-dir $(TARGET_DIR)

# Always clean up CARGOTMP
rm -Rf $(CARGOTMP);
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
# compiler, we need to add empty `libgcc_eh` to the library search paths.
#
# For more details, please refer to
# https://github.com/r-windows/rtools-packages/blob/2407b23f1e0925bbb20a4162c963600105236318/mingw-w64-gcc/PKGBUILD#L313-L316
touch $(TARGET_DIR)/libgcc_mock/libgcc_eh.a

# When the NOT_CRAN flag is *not* set, the vendor.tar.xz, if present,
# is unzipped and used for offline compilation.
if [ "$(NOT_CRAN)" != "true" ]; then \
if [ -f ./rust/vendor.tar.xz ]; then \
tar xf rust/vendor.tar.xz && \
mkdir -p $(CARGOTMP) && \
cp rust/vendor-config.toml $(CARGOTMP)/config.toml; \
fi; \
fi

# CARGO_LINKER is provided in Makevars.ucrt for R >= 4.2
# Build the project using Cargo with additional flags
export CARGO_HOME=$(CARGOTMP) && \
export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="$(CARGO_LINKER)" && \
export LIBRARY_PATH="$${LIBRARY_PATH};$(CURDIR)/$(TARGET_DIR)/libgcc_mock" && \
RUSTFLAGS="$(RUSTFLAGS) --print=native-static-libs" cargo build @CRAN_FLAGS@ --target=$(TARGET) --lib --release --manifest-path=./rust/Cargo.toml --target-dir $(TARGET_DIR)

# Always clean up CARGOTMP
rm -Rf $(CARGOTMP);

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

clean:
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) $(TARGET_DIR)
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) $(TARGET_DIR)
2 changes: 1 addition & 1 deletion inst/templates/configure.win
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ else
fi

# delete Makevars if it is present
[ -f src/Makevars ] && rm src/Makevars.win
[ -f src/Makevars.win ] && rm src/Makevars.win

# Substitute @CRAN_FLAGS@ in Makevars.in with the actual value of $CRAN_FLAGS
sed -e "s|@CRAN_FLAGS@|$CRAN_FLAGS|" src/Makevars.win.in > src/Makevars.win

0 comments on commit 37df69f

Please sign in to comment.