Skip to content

Commit 9f581e6

Browse files
authored
Merge pull request #1823 from JohnTitor/switch
Revive CI for the switch target
2 parents 8d90baf + 75d3ea5 commit 9f581e6

File tree

4 files changed

+59
-23
lines changed

4 files changed

+59
-23
lines changed

ci/azure.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,16 @@ jobs:
186186
variables:
187187
OS: linux
188188

189+
# devkitpro's pacman needs to be connected from Docker.
190+
- job: DockerSwitch
191+
dependsOn: StyleAndDocs
192+
pool:
193+
vmImage: ubuntu-18.04
194+
steps:
195+
- template: azure-install-rust.yml
196+
- bash: LIBC_CI=1 sh ./ci/run-docker.sh switch
197+
displayName: Execute run-docker.sh
198+
189199
- job: BuildChannelsOSX
190200
dependsOn: StyleAndDocs
191201
pool:

ci/build.sh

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ test_target() {
5151

5252
# Test that libc builds with the `extra_traits` feature
5353
cargo "+${RUST}" "${BUILD_CMD}" -vv --no-default-features --target "${TARGET}" \
54-
--features extra_traits
54+
--features extra_traits
5555

5656
# Test the 'const-extern-fn' feature on nightly
5757
if [ "${RUST}" = "nightly" ]; then
5858
cargo "+${RUST}" "${BUILD_CMD}" -vv --no-default-features --target "${TARGET}" \
59-
--features const-extern-fn
59+
--features const-extern-fn
6060
fi
6161

6262

6363
# Also test that it builds with `extra_traits` and default features:
6464
if [ "$NO_STD" != "1" ]; then
6565
cargo "+${RUST}" "${BUILD_CMD}" -vv --target "${TARGET}" \
66-
--features extra_traits
66+
--features extra_traits
6767
fi
6868
}
6969

@@ -233,25 +233,6 @@ if [ "${RUST}" = "nightly" ] && [ "${OS}" = "linux" ]; then
233233
test_target xbuild "$TARGET" 1
234234
fi
235235
done
236-
237-
# Nintendo switch
238-
# FIXME: Somehow downloads.devkitpro.org returns 403 now.
239-
# Temorarily disabled tests for this target.
240-
# cargo clean
241-
# mkdir -p target
242-
# (
243-
# cd target
244-
# wget https://github.com/devkitPro/pacman/releases/download/v1.0.2/devkitpro-pacman.amd64.deb
245-
# sudo apt-get install gdebi-core
246-
# sudo gdebi -nq devkitpro-pacman.amd64.deb
247-
# sudo dkp-pacman -Sy
248-
# sudo dkp-pacman -Syu
249-
# sudo dkp-pacman -S -v --noconfirm switch-dev devkitA64
250-
# )
251-
# cp ci/switch.json switch.json
252-
# PATH="$PATH:/opt/devkitpro/devkitA64/bin"
253-
# PATH="$PATH:/opt/devkitpro/tools/bin"
254-
# cargo xbuild --target switch.json
255236
fi
256237

257238
RUST_OSX_NO_CORE_TARGETS="\

ci/docker/switch/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM huyuumi/libc-switch:latest
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
gcc libc6-dev ca-certificates
5+
6+
ENV PATH=$PATH:/rust/bin

ci/run-docker.sh

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,49 @@ run() {
5050
sh -c "HOME=/tmp PATH=\$PATH:/rust/bin exec ci/run.sh ${1}"
5151
}
5252

53+
build_switch() {
54+
echo "Building docker container for target switch"
55+
56+
# use -f so we can use ci/ as build context
57+
docker build -t libc -f "ci/docker/switch/Dockerfile" ci/
58+
mkdir -p target
59+
if [ -w /dev/kvm ]; then
60+
kvm="--volume /dev/kvm:/dev/kvm"
61+
else
62+
kvm=""
63+
fi
64+
65+
cargo +nightly install cargo-xbuild
66+
cp "$(which rustup)" "$(rustc --print sysroot)/bin"
67+
68+
docker run \
69+
--rm \
70+
--user "$(id -u)":"$(id -g)" \
71+
--env LIBC_CI \
72+
--env CARGO_HOME=/cargo \
73+
--env CARGO_TARGET_DIR=/checkout/target \
74+
--volume "$CARGO_HOME":/cargo \
75+
--volume "$(rustc --print sysroot)":/rust:ro \
76+
--volume "$(pwd)":/checkout:ro \
77+
--volume "$(pwd)"/target:/checkout/target \
78+
--volume ~/.rustup:/.rustup:Z \
79+
$kvm \
80+
--init \
81+
--workdir /checkout \
82+
libc \
83+
sh -c "HOME=/tmp RUSTUP_HOME=/tmp PATH=\$PATH:/rust/bin rustup default nightly \
84+
&& rustup component add rust-src --target ci/switch.json \
85+
&& cargo xbuild --target ci/switch.json"
86+
}
87+
5388
if [ -z "${1}" ]; then
5489
for d in ci/docker/*; do
5590
run "${d}"
5691
done
5792
else
58-
run "${1}"
93+
if [ "${1}" != "switch" ]; then
94+
run "${1}"
95+
else
96+
build_switch
97+
fi
5998
fi

0 commit comments

Comments
 (0)