Skip to content

Formatting and shellcheck #1127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 38 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,30 @@ language: rust
rust: stable
sudo: required
dist: trusty
services:
- docker
install:
- if [ -z "$NO_ADD" ]; then rustup target add $TARGET; fi
script:
- cargo build $OPT
- cargo build $OPT --no-default-features
- cargo generate-lockfile --manifest-path libc-test/Cargo.toml
- if [[ $TRAVIS_OS_NAME = "linux" ]]; then
sh ci/run-docker.sh $TARGET;
else
export CARGO_TARGET_DIR=`pwd`/target;
sh ci/run.sh $TARGET;
fi
- rustc ci/style.rs && ./style src
env:
global:
secure: "e2/3QjgRN9atOuSHp22TrYG7QVKcYUWY48Hi9b60w+r1+BhPkTseIJLte7WefRhdXtqpjjUJTooKDhnurFOeHaCT+nmBgiv+FPU893sBl4bhesY4m0vgUJVbNZcs6lTImYekWVb+aqjGdgV/XAgCw7c3kPmrZV0MzGDWL64Xaps="
services: docker

matrix:
include:
# 1.13.0 compat
- env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
- env: TARGET=x86_64-unknown-linux-gnu
rust: 1.13.0
script: rm -f Cargo.lock && cargo build
install:
install: true

# build documentation
- env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
- env: TARGET=x86_64-unknown-linux-gnu
rust: nightly
script: sh ci/dox.sh
install: true

# stable compat
- env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
- env: TARGET=x86_64-unknown-linux-gnu
install: true
- env: TARGET=i686-unknown-linux-gnu
- os: osx
env: TARGET=x86_64-apple-darwin NO_ADD=1
env: TARGET=x86_64-apple-darwin
osx_image: xcode10
install: true
- os: osx
env: TARGET=i686-apple-darwin
osx_image: xcode10
Expand Down Expand Up @@ -67,20 +54,24 @@ matrix:
- env: TARGET=wasm32-unknown-emscripten

# beta
- env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
- env: TARGET=x86_64-unknown-linux-gnu
rust: beta
install: true
- os: osx
env: TARGET=x86_64-apple-darwin NO_ADD=1
env: TARGET=x86_64-apple-darwin
osx_image: xcode10
rust: beta
install: true

# nightly
- env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
- env: TARGET=x86_64-unknown-linux-gnu
rust: nightly
install: true
- os: osx
env: TARGET=x86_64-apple-darwin NO_ADD=1
env: TARGET=x86_64-apple-darwin
osx_image: xcode10
rust: nightly
install: true
# not available on stable
# without --release the build fails
# see https://github.com/rust-lang/rust/issues/45417
Expand All @@ -90,6 +81,26 @@ matrix:
# QEMU based targets that compile in an emulator
- env: TARGET=x86_64-unknown-freebsd

- name: "Shellcheck"
install: true
script:
- shellcheck --version
- shellcheck ci/*.sh

install: rustup target add $TARGET
script:
- cargo generate-lockfile --manifest-path libc-test/Cargo.toml
- if [[ $TRAVIS_OS_NAME = "linux" ]]; then
sh ci/run-docker.sh $TARGET;
else
export CARGO_TARGET_DIR=`pwd`/target;
sh ci/run.sh $TARGET;
fi
- rustc ci/style.rs && ./style src
env:
global:
secure: "e2/3QjgRN9atOuSHp22TrYG7QVKcYUWY48Hi9b60w+r1+BhPkTseIJLte7WefRhdXtqpjjUJTooKDhnurFOeHaCT+nmBgiv+FPU893sBl4bhesY4m0vgUJVbNZcs6lTImYekWVb+aqjGdgV/XAgCw7c3kPmrZV0MzGDWL64Xaps="

notifications:
email:
on_success: never
Expand Down
6 changes: 3 additions & 3 deletions ci/android-install-ndk.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env sh
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
Expand Down Expand Up @@ -30,8 +30,8 @@ esac;

android-ndk-r15b/build/tools/make_standalone_toolchain.py \
--unified-headers \
--install-dir /android/ndk-$1 \
--arch $arch \
--install-dir "/android/ndk-${1}" \
--arch "${arch}" \
--api 24

rm -rf ./android-ndk-r15b-linux-x86_64.zip ./android-ndk-r15b
4 changes: 2 additions & 2 deletions ci/android-install-sdk.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env sh
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
Expand Down Expand Up @@ -56,5 +56,5 @@ echo "yes" | \

echo "no" |
./sdk/tools/bin/avdmanager create avd \
--name $1 \
--name "${1}" \
--package "system-images;android-24;default;$abi"
40 changes: 22 additions & 18 deletions ci/android-sysimage.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
Expand All @@ -13,40 +15,42 @@ set -ex
URL=https://dl.google.com/android/repository/sys-img/android

main() {
local arch=$1
local name=$2
local arch="${1}"
local name="${2}"
local dest=/system
local td=$(mktemp -d)
local td
td="$(mktemp -d)"

apt-get install --no-install-recommends e2tools

pushd $td
curl -O $URL/$name
unzip -q $name
pushd "${td}"
curl -O "${URL}/${name}"
unzip -q "${name}"

local system=$(find . -name system.img)
mkdir -p $dest/{bin,lib,lib64}
local system
system="$(find . -name system.img)"
mkdir -p ${dest}/{bin,lib,lib64}

# Extract android linker and libraries to /system
# This allows android executables to be run directly (or with qemu)
if [ $arch = "x86_64" -o $arch = "arm64" ]; then
e2cp -p $system:/bin/linker64 $dest/bin/
e2cp -p $system:/lib64/libdl.so $dest/lib64/
e2cp -p $system:/lib64/libc.so $dest/lib64/
e2cp -p $system:/lib64/libm.so $dest/lib64/
if [ "${arch}" = "x86_64" ] || [ "${arch}" = "arm64" ]; then
e2cp -p "${system}:/bin/linker64" "${dest}/bin/"
e2cp -p "${system}:/lib64/libdl.so" "${dest}/lib64/"
e2cp -p "${system}:/lib64/libc.so" "${dest}/lib64/"
e2cp -p "${system}:/lib64/libm.so" "${dest}/lib64/"
else
e2cp -p $system:/bin/linker $dest/bin/
e2cp -p $system:/lib/libdl.so $dest/lib/
e2cp -p $system:/lib/libc.so $dest/lib/
e2cp -p $system:/lib/libm.so $dest/lib/
e2cp -p "${system}:/bin/linker" "${dest}/bin/"
e2cp -p "${system}:/lib/libdl.so" "${dest}/lib/"
e2cp -p "${system}:/lib/libc.so" "${dest}/lib/"
e2cp -p "${system}:/lib/libm.so" "${dest}/lib/"
fi

# clean up
apt-get purge --auto-remove -y e2tools

popd

rm -rf $td
rm -rf "${td}"
}

main "${@}"
16 changes: 8 additions & 8 deletions ci/dox.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#!/bin/sh
#!/usr/bin/env sh

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

set -e
set -ex

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

rm -rf target/doc
mkdir -p target/doc

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

for target in $TARGETS; do
echo documenting $target
echo "documenting ${target}"

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

echo "<li><a href="/libc/$target/libc/index.html">$target</a></li>" \
echo "<li><a href=\"/libc/${target}/libc/index.html\">${target}</a></li>" \
>> target/doc/index.html
done

Expand All @@ -28,6 +28,6 @@ cat ci/landing-page-footer.html >> target/doc/index.html
# If we're on travis, not a PR, and on the right branch, publish!
if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then
pip install ghp_import --install-option="--prefix=$HOME/.local"
$HOME/.local/bin/ghp-import -n target/doc
git push -qf https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages
"${HOME}/.local/bin/ghp-import" -n target/doc
git push -qf "https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git" gh-pages
fi
1 change: 1 addition & 0 deletions ci/emscripten-entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

set -ex

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

# emsdk-portable provides a node binary, but we need version 8 to run wasm
Expand Down
6 changes: 4 additions & 2 deletions ci/emscripten.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bash
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
Expand All @@ -17,10 +18,10 @@ echo ERROR: An error was encountered with the build.
cat /tmp/build.log
exit 1
"
trap "$on_err" ERR
trap '$on_err' ERR
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
PING_LOOP_PID=$!
$@ &> /tmp/build.log
"${@}" &> /tmp/build.log
trap - ERR
kill $PING_LOOP_PID
rm -f /tmp/build.log
Expand All @@ -37,6 +38,7 @@ hide_output ./emsdk install sdk-1.37.20-64bit
./emsdk activate sdk-1.37.20-64bit

# Compile and cache libc
# shellcheck disable=SC1091
source ./emsdk_env.sh
echo "main(){}" > a.c
HOME=/emsdk-portable/ emcc a.c
Expand Down
2 changes: 2 additions & 0 deletions ci/linux-s390x.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env sh

set -ex

mkdir -m 777 /qemu
Expand Down
2 changes: 2 additions & 0 deletions ci/linux-sparc64.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env sh

set -ex

mkdir -m 777 /qemu
Expand Down
31 changes: 18 additions & 13 deletions ci/run-docker.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
#!/usr/bin/env sh

# Small script to run tests for a target (or all targets) inside all the
# respective docker images.

set -ex

run() {
echo $1
echo "Building docker container for target ${1}"
# use -f so we can use ci/ as build context
docker build -t libc -f ci/docker/$1/Dockerfile ci/
docker build -t libc -f "ci/docker/${1}/Dockerfile" ci/
mkdir -p target
if [ -w /dev/kvm ]; then
kvm="--volume /dev/kvm:/dev/kvm"
kvm="--volume /dev/kvm:/dev/kvm"
else
kvm=""
fi

docker run \
--user `id -u`:`id -g` \
--user "$(id -u)":"$(id -g)" \
--rm \
--init \
--volume $HOME/.cargo:/cargo \
--volume "${HOME}/.cargo":/cargo \
$kvm \
--env CARGO_HOME=/cargo \
--volume `rustc --print sysroot`:/rust:ro \
--volume `pwd`:/checkout:ro \
--volume `pwd`/target:/checkout/target \
--volume "$(rustc --print sysroot)":/rust:ro \
--volume "$(pwd)":/checkout:ro \
--volume "$(pwd)"/target:/checkout/target \
--env CARGO_TARGET_DIR=/checkout/target \
--workdir /checkout \
libc \
ci/run.sh $1
ci/run.sh "${1}"
}

if [ -z "$1" ]; then
for d in `ls ci/docker/`; do
run $d
if [ -z "${1}" ]; then
for d in ci/docker/*; do
run "${d}"
done
else
run $1
run "${1}"
fi
12 changes: 7 additions & 5 deletions ci/run-qemu.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env sh

# Initial script which is run inside of all qemu images. The first argument to
# this script (as arranged by the qemu image itself) is the path to where the
# libc crate is mounted.
Expand All @@ -10,11 +12,11 @@

set -ex

ROOT=$1
cp -r $ROOT/libc /tmp/libc
ROOT="${1}"
cp -r "${ROOT}/libc" /tmp/libc
cd /tmp/libc

TARGET=$(cat $ROOT/TARGET)
TARGET="$(cat "${ROOT}/TARGET")"
export CARGO_TARGET_DIR=/tmp

case $TARGET in
Expand All @@ -24,9 +26,9 @@ case $TARGET in
;;

*)
echo "Unknown target: $TARGET"
echo "Unknown target: ${TARGET}"
exit 1
;;
esac

exec sh ci/run.sh $TARGET
exec sh ci/run.sh "${TARGET}"
Loading