Skip to content

Commit

Permalink
Update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Apr 30, 2023
1 parent d5ae628 commit ee3443f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
10 changes: 4 additions & 6 deletions tools/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ build() {
local target_flags=(--target "${target}")
fi
args+=("${target_flags[@]}")
cfgs=$(RUSTC_BOOTSTRAP=1 rustc ${pre_args[@]+"${pre_args[@]}"} --print cfg "${target_flags[@]}")
if grep <<<"${rustup_target_list}" -Eq "^${target}$"; then
rustup ${pre_args[@]+"${pre_args[@]}"} target add "${target}" &>/dev/null
elif [[ -n "${nightly}" ]]; then
Expand All @@ -279,18 +280,15 @@ build() {
# On musl, building std with pre-1.59 nightly requires musl toolchain.
args+=(-Z build-std="core,alloc")
args+=(--exclude-features "std")
elif grep <<<"${cfgs}" -q 'panic="abort"'; then
args+=(-Z build-std="panic_abort,std")
else
case "${target}" in
# panic=abort
*-espidf*) args+=(-Z build-std="panic_abort,std") ;;
*) args+=(-Z build-std) ;;
esac
args+=(-Z build-std)
fi
else
echo "target '${target}' requires nightly compiler (skipped all checks)"
return 0
fi
cfgs=$(RUSTC_BOOTSTRAP=1 rustc ${pre_args[@]+"${pre_args[@]}"} --print cfg "${target_flags[@]}")
has_atomic_cas='1'
# target_has_atomic changed in 1.40.0-nightly: https://github.com/rust-lang/rust/pull/65214
if [[ "${rustc_minor_version}" -ge 40 ]]; then
Expand Down
10 changes: 5 additions & 5 deletions tools/no-std.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fi

rustup_target_list=''
if [[ -z "${is_custom_toolchain}" ]]; then
rustup_target_list=$(rustup ${pre_args[@]+"${pre_args[@]}"} target list)
rustup_target_list=$(rustup ${pre_args[@]+"${pre_args[@]}"} target list | sed 's/ .*//g')
fi
rustc_target_list=$(rustc ${pre_args[@]+"${pre_args[@]}"} --print target-list)
rustc_version=$(rustc ${pre_args[@]+"${pre_args[@]}"} -Vv | grep 'release: ' | sed 's/release: //')
Expand All @@ -105,9 +105,9 @@ run() {
echo "target '${target}' not available on ${rustc_version} (skipped)"
return 0
fi
target_flags=(--target "$(pwd)/target-specs/${target}.json")
local target_flags=(--target "$(pwd)/target-specs/${target}.json")
else
target_flags=(--target "${target}")
local target_flags=(--target "${target}")
fi
local subcmd=run
case "${target}" in
Expand All @@ -125,8 +125,8 @@ run() {
;;
esac
args+=("${subcmd}" "${target_flags[@]}")
if grep <<<"${rustup_target_list}" -Eq "^${target}( |$)"; then
x rustup ${pre_args[@]+"${pre_args[@]}"} target add "${target}" &>/dev/null
if grep <<<"${rustup_target_list}" -Eq "^${target}$"; then
rustup ${pre_args[@]+"${pre_args[@]}"} target add "${target}" &>/dev/null
elif [[ -n "${nightly}" ]]; then
args+=(-Z build-std="core")
else
Expand Down
4 changes: 2 additions & 2 deletions tools/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ done

cargo="${cargo:-cargo}"
if type -P rustup &>/dev/null; then
rustup_target_list=$(rustup ${pre_args[@]+"${pre_args[@]}"} target list)
rustup_target_list=$(rustup ${pre_args[@]+"${pre_args[@]}"} target list | sed 's/ .*//g')
fi
rustc_target_list=$(rustc ${pre_args[@]+"${pre_args[@]}"} --print target-list)
rustc_version=$(rustc ${pre_args[@]+"${pre_args[@]}"} -Vv | grep 'release: ' | sed 's/release: //')
Expand Down Expand Up @@ -103,7 +103,7 @@ if [[ -n "${target}" ]]; then
fi
args+=("${target_flags[@]}")
if type -P rustup &>/dev/null; then
if grep <<<"${rustup_target_list}" -Eq "^${target}( |$)"; then
if grep <<<"${rustup_target_list}" -Eq "^${target}$"; then
rustup ${pre_args[@]+"${pre_args[@]}"} target add "${target}" &>/dev/null
elif [[ -n "${nightly}" ]]; then
if [[ -z "${build_std}" ]]; then
Expand Down

0 comments on commit ee3443f

Please sign in to comment.