Skip to content

Commit a9b3f97

Browse files
committed
Auto merge of #1127 - gnzlbg:fmt, r=gnzlbg
Formatting and shellcheck
2 parents 2921acc + 37a0bd3 commit a9b3f97

16 files changed

+400
-320
lines changed

.travis.yml

+38-27
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,30 @@ language: rust
22
rust: stable
33
sudo: required
44
dist: trusty
5-
services:
6-
- docker
7-
install:
8-
- if [ -z "$NO_ADD" ]; then rustup target add $TARGET; fi
9-
script:
10-
- cargo build $OPT
11-
- cargo build $OPT --no-default-features
12-
- cargo generate-lockfile --manifest-path libc-test/Cargo.toml
13-
- if [[ $TRAVIS_OS_NAME = "linux" ]]; then
14-
sh ci/run-docker.sh $TARGET;
15-
else
16-
export CARGO_TARGET_DIR=`pwd`/target;
17-
sh ci/run.sh $TARGET;
18-
fi
19-
- rustc ci/style.rs && ./style src
20-
env:
21-
global:
22-
secure: "e2/3QjgRN9atOuSHp22TrYG7QVKcYUWY48Hi9b60w+r1+BhPkTseIJLte7WefRhdXtqpjjUJTooKDhnurFOeHaCT+nmBgiv+FPU893sBl4bhesY4m0vgUJVbNZcs6lTImYekWVb+aqjGdgV/XAgCw7c3kPmrZV0MzGDWL64Xaps="
5+
services: docker
6+
237
matrix:
248
include:
259
# 1.13.0 compat
26-
- env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
10+
- env: TARGET=x86_64-unknown-linux-gnu
2711
rust: 1.13.0
2812
script: rm -f Cargo.lock && cargo build
29-
install:
13+
install: true
3014

3115
# build documentation
32-
- env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
16+
- env: TARGET=x86_64-unknown-linux-gnu
3317
rust: nightly
3418
script: sh ci/dox.sh
19+
install: true
3520

3621
# stable compat
37-
- env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
22+
- env: TARGET=x86_64-unknown-linux-gnu
23+
install: true
3824
- env: TARGET=i686-unknown-linux-gnu
3925
- os: osx
40-
env: TARGET=x86_64-apple-darwin NO_ADD=1
26+
env: TARGET=x86_64-apple-darwin
4127
osx_image: xcode10
28+
install: true
4229
- os: osx
4330
env: TARGET=i686-apple-darwin
4431
osx_image: xcode10
@@ -67,20 +54,24 @@ matrix:
6754
- env: TARGET=wasm32-unknown-emscripten
6855

6956
# beta
70-
- env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
57+
- env: TARGET=x86_64-unknown-linux-gnu
7158
rust: beta
59+
install: true
7260
- os: osx
73-
env: TARGET=x86_64-apple-darwin NO_ADD=1
61+
env: TARGET=x86_64-apple-darwin
7462
osx_image: xcode10
7563
rust: beta
64+
install: true
7665

7766
# nightly
78-
- env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
67+
- env: TARGET=x86_64-unknown-linux-gnu
7968
rust: nightly
69+
install: true
8070
- os: osx
81-
env: TARGET=x86_64-apple-darwin NO_ADD=1
71+
env: TARGET=x86_64-apple-darwin
8272
osx_image: xcode10
8373
rust: nightly
74+
install: true
8475
# not available on stable
8576
# without --release the build fails
8677
# see https://github.com/rust-lang/rust/issues/45417
@@ -90,6 +81,26 @@ matrix:
9081
# QEMU based targets that compile in an emulator
9182
- env: TARGET=x86_64-unknown-freebsd
9283

84+
- name: "Shellcheck"
85+
install: true
86+
script:
87+
- shellcheck --version
88+
- shellcheck ci/*.sh
89+
90+
install: rustup target add $TARGET
91+
script:
92+
- cargo generate-lockfile --manifest-path libc-test/Cargo.toml
93+
- if [[ $TRAVIS_OS_NAME = "linux" ]]; then
94+
sh ci/run-docker.sh $TARGET;
95+
else
96+
export CARGO_TARGET_DIR=`pwd`/target;
97+
sh ci/run.sh $TARGET;
98+
fi
99+
- rustc ci/style.rs && ./style src
100+
env:
101+
global:
102+
secure: "e2/3QjgRN9atOuSHp22TrYG7QVKcYUWY48Hi9b60w+r1+BhPkTseIJLte7WefRhdXtqpjjUJTooKDhnurFOeHaCT+nmBgiv+FPU893sBl4bhesY4m0vgUJVbNZcs6lTImYekWVb+aqjGdgV/XAgCw7c3kPmrZV0MzGDWL64Xaps="
103+
93104
notifications:
94105
email:
95106
on_success: never

ci/android-install-ndk.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env sh
22
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
33
# file at the top-level directory of this distribution and at
44
# http://rust-lang.org/COPYRIGHT.
@@ -30,8 +30,8 @@ esac;
3030

3131
android-ndk-r15b/build/tools/make_standalone_toolchain.py \
3232
--unified-headers \
33-
--install-dir /android/ndk-$1 \
34-
--arch $arch \
33+
--install-dir "/android/ndk-${1}" \
34+
--arch "${arch}" \
3535
--api 24
3636

3737
rm -rf ./android-ndk-r15b-linux-x86_64.zip ./android-ndk-r15b

ci/android-install-sdk.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env sh
22
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
33
# file at the top-level directory of this distribution and at
44
# http://rust-lang.org/COPYRIGHT.
@@ -56,5 +56,5 @@ echo "yes" | \
5656

5757
echo "no" |
5858
./sdk/tools/bin/avdmanager create avd \
59-
--name $1 \
59+
--name "${1}" \
6060
--package "system-images;android-24;default;$abi"

ci/android-sysimage.sh

+22-18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bash
2+
13
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
24
# file at the top-level directory of this distribution and at
35
# http://rust-lang.org/COPYRIGHT.
@@ -13,40 +15,42 @@ set -ex
1315
URL=https://dl.google.com/android/repository/sys-img/android
1416

1517
main() {
16-
local arch=$1
17-
local name=$2
18+
local arch="${1}"
19+
local name="${2}"
1820
local dest=/system
19-
local td=$(mktemp -d)
21+
local td
22+
td="$(mktemp -d)"
2023

2124
apt-get install --no-install-recommends e2tools
2225

23-
pushd $td
24-
curl -O $URL/$name
25-
unzip -q $name
26+
pushd "${td}"
27+
curl -O "${URL}/${name}"
28+
unzip -q "${name}"
2629

27-
local system=$(find . -name system.img)
28-
mkdir -p $dest/{bin,lib,lib64}
30+
local system
31+
system="$(find . -name system.img)"
32+
mkdir -p ${dest}/{bin,lib,lib64}
2933

3034
# Extract android linker and libraries to /system
3135
# This allows android executables to be run directly (or with qemu)
32-
if [ $arch = "x86_64" -o $arch = "arm64" ]; then
33-
e2cp -p $system:/bin/linker64 $dest/bin/
34-
e2cp -p $system:/lib64/libdl.so $dest/lib64/
35-
e2cp -p $system:/lib64/libc.so $dest/lib64/
36-
e2cp -p $system:/lib64/libm.so $dest/lib64/
36+
if [ "${arch}" = "x86_64" ] || [ "${arch}" = "arm64" ]; then
37+
e2cp -p "${system}:/bin/linker64" "${dest}/bin/"
38+
e2cp -p "${system}:/lib64/libdl.so" "${dest}/lib64/"
39+
e2cp -p "${system}:/lib64/libc.so" "${dest}/lib64/"
40+
e2cp -p "${system}:/lib64/libm.so" "${dest}/lib64/"
3741
else
38-
e2cp -p $system:/bin/linker $dest/bin/
39-
e2cp -p $system:/lib/libdl.so $dest/lib/
40-
e2cp -p $system:/lib/libc.so $dest/lib/
41-
e2cp -p $system:/lib/libm.so $dest/lib/
42+
e2cp -p "${system}:/bin/linker" "${dest}/bin/"
43+
e2cp -p "${system}:/lib/libdl.so" "${dest}/lib/"
44+
e2cp -p "${system}:/lib/libc.so" "${dest}/lib/"
45+
e2cp -p "${system}:/lib/libm.so" "${dest}/lib/"
4246
fi
4347

4448
# clean up
4549
apt-get purge --auto-remove -y e2tools
4650

4751
popd
4852

49-
rm -rf $td
53+
rm -rf "${td}"
5054
}
5155

5256
main "${@}"

ci/dox.sh

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
#!/bin/sh
1+
#!/usr/bin/env sh
22

33
# Builds documentation for all target triples that we have a registered URL for
44
# in liblibc. This scrapes the list of triples to document from `src/lib.rs`
55
# which has a bunch of `html_root_url` directives we pick up.
66

7-
set -e
7+
set -ex
88

9-
TARGETS=`grep html_root_url src/lib.rs | sed 's/.*".*\/\(.*\)"/\1/'`
9+
TARGETS=$(grep html_root_url src/lib.rs | sed 's/.*".*\/\(.*\)"/\1/'| sed 's/)//')
1010

1111
rm -rf target/doc
1212
mkdir -p target/doc
1313

1414
cp ci/landing-page-head.html target/doc/index.html
1515

1616
for target in $TARGETS; do
17-
echo documenting $target
17+
echo "documenting ${target}"
1818

19-
rustdoc -o target/doc/$target --target $target src/lib.rs --cfg cross_platform_docs \
19+
rustdoc -o "target/doc/${target}" --target "${target}" src/lib.rs --cfg cross_platform_docs \
2020
--crate-name libc
2121

22-
echo "<li><a href="/libc/$target/libc/index.html">$target</a></li>" \
22+
echo "<li><a href=\"/libc/${target}/libc/index.html\">${target}</a></li>" \
2323
>> target/doc/index.html
2424
done
2525

@@ -28,6 +28,6 @@ cat ci/landing-page-footer.html >> target/doc/index.html
2828
# If we're on travis, not a PR, and on the right branch, publish!
2929
if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then
3030
pip install ghp_import --install-option="--prefix=$HOME/.local"
31-
$HOME/.local/bin/ghp-import -n target/doc
32-
git push -qf https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages
31+
"${HOME}/.local/bin/ghp-import" -n target/doc
32+
git push -qf "https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git" gh-pages
3333
fi

ci/emscripten-entry.sh

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
set -ex
1313

14+
# shellcheck disable=SC1091
1415
source /emsdk-portable/emsdk_env.sh &> /dev/null
1516

1617
# emsdk-portable provides a node binary, but we need version 8 to run wasm

ci/emscripten.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env bash
12
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
23
# file at the top-level directory of this distribution and at
34
# http://rust-lang.org/COPYRIGHT.
@@ -17,10 +18,10 @@ echo ERROR: An error was encountered with the build.
1718
cat /tmp/build.log
1819
exit 1
1920
"
20-
trap "$on_err" ERR
21+
trap '$on_err' ERR
2122
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
2223
PING_LOOP_PID=$!
23-
$@ &> /tmp/build.log
24+
"${@}" &> /tmp/build.log
2425
trap - ERR
2526
kill $PING_LOOP_PID
2627
rm -f /tmp/build.log
@@ -37,6 +38,7 @@ hide_output ./emsdk install sdk-1.37.20-64bit
3738
./emsdk activate sdk-1.37.20-64bit
3839

3940
# Compile and cache libc
41+
# shellcheck disable=SC1091
4042
source ./emsdk_env.sh
4143
echo "main(){}" > a.c
4244
HOME=/emsdk-portable/ emcc a.c

ci/linux-s390x.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env sh
2+
13
set -ex
24

35
mkdir -m 777 /qemu

ci/linux-sparc64.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env sh
2+
13
set -ex
24

35
mkdir -m 777 /qemu

ci/run-docker.sh

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
1+
#!/usr/bin/env sh
2+
13
# Small script to run tests for a target (or all targets) inside all the
24
# respective docker images.
35

46
set -ex
57

68
run() {
7-
echo $1
9+
echo "Building docker container for target ${1}"
810
# use -f so we can use ci/ as build context
9-
docker build -t libc -f ci/docker/$1/Dockerfile ci/
11+
docker build -t libc -f "ci/docker/${1}/Dockerfile" ci/
1012
mkdir -p target
1113
if [ -w /dev/kvm ]; then
12-
kvm="--volume /dev/kvm:/dev/kvm"
14+
kvm="--volume /dev/kvm:/dev/kvm"
15+
else
16+
kvm=""
1317
fi
18+
1419
docker run \
15-
--user `id -u`:`id -g` \
20+
--user "$(id -u)":"$(id -g)" \
1621
--rm \
1722
--init \
18-
--volume $HOME/.cargo:/cargo \
23+
--volume "${HOME}/.cargo":/cargo \
1924
$kvm \
2025
--env CARGO_HOME=/cargo \
21-
--volume `rustc --print sysroot`:/rust:ro \
22-
--volume `pwd`:/checkout:ro \
23-
--volume `pwd`/target:/checkout/target \
26+
--volume "$(rustc --print sysroot)":/rust:ro \
27+
--volume "$(pwd)":/checkout:ro \
28+
--volume "$(pwd)"/target:/checkout/target \
2429
--env CARGO_TARGET_DIR=/checkout/target \
2530
--workdir /checkout \
2631
libc \
27-
ci/run.sh $1
32+
ci/run.sh "${1}"
2833
}
2934

30-
if [ -z "$1" ]; then
31-
for d in `ls ci/docker/`; do
32-
run $d
35+
if [ -z "${1}" ]; then
36+
for d in ci/docker/*; do
37+
run "${d}"
3338
done
3439
else
35-
run $1
40+
run "${1}"
3641
fi

ci/run-qemu.sh

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env sh
2+
13
# Initial script which is run inside of all qemu images. The first argument to
24
# this script (as arranged by the qemu image itself) is the path to where the
35
# libc crate is mounted.
@@ -10,11 +12,11 @@
1012

1113
set -ex
1214

13-
ROOT=$1
14-
cp -r $ROOT/libc /tmp/libc
15+
ROOT="${1}"
16+
cp -r "${ROOT}/libc" /tmp/libc
1517
cd /tmp/libc
1618

17-
TARGET=$(cat $ROOT/TARGET)
19+
TARGET="$(cat "${ROOT}/TARGET")"
1820
export CARGO_TARGET_DIR=/tmp
1921

2022
case $TARGET in
@@ -24,9 +26,9 @@ case $TARGET in
2426
;;
2527

2628
*)
27-
echo "Unknown target: $TARGET"
29+
echo "Unknown target: ${TARGET}"
2830
exit 1
2931
;;
3032
esac
3133

32-
exec sh ci/run.sh $TARGET
34+
exec sh ci/run.sh "${TARGET}"

0 commit comments

Comments
 (0)