-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.win
executable file
·48 lines (39 loc) · 1.78 KB
/
configure.win
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# The envvar used in libR-sys crate
LIBRSYS_R_VERSION=$("${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "./tools/print_r_version.R")
# Variables used for tweaking Makevars
BEFORE_CARGO_BUILD="export LIBRSYS_R_VERSION=\"${LIBRSYS_R_VERSION}\" \\&\\&"
AFTER_CARGO_BUILD=''
# Check for rustc and report its version
if command -v rustc >/dev/null 2>&1; then
echo "Using system rustc version: $(rustc --version)"
elif [ -x "$USERPROFILE/.cargo/bin/rustc" ]; then
echo "Using user-installed rustc version: $($USERPROFILE/.cargo/bin/rustc --version)"
else
echo "Error: rustc not found. Please install Rust from https://rustup.rs/"
exit 1
fi
# Check the Rust installation, and abort if not available
"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "./tools/configure.R"
ret=$?
if [ $ret -ne 0 ]; then
exit $ret
fi
# To address the change of the toolchain on R 4.2
BEFORE_CARGO_BUILD="${BEFORE_CARGO_BUILD}"' export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="$(CARGO_LINKER)" \&\&'
BEFORE_CARGO_BUILD="${BEFORE_CARGO_BUILD}"' export LIBRARY_PATH="$${LIBRARY_PATH};$(CURDIR)/$(LIBDIR)/libgcc_mock" \&\&'
# If it's on CRAN, a package is not allowed to write in any other place than the
# temporary directory on installation. So, we need to tweak Makevars to make the
# compilation happen only within the package directory (i.e. `$(PWD)`).
if [ "${NOT_CRAN}" != "true" ]; then
BEFORE_CARGO_BUILD="${BEFORE_CARGO_BUILD}"' export CARGO_HOME="$(PWD)/.cargo" \&\&'
AFTER_CARGO_BUILD="${AFTER_CARGO_BUILD}"'rm -Rf $(PWD)/.cargo $(LIBDIR)/build'
else
echo "*** Detected NOT_CRAN=true, do not override CARGO_HOME"
fi
sed \
-e "s|@BEFORE_CARGO_BUILD@|${BEFORE_CARGO_BUILD}|" \
-e "s|@AFTER_CARGO_BUILD@|${AFTER_CARGO_BUILD}|" \
src/Makevars.win.in > src/Makevars.win
# Uncomment this to debug
#
# cat src/Makevars.win