Skip to content

Commit a9863f3

Browse files
authored
feat: check msrv by the configure script and refactoring (#311)
1 parent 8f64f14 commit a9863f3

File tree

3 files changed

+54
-31
lines changed

3 files changed

+54
-31
lines changed

LICENSE.note

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,31 +484,31 @@ License: Apache-2.0 OR BSL-1.0
484484
-------------------------------------------------------------
485485

486486
Name: savvy
487-
Version: 0.6.7
487+
Version: 0.6.8
488488
Repository: https://github.com/yutannihilation/savvy/
489489
Authors: Hiroaki Yutani
490490
License: MIT
491491

492492
-------------------------------------------------------------
493493

494494
Name: savvy-bindgen
495-
Version: 0.6.7
495+
Version: 0.6.8
496496
Repository: https://github.com/yutannihilation/savvy/
497497
Authors: Hiroaki Yutani
498498
License: MIT
499499

500500
-------------------------------------------------------------
501501

502502
Name: savvy-ffi
503-
Version: 0.6.7
503+
Version: 0.6.8
504504
Repository: https://github.com/yutannihilation/savvy/
505505
Authors: Hiroaki Yutani
506506
License: MIT
507507

508508
-------------------------------------------------------------
509509

510510
Name: savvy-macro
511-
Version: 0.6.7
511+
Version: 0.6.8
512512
Repository: https://github.com/yutannihilation/savvy/
513513
Authors: Hiroaki Yutani
514514
License: MIT

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
## Miscellaneous
88

99
- On R-universe, installing with pre-built binaries is now default. (#305)
10+
- The configure script now compares the package's MSRV and the rustc version,
11+
and if the rustc version is less than the MSRV, an warning message is displayed. (#311)
1012

1113
# prqlr 0.8.1
1214

configure

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export PATH="$PATH:$HOME/.cargo/bin"
1414

1515
check_cargo() {
1616
if [ ! "$(command -v cargo)" ]; then
17-
cat <<EOF
17+
cat <<EOF
1818
------------------------- [RUST NOT FOUND] -------------------------
1919
The 'cargo' command was not found on the PATH. Please install rustc
2020
from: https://www.rust-lang.org/tools/install
@@ -27,7 +27,7 @@ Alternatively, you may install cargo from your OS package manager:
2727
EOF
2828
exit 1
2929
else
30-
cat <<EOF
30+
cat <<EOF
3131
--------------------------- [RUST FOUND] ---------------------------
3232
$(cargo -V)
3333
@@ -44,7 +44,7 @@ check_bin_lib() {
4444

4545
# On R-universe, we try to download the pre-built binary from GitHub releases.
4646
if [ -n "${MY_UNIVERSE}" ] && [ -z "${LIBPRQLR_BUILD}" ]; then
47-
cat <<EOF
47+
cat <<EOF
4848
--------------------- [SETTING FOR R-UNIVERSE] ---------------------
4949
It seems that this is on R-universe <${MY_UNIVERSE}>.
5050
Trying to download pre-built binary.
@@ -53,46 +53,39 @@ EOF
5353
LIBPRQLR_BUILD="false"
5454
fi
5555

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
5859
--------------- [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.
5962
$("${R_HOME}/bin${R_ARCH_BIN}/Rscript" "tools/prep-lib.R" || echo "Failed to download pre-built binary.")
6063
------------------------------------------------------------------
6164
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
6866

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
7569
------------------------ [COPYING BINARY] ------------------------
7670
Copying <${LIBPRQLR_PATH}> to <${LIBPRQLR_DEFAULT_PATH}>.
7771
$(mkdir -p "$(dirname "${LIBPRQLR_DEFAULT_PATH}")")
7872
$(cp "${LIBPRQLR_PATH}" "${LIBPRQLR_DEFAULT_PATH}" || echo "Failed to copy binary.")
7973
------------------------------------------------------------------
8074
EOF
8175
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
8579
---------------------- [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.
8881
8982
Note: rustc version: $(command -v rustc >/dev/null && rustc -V || echo "Not found")
9083
--------------------------------------------------------------------
9184
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
9689
-------------------- [LIBRARY BINARY NOT FOUND] --------------------
9790
The library was not found at <${LIBPRQLR_PATH}>.
9891
Falling back to building from source.
@@ -106,7 +99,7 @@ detect_target_option() {
10699
case "${option}" in
107100
--host=*)
108101
specified_target="$(echo "${option}" | sed -e 's/--host=//' | sed -E 's/([0-9]+\.)*[0-9]+$//')"
109-
cat <<EOF
102+
cat <<EOF
110103
------------------------- [DETECTED TARGET] -------------------------
111104
The target was specified as <${specified_target}> via the '--host' option.
112105
---------------------------------------------------------------------
@@ -119,9 +112,37 @@ EOF
119112
done
120113
}
121114

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+
122142
detect_target_option "$@"
123143
check_bin_lib
124144
check_cargo
145+
check_msrv
125146

126147
# cf. https://github.com/r-wasm/rwasm/issues/18#issuecomment-1910198843
127148
if [ "$(uname)" = "Emscripten" ]; then

0 commit comments

Comments
 (0)