Skip to content

Commit d0959f9

Browse files
committed
Auto merge of #1346 - gnzlbg:simplify_freebsd, r=gnzlbg
Clean up libc-test/build.rs for FreeBSD and enable testing FreeBSD12 on CI
2 parents 15855d6 + 7437d0a commit d0959f9

File tree

17 files changed

+710
-421
lines changed

17 files changed

+710
-421
lines changed

.cirrus.yml

+20-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
1-
freebsd_instance:
2-
image: freebsd-11-1-release-amd64
3-
41
task:
5-
# This name gets reported as a build status in GitHub
6-
name: stable x86_64-unknown-freebsd
2+
name: stable x86_64-unknown-freebsd-11
3+
freebsd_instance:
4+
image: freebsd-11-2-release-amd64
75
setup_script:
86
- pkg install -y curl
97
- curl https://sh.rustup.rs -sSf --output rustup.sh
108
- sh rustup.sh -y
9+
- . $HOME/.cargo/env
10+
- rustup default stable
11+
test_script:
12+
- . $HOME/.cargo/env
13+
- sh ci/run.sh x86_64-unknown-freebsd
14+
15+
task:
16+
name: nightly x86_64-unknown-freebsd-12
17+
freebsd_instance:
18+
image: freebsd-12-0-release-amd64
19+
setup_script:
20+
- pkg install -y curl
21+
- curl https://sh.rustup.rs -sSf --output rustup.sh
22+
- sh rustup.sh --default-toolchain nightly -y
23+
- . $HOME/.cargo/env
24+
- rustup default nightly
1125
test_script:
1226
- . $HOME/.cargo/env
13-
- cd libc-test
14-
- cargo test
27+
- sh ci/run.sh x86_64-unknown-freebsd

build.rs

+29
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ fn main() {
1616
);
1717
}
1818

19+
if std::env::var("LIBC_CI").is_ok() {
20+
if let Some(12) = which_freebsd() {
21+
println!("cargo:rustc-cfg=freebsd12");
22+
}
23+
}
24+
1925
// Rust >= 1.15 supports private module use:
2026
if rustc_minor_ver >= 15 || rustc_dep_of_std {
2127
println!("cargo:rustc-cfg=libc_priv_mod_use");
@@ -70,3 +76,26 @@ fn rustc_minor_version() -> Option<u32> {
7076

7177
otry!(pieces.next()).parse().ok()
7278
}
79+
80+
fn which_freebsd() -> Option<i32> {
81+
let output = std::process::Command::new("freebsd-version").output().ok();
82+
if output.is_none() {
83+
return None;
84+
}
85+
let output = output.unwrap();
86+
if !output.status.success() {
87+
return None;
88+
}
89+
90+
let stdout = String::from_utf8(output.stdout).ok();
91+
if stdout.is_none() {
92+
return None;
93+
}
94+
let stdout = stdout.unwrap();
95+
96+
match &stdout {
97+
s if s.starts_with("11") => Some(11),
98+
s if s.starts_with("12") => Some(12),
99+
_ => None,
100+
}
101+
}

ci/run.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ if [ "$TARGET" = "x86_64-unknown-linux-gnux32" ]; then
8787
opt="--release"
8888
fi
8989

90-
cargo test $opt --no-default-features --manifest-path libc-test/Cargo.toml \
90+
export LIBC_CI=1
91+
92+
cargo test -vv $opt --no-default-features --manifest-path libc-test/Cargo.toml \
9193
--target "${TARGET}"
9294

93-
cargo test $opt --manifest-path libc-test/Cargo.toml --target "${TARGET}"
95+
cargo test -vv $opt --manifest-path libc-test/Cargo.toml --target "${TARGET}"
9496

95-
cargo test $opt --features extra_traits --manifest-path libc-test/Cargo.toml \
97+
cargo test -vv $opt --features extra_traits --manifest-path libc-test/Cargo.toml \
9698
--target "${TARGET}"

0 commit comments

Comments
 (0)