@@ -14,7 +14,7 @@ export PATH="$PATH:$HOME/.cargo/bin"
14
14
15
15
check_cargo () {
16
16
if [ ! " $( command -v cargo) " ]; then
17
- cat << EOF
17
+ cat << EOF
18
18
------------------------- [RUST NOT FOUND] -------------------------
19
19
The 'cargo' command was not found on the PATH. Please install rustc
20
20
from: https://www.rust-lang.org/tools/install
@@ -27,7 +27,7 @@ Alternatively, you may install cargo from your OS package manager:
27
27
EOF
28
28
exit 1
29
29
else
30
- cat << EOF
30
+ cat << EOF
31
31
--------------------------- [RUST FOUND] ---------------------------
32
32
$( cargo -V)
33
33
@@ -44,7 +44,7 @@ check_bin_lib() {
44
44
45
45
# On R-universe, we try to download the pre-built binary from GitHub releases.
46
46
if [ -n " ${MY_UNIVERSE} " ] && [ -z " ${LIBPRQLR_BUILD} " ]; then
47
- cat << EOF
47
+ cat << EOF
48
48
--------------------- [SETTING FOR R-UNIVERSE] ---------------------
49
49
It seems that this is on R-universe <${MY_UNIVERSE} >.
50
50
Trying to download pre-built binary.
53
53
LIBPRQLR_BUILD=" false"
54
54
fi
55
55
56
- if [ " ${LIBPRQLR_BUILD} " = " false" ] && [ -f " tools/lib-sums.tsv" ] && [ ! -f " ${LIBPRQLR_PATH} " ]; then
57
- cat << EOF
56
+ if [ " ${LIBPRQLR_BUILD} " = " false" ]; then
57
+ if [ -f " tools/lib-sums.tsv" ] && [ ! -f " ${LIBPRQLR_PATH} " ]; then
58
+ cat << EOF
58
59
--------------- [TRY TO DOWNLOAD PRE-BUILT BINARY] ---------------
60
+ The library was not found at <${LIBPRQLR_PATH} >.
61
+ Trying to download pre-built binary from the Internet.
59
62
$( " ${R_HOME} /bin${R_ARCH_BIN} /Rscript" " tools/prep-lib.R" || echo " Failed to download pre-built binary." )
60
63
------------------------------------------------------------------
61
64
EOF
62
- fi
63
-
64
- if [ " ${LIBPRQLR_BUILD} " = " false" ] && [ -f " ${LIBPRQLR_PATH} " ]; then
65
- cat << EOF
66
- ---------------------- [LIBRARY BINARY FOUND] ----------------------
67
- The library was found at <${LIBPRQLR_PATH} >. No need to build it.
65
+ fi
68
66
69
- Note: rustc version: $( command -v rustc > /dev/null && rustc -V || echo " Not found" )
70
- --------------------------------------------------------------------
71
- EOF
72
- sed -e " s|@RUST_TARGET@||" src/Makevars.in > src/Makevars
73
- if [ " ${LIBPRQLR_PATH} " != " ${LIBPRQLR_DEFAULT_PATH} " ]; then
74
- cat << EOF
67
+ if [ -f " ${LIBPRQLR_PATH} " ] && [ " ${LIBPRQLR_PATH} " != " ${LIBPRQLR_DEFAULT_PATH} " ]; then
68
+ cat << EOF
75
69
------------------------ [COPYING BINARY] ------------------------
76
70
Copying <${LIBPRQLR_PATH} > to <${LIBPRQLR_DEFAULT_PATH} >.
77
71
$( mkdir -p " $( dirname " ${LIBPRQLR_DEFAULT_PATH} " ) " )
78
72
$( cp " ${LIBPRQLR_PATH} " " ${LIBPRQLR_DEFAULT_PATH} " || echo " Failed to copy binary." )
79
73
------------------------------------------------------------------
80
74
EOF
81
75
fi
82
- exit 0
83
- elif [ " ${LIBPRQLR_BUILD} " = " false " ] && [ -f " ${LIBPRQLR_DEFAULT_PATH} " ]; then
84
- cat << EOF
76
+
77
+ if [ -f " ${LIBPRQLR_DEFAULT_PATH} " ]; then
78
+ cat << EOF
85
79
---------------------- [LIBRARY BINARY FOUND] ----------------------
86
- The library was not found at <${LIBPRQLR_PATH} >,
87
- but was found at <${LIBPRQLR_DEFAULT_PATH} >. No need to build it.
80
+ The library was found at <${LIBPRQLR_DEFAULT_PATH} >. No need to build it.
88
81
89
82
Note: rustc version: $( command -v rustc > /dev/null && rustc -V || echo " Not found" )
90
83
--------------------------------------------------------------------
91
84
EOF
92
- sed -e " s|@RUST_TARGET@||" src/Makevars.in > src/Makevars
93
- exit 0
94
- elif [ " ${LIBPRQLR_BUILD} " = " false " ] ; then
95
- cat << EOF
85
+ sed -e " s|@RUST_TARGET@||" src/Makevars.in > src/Makevars
86
+ exit 0
87
+ fi
88
+ cat << EOF
96
89
-------------------- [LIBRARY BINARY NOT FOUND] --------------------
97
90
The library was not found at <${LIBPRQLR_PATH} >.
98
91
Falling back to building from source.
@@ -106,7 +99,7 @@ detect_target_option() {
106
99
case " ${option} " in
107
100
--host=* )
108
101
specified_target=" $( echo " ${option} " | sed -e ' s/--host=//' | sed -E ' s/([0-9]+\.)*[0-9]+$//' ) "
109
- cat << EOF
102
+ cat << EOF
110
103
------------------------- [DETECTED TARGET] -------------------------
111
104
The target was specified as <${specified_target} > via the '--host' option.
112
105
---------------------------------------------------------------------
119
112
done
120
113
}
121
114
115
+ check_msrv () {
116
+ rustc_version=" $( rustc -V | grep -o ' [0-9]\+\(\.[0-9]\+\)\+' ) "
117
+ package_rust_version=" $(
118
+ cargo metadata --manifest-path src/rust/Cargo.toml --no-deps --format-version 1 |
119
+ grep -o ' "rust_version"\s*:\s*"[0-9]\+\(\.[0-9]\+\)\+"' |
120
+ grep -o ' [0-9]\+\(\.[0-9]\+\)\+'
121
+ ) "
122
+ lower_version=" $( echo " ${rustc_version} ${package_rust_version} " | tr ' ' ' \n' | sort -V | head -n1) "
123
+
124
+ if [ " ${rustc_version} " != " ${package_rust_version} " ] && [ " ${rustc_version} " = " ${lower_version} " ]; then
125
+ cat << EOF
126
+ ------------------- [NOT SUPPORTED RUST VERSION] -------------------
127
+ The MSRV of this package is '${package_rust_version} ',
128
+ so this installation may fail with the current rustc version '${rustc_version} '.
129
+ If this happens, please install the newer version of rustc
130
+ from: https://www.rust-lang.org/tools/install
131
+ --------------------------------------------------------------------
132
+ EOF
133
+ else
134
+ cat << EOF
135
+ ----------------- [MINIMUM SUPPORTED RUST VERSION] -----------------
136
+ The MSRV of this package is '${package_rust_version} '.
137
+ --------------------------------------------------------------------
138
+ EOF
139
+ fi
140
+ }
141
+
122
142
detect_target_option " $@ "
123
143
check_bin_lib
124
144
check_cargo
145
+ check_msrv
125
146
126
147
# cf. https://github.com/r-wasm/rwasm/issues/18#issuecomment-1910198843
127
148
if [ " $( uname) " = " Emscripten" ]; then
0 commit comments