Skip to content

Commit

Permalink
Merge pull request rust-lang#1837 from JohnTitor/xbuild
Browse files Browse the repository at this point in the history
Use `build-std` feature instead of using `cargo-xbuild`
  • Loading branch information
JohnTitor authored Jul 25, 2020
2 parents f944fce + 45317a0 commit d706b4d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
42 changes: 28 additions & 14 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ RUST=${TOOLCHAIN}
echo "Testing Rust ${RUST} on ${OS}"

if [ "${TOOLCHAIN}" = "nightly" ] ; then
cargo +nightly install cargo-xbuild
rustup component add rust-src
fi

Expand All @@ -41,29 +40,46 @@ test_target() {
fi

# Test that libc builds without any default features (no libstd)
cargo "+${RUST}" "${BUILD_CMD}" -vv --no-default-features --target "${TARGET}"

if [ "${NO_STD}" != "1" ]; then
cargo "+${RUST}" "${BUILD_CMD}" -vv --no-default-features --target "${TARGET}"
else
cargo "+${RUST}" "${BUILD_CMD}" -Z build-std=core,alloc -vv --no-default-features --target "${TARGET}"
fi
# Test that libc builds with default features (e.g. libstd)
# if the target supports libstd
if [ "$NO_STD" != "1" ]; then
cargo "+${RUST}" "${BUILD_CMD}" -vv --target "${TARGET}"
else
cargo "+${RUST}" "${BUILD_CMD}" -Z build-std=core,alloc -vv --target "${TARGET}"
fi

# Test that libc builds with the `extra_traits` feature
cargo "+${RUST}" "${BUILD_CMD}" -vv --no-default-features --target "${TARGET}" \
if [ "${NO_STD}" != "1" ]; then
cargo "+${RUST}" "${BUILD_CMD}" -vv --no-default-features --target "${TARGET}" \
--features extra_traits
else
cargo "+${RUST}" "${BUILD_CMD}" -Z build-std=core,alloc -vv --no-default-features \
--target "${TARGET}" --features extra_traits
fi

# Test the 'const-extern-fn' feature on nightly
if [ "${RUST}" = "nightly" ]; then
cargo "+${RUST}" "${BUILD_CMD}" -vv --no-default-features --target "${TARGET}" \
--features const-extern-fn
if [ "${NO_STD}" != "1" ]; then
cargo "+${RUST}" "${BUILD_CMD}" -vv --no-default-features --target "${TARGET}" \
--features const-extern-fn
else
cargo "+${RUST}" "${BUILD_CMD}" -Z build-std=core,alloc -vv --no-default-features \
--target "${TARGET}" --features const-extern-fn
fi
fi


# Also test that it builds with `extra_traits` and default features:
if [ "$NO_STD" != "1" ]; then
cargo "+${RUST}" "${BUILD_CMD}" -vv --target "${TARGET}" \
--features extra_traits
else
cargo "+${RUST}" "${BUILD_CMD}" -Z build-std=core,alloc -vv --target "${TARGET}" \
--features extra_traits
fi
}

Expand Down Expand Up @@ -166,7 +182,7 @@ case "${OS}" in
esac

for TARGET in $TARGETS; do
if echo "$TARGET"|grep -q "$FILTER";then
if echo "$TARGET"|grep -q "$FILTER"; then
test_target build "$TARGET"
fi
done
Expand All @@ -193,6 +209,7 @@ i686-unknown-haiku \
i686-unknown-netbsd \
i686-unknown-openbsd \
mips-unknown-linux-uclibc \
mipsel-sony-psp \
mipsel-unknown-linux-uclibc \
mips64-unknown-linux-muslabi64 \
mips64el-unknown-linux-muslabi64 \
Expand Down Expand Up @@ -229,13 +246,10 @@ powerpc64-wrs-vxworks \

if [ "${RUST}" = "nightly" ] && [ "${OS}" = "linux" ]; then
for TARGET in $RUST_LINUX_NO_CORE_TARGETS; do
if echo "$TARGET"|grep -q "$FILTER";then
test_target xbuild "$TARGET" 1
if echo "$TARGET"|grep -q "$FILTER"; then
test_target build "$TARGET" 1
fi
done

# Sony PSP
cargo xbuild --target mipsel-sony-psp
fi

RUST_OSX_NO_CORE_TARGETS="\
Expand All @@ -248,7 +262,7 @@ i686-apple-darwin \
if [ "${RUST}" = "nightly" ] && [ "${OS}" = "osx" ]; then
for TARGET in $RUST_OSX_NO_CORE_TARGETS; do
if echo "$TARGET" | grep -q "$FILTER"; then
test_target xbuild "$TARGET" 1
test_target build "$TARGET" 1
fi
done
fi
6 changes: 3 additions & 3 deletions ci/dox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ if ! rustc --version | grep -E "nightly" ; then
fi

rustup component add rust-src
cargo +nightly install cargo-xbuild

# List all targets that do currently build successfully:
# shellcheck disable=SC1003
Expand Down Expand Up @@ -50,10 +49,11 @@ while read -r target; do
# Enable extra configuration flags:
export RUSTDOCFLAGS="--cfg freebsd11"

# If cargo doc fails, then try xargo:
# If cargo doc fails, then try with unstable feature:
if ! cargo doc --target "${target}" \
--no-default-features --features extra_traits ; then
cargo xdoc --target "${target}" \
cargo doc --target "${target}" \
-Z build-std=core,alloc \
--no-default-features --features extra_traits
fi

Expand Down
3 changes: 1 addition & 2 deletions ci/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ build_switch() {
kvm=""
fi

cargo +nightly install cargo-xbuild
cp "$(which rustup)" "$(rustc --print sysroot)/bin"

docker run \
Expand All @@ -82,7 +81,7 @@ build_switch() {
libc \
sh -c "HOME=/tmp RUSTUP_HOME=/tmp PATH=\$PATH:/rust/bin rustup default nightly \
&& rustup component add rust-src --target ci/switch.json \
&& cargo xbuild --target ci/switch.json"
&& cargo build -Z build-std=core,alloc --target ci/switch.json"
}

if [ -z "${1}" ]; then
Expand Down

0 comments on commit d706b4d

Please sign in to comment.