Skip to content

Commit dea55a4

Browse files
committed
Clean up ci/no_atomic_cas.sh
1 parent 47e7cd4 commit dea55a4

File tree

6 files changed

+24
-21
lines changed

6 files changed

+24
-21
lines changed

ci/no_atomic_cas.sh

+19-16
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
#!/bin/bash
2+
set -euo pipefail
3+
IFS=$'\n\t'
4+
cd "$(dirname "$0")"/..
25

36
# Update the list of targets that do not support atomic CAS operations.
47
#
58
# Usage:
69
# ./ci/no_atomic_cas.sh
710

8-
set -euo pipefail
9-
IFS=$'\n\t'
10-
11-
cd "$(cd "$(dirname "$0")" && pwd)"/..
12-
1311
file="no_atomic_cas.rs"
1412

15-
{
16-
echo "// This file is @generated by $(basename "$0")."
17-
echo "// It is not intended for manual editing."
18-
echo ""
19-
echo "const NO_ATOMIC_CAS_TARGETS: &[&str] = &["
20-
} >"$file"
21-
13+
no_atomic_cas=()
2214
for target in $(rustc --print target-list); do
23-
res=$(rustc --print target-spec-json -Z unstable-options --target "$target" \
24-
| jq -r "select(.\"atomic-cas\" == false)")
25-
[[ -z "$res" ]] || echo " \"$target\"," >>"$file"
15+
target_spec=$(rustc --print target-spec-json -Z unstable-options --target "${target}")
16+
res=$(jq <<<"${target_spec}" -r 'select(."atomic-cas" == false)')
17+
[[ -z "${res}" ]] || no_atomic_cas+=("${target}")
2618
done
2719

28-
echo "];" >>"$file"
20+
cat >"${file}" <<EOF
21+
// This file is @generated by $(basename "$0").
22+
// It is not intended for manual editing.
23+
24+
const NO_ATOMIC_CAS: &[&str] = &[
25+
EOF
26+
for target in "${no_atomic_cas[@]}"; do
27+
echo " \"${target}\"," >>"${file}"
28+
done
29+
cat >>"${file}" <<EOF
30+
];
31+
EOF

futures-channel/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn main() {
3434
// `cfg(target_has_atomic = "ptr")` as true when the build script doesn't
3535
// run. This is needed for compatibility with non-cargo build systems that
3636
// don't run the build script.
37-
if NO_ATOMIC_CAS_TARGETS.contains(&&*target) {
37+
if NO_ATOMIC_CAS.contains(&&*target) {
3838
println!("cargo:rustc-cfg=futures_no_atomic_cas");
3939
}
4040

futures-core/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn main() {
3434
// `cfg(target_has_atomic = "ptr")` as true when the build script doesn't
3535
// run. This is needed for compatibility with non-cargo build systems that
3636
// don't run the build script.
37-
if NO_ATOMIC_CAS_TARGETS.contains(&&*target) {
37+
if NO_ATOMIC_CAS.contains(&&*target) {
3838
println!("cargo:rustc-cfg=futures_no_atomic_cas");
3939
}
4040

futures-task/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn main() {
3434
// `cfg(target_has_atomic = "ptr")` as true when the build script doesn't
3535
// run. This is needed for compatibility with non-cargo build systems that
3636
// don't run the build script.
37-
if NO_ATOMIC_CAS_TARGETS.contains(&&*target) {
37+
if NO_ATOMIC_CAS.contains(&&*target) {
3838
println!("cargo:rustc-cfg=futures_no_atomic_cas");
3939
}
4040

futures-util/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn main() {
3434
// `cfg(target_has_atomic = "ptr")` as true when the build script doesn't
3535
// run. This is needed for compatibility with non-cargo build systems that
3636
// don't run the build script.
37-
if NO_ATOMIC_CAS_TARGETS.contains(&&*target) {
37+
if NO_ATOMIC_CAS.contains(&&*target) {
3838
println!("cargo:rustc-cfg=futures_no_atomic_cas");
3939
}
4040

no_atomic_cas.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This file is @generated by no_atomic_cas.sh.
22
// It is not intended for manual editing.
33

4-
const NO_ATOMIC_CAS_TARGETS: &[&str] = &[
4+
const NO_ATOMIC_CAS: &[&str] = &[
55
"avr-unknown-gnu-atmega328",
66
"bpfeb-unknown-none",
77
"bpfel-unknown-none",

0 commit comments

Comments
 (0)