-
Notifications
You must be signed in to change notification settings - Fork 5
/
configure
executable file
·53 lines (45 loc) · 1.8 KB
/
configure
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
49
50
51
52
53
# Variables used for tweaking Makevars
BEFORE_CARGO_BUILD=''
AFTER_CARGO_BUILD=''
# Even when `cargo` is on `PATH`, `rustc` might not. We need to source
# ~/.cargo/env to ensure PATH is configured correctly in some cases
# (c.f. yutannihilation/string2path#4). However, this file is not always
# available (e.g. when Rust is installed via apt on Ubuntu), so it might be
# more straightforward to add `PATH` directly.
if [ -e "${HOME}/.cargo/env" ]; then
. "${HOME}/.cargo/env"
BEFORE_CARGO_BUILD="${BEFORE_CARGO_BUILD} . \"${HOME}/.cargo/env\" \\&\\&"
fi
# Check the Rust installation, and abort if not available
"${R_HOME}/bin/Rscript" "./tools/configure.R"
ret=$?
if [ $ret -ne 0 ]; then
exit $ret
fi
# Report the version of Rustc to comply with the CRAN policy
echo "using Rust package manager: '$(cargo --version)'"
echo "using Rust compiler: '$(rustc --version)'"
# Handle webR
if [ "$(uname)" = "Emscripten" ]; then
TARGET="wasm32-unknown-emscripten"
# 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)`).
elif [ "${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'
VENDORING="yes"
OFFLINE_OPTION="--offline"
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}|" \
-e "s|@VENDORING@|${VENDORING}|" \
-e "s|@OFFLINE_OPTION@|${OFFLINE_OPTION}|" \
-e "s|@TARGET@|${TARGET}|" \
src/Makevars.in > src/Makevars
# Uncomment this to debug
#
# cat src/Makevars