From 5d4967ee9af8b2feeffd18534eef433066ad36c5 Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Thu, 23 Feb 2017 15:27:11 -0800 Subject: [PATCH 01/12] Add ppoll() --- CHANGELOG.md | 2 ++ src/poll.rs | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41c6f255c4..6e620c508e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ([#508](https://github.com/nix-rust/nix/pull/508)) - Fixed the style of many bitflags and use `libc` in more places. ([#503](https://github.com/nix-rust/nix/pull/503)) +- Added `ppoll` in `::nix::poll` + ([#520](https://github.com/nix-rust/nix/pull/520)) ### Changed - `epoll_ctl` now could accept None as argument `event` diff --git a/src/poll.rs b/src/poll.rs index 72988d8c3e..8a3de5f1da 100644 --- a/src/poll.rs +++ b/src/poll.rs @@ -1,3 +1,8 @@ +#[cfg(any(target_os = "linux", target_os = "android"))] +use sys::time::TimeSpec; +#[cfg(any(target_os = "linux", target_os = "android"))] +use sys::signal::SigSet; + use libc; use {Errno, Result}; @@ -47,3 +52,16 @@ pub fn poll(fds: &mut [PollFd], timeout: libc::c_int) -> Result { Errno::result(res) } + +#[cfg(any(target_os = "linux", target_os = "android"))] +pub fn ppoll(fds: &mut [PollFd], timeout: TimeSpec, sigmask: SigSet) -> Result { + + + let res = unsafe { + libc::ppoll(fds.as_mut_ptr() as *mut libc::pollfd, + fds.len() as libc::nfds_t, + timeout.as_ref(), + sigmask.as_ref()) + }; + Errno::result(res) +} From 6cdb225c24f1a88b2882e30ebdd16bf8d9d22660 Mon Sep 17 00:00:00 2001 From: Zac Berkowitz Date: Sat, 25 Feb 2017 02:16:30 +0000 Subject: [PATCH 02/12] Removed old ci infrastructure. --- .travis.yml | 102 ----------------------------------- ci/README.md | 48 ----------------- ci/cargo-config | 18 ------- ci/run-all.sh | 29 ---------- ci/run-docker.sh | 15 ------ ci/run-travis.sh | 41 -------------- ci/run.sh | 137 ----------------------------------------------- 7 files changed, 390 deletions(-) delete mode 100644 .travis.yml delete mode 100644 ci/README.md delete mode 100644 ci/cargo-config delete mode 100755 ci/run-all.sh delete mode 100755 ci/run-docker.sh delete mode 100644 ci/run-travis.sh delete mode 100755 ci/run.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e08e05e4f6..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,102 +0,0 @@ -# -# Operating Environment -# -language: rust -sudo: false -dist: trusty -services: - - docker -addons: - apt: - packages: - - gcc-multilib - - libcurl4-openssl-dev - - libelf-dev - - libdw-dev - - binutils-dev - -rust: - - 1.7.0 # Oldest supported version - - stable - - beta - - nightly - -# -# Environment Variables and Build Matrix -# -env: - global: - - PATH=$HOME/.local/bin:$PATH - - TRAVIS_CARGO_NIGHTLY_FEATURE="" - matrix: - - ARCH=x86_64 - - ARCH=i686 - -os: # OSX included in build matrix explicitly - - linux - -# Failures on nightly shouldn't fail the overall build. -matrix: - fast_finish: true - include: - # 32-bit and 64-bit OSX builds on oldest/stable - - os: osx - env: ARCH=x86_64 - rust: stable - - os: osx - env: ARCH=i686 - rust: stable - # Docker builds for other targets - - os: linux - env: TARGET=aarch64-unknown-linux-gnu DOCKER_IMAGE=posborne/rust-cross:arm - rust: 1.7.0 - sudo: true - - os: linux - env: TARGET=arm-unknown-linux-gnueabihf DOCKER_IMAGE=posborne/rust-cross:arm - rust: 1.7.0 - sudo: true - - os: linux - env: TARGET=mips-unknown-linux-gnu DOCKER_IMAGE=posborne/rust-cross:mips - rust: 1.7.0 - sudo: true - - os: linux - env: TARGET=mipsel-unknown-linux-gnu DOCKER_IMAGE=posborne/rust-cross:mips - rust: 1.7.0 - sudo: true - - os: linux - env: TARGET=arm-linux-androideabi DOCKER_IMAGE=posborne/rust-cross:android - rust: 1.7.0 - sudo: true - allow_failures: - - rust: nightly - # We need to upgrade the lowest supported version. However, the build - # infrastructure for arm/mips/android is not ready yet. - - rust: 1.7.0 - - env: TARGET=mips-unknown-linux-gnu DOCKER_IMAGE=posborne/rust-cross:mips - - env: TARGET=mipsel-unknown-linux-gnu DOCKER_IMAGE=posborne/rust-cross:mips - - env: TARGET=arm-linux-androideabi DOCKER_IMAGE=posborne/rust-cross:android - - -# -# Build/Test/Deploy Steps -# -before_script: - - pip install 'travis-cargo<0.2' --user - -script: - - bash ci/run-travis.sh - - | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then - travis-cargo --only stable doc - fi - -after_success: - - | - if [ "$TRAVIS_OS_NAME" = "linux" ] && \ - [ "$TRAVIS_RUST_VERSION" = "stable" ] && \ - [ "$ARCH" = "x86_64" ]; then - # Upload docs for stable (on master) to gh-pages - travis-cargo --only stable doc-upload - # Measure code coverage using kcov and upload to coveralls.io - travis-cargo coveralls --no-sudo --verify - fi diff --git a/ci/README.md b/ci/README.md deleted file mode 100644 index c86fd7157d..0000000000 --- a/ci/README.md +++ /dev/null @@ -1,48 +0,0 @@ -Test Infrastructure -=================== - -The ci directory contains scripts that aid in the testing of nix both -in our continuous integration environment (Travis CI) but also for -developers working locally. - -Nix interfaces very directly with the underlying platform (usually via -libc) and changes need to be tested on a large number of platforms to -avoid problems. - -Running Tests For Host Architecture ------------------------------------ - -Running the tests for one's host architecture can be done by simply -doing the following: - - $ cargo test - -Running Tests Against All Architectures/Versions ------------------------------------------------- - -Testing for other architectures is more involved. Currently, -developers may run tests against several architectures and versions of -rust by running the `ci/run-all.sh` script. This scripts requires -that docker be set up. This will take some time: - - $ ci/run-all.sh - -The list of versions and architectures tested by this can be -determined by looking at the contents of the script. The docker image -used is [posborne/rust-cross][posborne/rust-cross]. - -[posborne/rust-cross]: https://github.com/rust-embedded/docker-rust-cross - -Running Test for Specific Architectures/Versions ------------------------------------------------- - -Suppose we have a failing test with Rust 1.7 on the raspberry pi. In -that case, we can run the following: - - $ DOCKER_IMAGE=posborne/rust-cross:arm \ - RUST_VERSION=1.7.0 \ - RUST_TARGET=arm-unknown-linux-gnueabihf ci/run-docker.sh - -Currently, the docker images only support Rust 1.7. To get a better -idea of combinations that might work, look at the contents of the -[travis configuration](../.travis.yml) or [run-all.sh](run-all.sh). diff --git a/ci/cargo-config b/ci/cargo-config deleted file mode 100644 index 6fee5be7a8..0000000000 --- a/ci/cargo-config +++ /dev/null @@ -1,18 +0,0 @@ -# Configuration of which linkers to call on Travis for various architectures -[target.arm-linux-androideabi] -linker = "arm-linux-androideabi-gcc" - -[target.arm-unknown-linux-gnueabihf] -linker = "arm-linux-gnueabihf-gcc-4.7" - -[target.mips-unknown-linux-gnu] -linker = "mips-linux-gnu-gcc-5" - -[target.mipsel-unknown-linux-gnu] -linker = "mipsel-linux-gnu-gcc-5" - -[target.aarch64-unknown-linux-gnu] -linker = "aarch64-linux-gnu-gcc-4.8" - -[target.powerpc-unknown-linux-gnu] -linker = "powerpc-linux-gnu-gcc-4.8" diff --git a/ci/run-all.sh b/ci/run-all.sh deleted file mode 100755 index a7d1ece9ea..0000000000 --- a/ci/run-all.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# -# Build nix and all tests for as many versions and platforms as can be -# managed. This requires docker. -# - -set -e - -BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -RUN_DOCKER="${BASE_DIR}/ci/run-docker.sh" - -export RUST_VERSION=1.7.0 - -export DOCKER_IMAGE=posborne/rust-cross:x86 -RUST_TARGET=i686-unknown-linux-gnu ${RUN_DOCKER} -RUST_TARGET=x86_64-unknown-linux-gnu ${RUN_DOCKER} -RUST_TARGET=x86_64-unknown-linux-musl ${RUN_DOCKER} - -export DOCKER_IMAGE=posborne/rust-cross:arm -RUST_TARGET=aarch64-unknown-linux-gnu ${RUN_DOCKER} -RUST_TARGET=arm-linux-gnueabi ${RUN_DOCKER} -RUST_TARGET=arm-linux-gnueabihf ${RUN_DOCKER} - -export DOCKER_IMAGE=posborne/rust-cross:mips -RUST_TARGET=mips-unknown-linux-gnu ${RUN_DOCKER} -RUST_TARGET=mipsel-unknown-linux-gnu ${RUN_DOCKER} - -export DOCKER_IMAGE=posborne/rust-cross:android ${RUN_DOCKER} -RUST_TARGET=arm-linux-androideabi ${RUN_DOCKER} diff --git a/ci/run-docker.sh b/ci/run-docker.sh deleted file mode 100755 index 3ef831c32c..0000000000 --- a/ci/run-docker.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -# -# Run the nix tests in a docker container. This script expects the following -# environment variables to be set: -# - DOCKER_IMAGE : Docker image to use for testing (e.g. posborne/rust-cross:arm) -# - RUST_VERSION : Rust Version to test against (e.g. 1.7.0) -# - RUST_TARGET : Target Triple to test - -BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" - -docker run -i -t \ - -v ${BASE_DIR}:/source \ - -e CARGO_TARGET_DIR=/build \ - ${DOCKER_IMAGE} \ - /source/ci/run.sh ${RUST_VERSION} ${RUST_TARGET} diff --git a/ci/run-travis.sh b/ci/run-travis.sh deleted file mode 100644 index 5be6372e51..0000000000 --- a/ci/run-travis.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# -# Entry point for all travis builds, this will set up the Travis environment by -# downloading any dependencies. It will then execute the `run.sh` script to -# build and execute all tests. -# -# Much of this script was liberally stolen from rust-lang/libc -# -# Key variables that may be set from Travis: -# - TRAVIS_RUST_VERSION: 1.1.0 ... stable/nightly/beta -# - TRAVIS_OS_NAME: linux/osx -# - DOCKER_IMAGE: posborne/rust-cross:arm -# - TARGET: e.g. arm-unknown-linux-gnueabihf - -set -ex - -BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" - -if [ "$TRAVIS_OS_NAME" = "linux" ]; then - OS=unknown-linux-gnu -elif [ "$TRAVIS_OS_NAME" = "osx" ]; then - OS=apple-darwin -else - echo "Unexpected TRAVIS_OS_NAME: $TRAVIS_OS_NAME" - exit 1 -fi - -export HOST=$ARCH-$OS -if [ "$TARGET" = "" ]; then - TARGET=$HOST -fi - -if [ "$DOCKER_IMAGE" = "" ]; then - export RUST_TEST_THREADS=1 - curl -sSL "https://raw.githubusercontent.com/carllerche/travis-rust-matrix/master/test" | bash -else - export RUST_VERSION=${TRAVIS_RUST_VERSION} - export RUST_TARGET=${TARGET} - export DOCKER_IMAGE=${DOCKER_IMAGE} - ${BASE_DIR}/ci/run-docker.sh -fi diff --git a/ci/run.sh b/ci/run.sh deleted file mode 100755 index 770f5aa712..0000000000 --- a/ci/run.sh +++ /dev/null @@ -1,137 +0,0 @@ -#!/bin/bash - -# Builds and runs tests for a particular target passed as an argument to this -# script. - -set -e - -# This should only be run in a docker container, so verify that -if [ ! $(pidof $0) = "1" ]; then - echo "run.sh should only be executed in a docker container" - echo "and that does not appear to be the case. Maybe you meant" - echo "to execute the tests via run-all.sh or run-docker.sh." - echo "" - echo "For more instructions, please refer to ci/README.md" - exit 1 -fi - -BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -MANIFEST_PATH="${BASE_DIR}/Cargo.toml" -BUILD_DIR="." - -VERSION="$1" -TARGET="$2" - -export DOCKER_ENVIRONMENT=1 -export RUST_TEST_THREADS=1 -export RUST_BACKTRACE=1 - -# -# Tell cargo what linker to use and whatever else is required -# -configure_cargo() { - mkdir -p .cargo - cp -b "${BASE_DIR}/ci/cargo-config" .cargo/config -} - -# -# We need to export CC for the tests to build properly (some C code is -# compiled) to work. We already tell Cargo about the compiler in the -# cargo config, so we just parse that info out of the cargo config -# -cc_for_target() { - awk "/\[target\.${TARGET}\]/{getline; print}" .cargo/config | - cut -d '=' -f2 | \ - tr -d '"' | tr -d ' ' -} - -cross_compile_tests() { - case "$TARGET" in - *-apple-ios) - cargo test --no-run --manifest-path="${MANIFEST_PATH}" --target "$TARGET" -- \ - -C link-args=-mios-simulator-version-min=7.0 - ;; - - *) - cargo test --no-run --verbose \ - --manifest-path="${MANIFEST_PATH}" \ - --target "$TARGET" - ;; - esac -} - -# This is a hack as we cannot currently -# ask cargo what test files it generated: -# https://github.com/rust-lang/cargo/issues/1924 -find_binaries() { - target_base_dir="${BUILD_DIR}/${TARGET}/debug" - - # find [[test]] sections and print the first line and - # hack it to what we want from there. Also "nix" for - # tests that are implicitly prsent - for test_base in $( awk '/\[\[test\]\]/{getline; print}' "${MANIFEST_PATH}" | \ - cut -d '=' -f2 | \ - tr -d '"' | \ - tr '-' '_' | \ - tr -d ' '; echo "nix" ); do - for path in ${target_base_dir}/${test_base}-* ; do - echo "${path} " - done - done -} - -test_binary() { - binary=$1 - - case "$TARGET" in - arm-linux-gnueabi-gcc) - qemu-arm -L /usr/arm-linux-gnueabihf "$binary" - ;; - - arm-unknown-linux-gnueabihf) - qemu-arm -L /usr/arm-linux-gnueabihf "$binary" - ;; - - mips-unknown-linux-gnu) - qemu-mips -L /usr/mips-linux-gnu "$binary" - ;; - - aarch64-unknown-linux-gnu) - qemu-aarch64 -L /usr/aarch64-linux-gnu "$binary" - ;; - - *-rumprun-netbsd) - rumprun-bake hw_virtio /tmp/nix-test.img "${binary}" - qemu-system-x86_64 -nographic -vga none -m 64 \ - -kernel /tmp/nix-test.img 2>&1 | tee /tmp/out & - sleep 5 - grep "^PASSED .* tests" /tmp/out - ;; - - *) - echo "Running binary: ${binary}" - ${binary} - ;; - esac -} - -echo "=======================================================" -echo "TESTING VERSION: ${VERSION}, TARGET: ${TARGET}" -echo "=======================================================" - -configure_cargo -export CC="$(cc_for_target)" -if [ "${CC}" = "" ]; then - unset CC -fi - -# select the proper version -multirust override ${VERSION} - -# build the tests -cross_compile_tests - -# and run the tests -for bin in $(find_binaries); do - test_binary "${bin}" -done From a62874f51329bfdec3071be2fa7945de8792274d Mon Sep 17 00:00:00 2001 From: Zac Berkowitz Date: Sat, 25 Feb 2017 02:21:41 +0000 Subject: [PATCH 03/12] Added ci templates from `trust` v0.1.1 --- .travis.yml | 103 +++++++++++++++++++++++++++++++++++++++++++ appveyor.yml | 93 ++++++++++++++++++++++++++++++++++++++ ci/before_deploy.ps1 | 23 ++++++++++ ci/before_deploy.sh | 33 ++++++++++++++ ci/install.sh | 24 ++++++++++ ci/script.sh | 24 ++++++++++ 6 files changed, 300 insertions(+) create mode 100644 .travis.yml create mode 100644 appveyor.yml create mode 100644 ci/before_deploy.ps1 create mode 100644 ci/before_deploy.sh create mode 100644 ci/install.sh create mode 100644 ci/script.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..cf1fa42932 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,103 @@ +# Based on the "trust" template v0.1.1 +# https://github.com/japaric/trust/tree/v0.1.1 + +dist: trusty +language: rust +services: docker +sudo: required + +# TODO This is the Rust channel that build jobs will use by default but can be +# overridden on a case by case basis down below +rust: stable + +env: + global: + # TODO Update this to match the name of your project. + - CRATE_NAME=trust + + # default job + - TARGET=x86_64-unknown-linux-gnu + +matrix: + # TODO These are all the build jobs. Adjust as necessary. Comment out what you + # don't need + include: + # Linux + - env: TARGET=i686-unknown-linux-gnu + - env: TARGET=i686-unknown-linux-musl + # - env: TARGET=x86_64-unknown-linux-gnu # this is the default job + - env: TARGET=x86_64-unknown-linux-musl + + # OSX + - env: TARGET=i686-apple-darwin + os: osx + - env: TARGET=x86_64-apple-darwin + os: osx + + # *BSD + - env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1 + - env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1 + - env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1 + + # Other architectures + - env: TARGET=aarch64-unknown-linux-gnu + - env: TARGET=armv7-unknown-linux-gnueabihf + - env: TARGET=mips-unknown-linux-gnu + - env: TARGET=mips64-unknown-linux-gnuabi64 + - env: TARGET=mips64el-unknown-linux-gnuabi64 + - env: TARGET=mipsel-unknown-linux-gnu + - env: TARGET=powerpc-unknown-linux-gnu + - env: TARGET=powerpc64-unknown-linux-gnu + - env: TARGET=powerpc64le-unknown-linux-gnu + - env: TARGET=s390x-unknown-linux-gnu DISABLE_TESTS=1 + + # Testing other channels + - env: TARGET=x86_64-unknown-linux-gnu + rust: nightly + - env: TARGET=x86_64-apple-darwin + os: osx + rust: nightly + +install: + - sh ci/install.sh + - source ~/.cargo/env || true + +script: + - bash ci/script.sh + +before_deploy: + - sh ci/before_deploy.sh + +deploy: + # TODO update `api_key.secure` + # - Create a `public_repo` GitHub token. Go to: https://github.com/settings/tokens/new + # - Encrypt it: `travis encrypt GH_TOKEN=0123456789012345678901234567890123456789` + # - Paste the output down here + api_key: + secure: A9v3PIzQQ4U08OHFmDPQzNXbNHEb7YHyLXCvMF+dXFuNSvhUNlmQYykxqUf3dvikhJL2/bsZ14umm7ni7fQh0tGwJ4+lPpNzYAcweGgNXnWvjTpY6ovuRbr3gs4/srkyxp/GBDmSW5L8wFN3hKCB+Lm0YnIPB9IA2afP8a30+8VTXT9nv7pNqGny4ilN41ycr4DZi3sQoXdbruy7ClN7gsWW/GUiudBccHVIjmTapOFKLwZHODaUl/1/RDWQzh+i+17e1ivXuJPktDSrqmHPTZ15OjklnHKd6t179ry6VkGRg4R/R/YukVIqGzeaXGWAwdAQ5gE8cjGZghJLVi2jkDBJ85z8MvT+zLZLyliiuhLc/X8y7mkE1n0FKFtXXzFVt0l7V1LaEKbIbiV6XX3jsir4qgkqWjPHBZqO5mkGNFS16Dmt30/ZtEPAzXiINFXbWuWrpQ/LZ4NSto8IMrRTcoyDbAga/KYxJiNIeVuCe1E9dbytDM7K0GLtxJTul/WnnSeI6r//EFyC4bxYjyHhCXaag4q14KM+ak4rB0QgxsYzyGuh2MqyCoVj8YJLjLdKnL/SV7W7LPD40xlxvI6VCYTVi2ILHwL6vCxpukXYteX0c5IAIWkISDKu6nNBEgmCHXXPSqYSrgE5g7/QoCQHI8++nR8iKe0s7TWxZRydby8= + file_glob: true + file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.* + on: + # TODO Here you can pick which targets will generate binary releases + # In this example, there are some targets that are tested using the stable + # and nightly channels. This condition makes sure there is only one release + # for such targets and that's generated using the stable channel + condition: $TRAVIS_RUST_VERSION = stable + tags: true + provider: releases + skip_cleanup: true + +cache: cargo +before_cache: + # Travis can't cache files that are not readable by "others" + - chmod -R a+r $HOME/.cargo + +branches: + only: + # release tags + - /^v\d+\.\d+\.\d+.*$/ + - master + +notifications: + email: + on_success: never diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000000..ca13308313 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,93 @@ +# Based on the "trust" template v0.1.1 +# https://github.com/japaric/trust/tree/v0.1.1 + +environment: + global: + # TODO This is the Rust channel that build jobs will use by default but can be + # overridden on a case by case basis down below + RUST_VERSION: stable + + # TODO Update this to match the name of your project. + CRATE_NAME: trust + + # TODO These are all the build jobs. Adjust as necessary. Comment out what you + # don't need + matrix: + # MinGW + - TARGET: i686-pc-windows-gnu + - TARGET: x86_64-pc-windows-gnu + + # MSVC + - TARGET: i686-pc-windows-msvc + - TARGET: x86_64-pc-windows-msvc + + # Testing other channels + - TARGET: x86_64-pc-windows-gnu + RUST_VERSION: nightly + - TARGET: x86_64-pc-windows-msvc + RUST_VERSION: nightly + +install: + - ps: >- + If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') { + $Env:PATH += ';C:\msys64\mingw64\bin' + } ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') { + $Env:PATH += ';C:\msys64\mingw32\bin' + } + - curl -sSf -o rustup-init.exe https://win.rustup.rs/ + - rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_VERSION% + - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin + - rustc -Vv + - cargo -V + +# TODO This is the "test phase", tweak it as you see fit +test_script: + # we don't run the "test phase" when doing deploys + - if [%APPVEYOR_REPO_TAG%]==[false] ( + cargo build --target %TARGET% && + cargo build --target %TARGET% --release && + cargo test --target %TARGET% && + cargo test --target %TARGET% --release && + cargo run --target %TARGET% && + cargo run --target %TARGET% --release + ) + +before_deploy: + # TODO Update this to build the artifacts that matter to you + - cargo rustc --target %TARGET% --release --bin hello -- -C lto + - ps: ci\before_deploy.ps1 + +deploy: + artifact: /.*\.zip/ + # TODO update `auth_token.secure` + # - Create a `public_repo` GitHub token. Go to: https://github.com/settings/tokens/new + # - Encrypt it. Go to https://ci.appveyor.com/tools/encrypt + # - Paste the output down here + auth_token: + secure: t3puM/2hOig26EHhAodcZBc61NywF7/PFEpimR6SwGaCiqS07KR5i7iAhSABmBp7 + description: '' + on: + # TODO Here you can pick which targets will generate binary releases + # In this example, there are some targets that are tested using the stable + # and nightly channels. This condition makes sure there is only one release + # for such targets and that's generated using the stable channel + RUST_VERSION: stable + appveyor_repo_tag: true + provider: GitHub + +cache: + - C:\Users\appveyor\.cargo\registry + - target + +branches: + only: + # Release tags + - /^v\d+\.\d+\.\d+.*$/ + - master + +notifications: + - provider: Email + on_build_success: false + +# disable automatic builds +build: false diff --git a/ci/before_deploy.ps1 b/ci/before_deploy.ps1 new file mode 100644 index 0000000000..191a30b88d --- /dev/null +++ b/ci/before_deploy.ps1 @@ -0,0 +1,23 @@ +# This script takes care of packaging the build artifacts that will go in the +# release zipfile + +$SRC_DIR = $PWD.Path +$STAGE = [System.Guid]::NewGuid().ToString() + +Set-Location $ENV:Temp +New-Item -Type Directory -Name $STAGE +Set-Location $STAGE + +$ZIP = "$SRC_DIR\$($Env:CRATE_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:TARGET).zip" + +# TODO Update this to package the right artifacts +Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\hello.exe" '.\' + +7z a "$ZIP" * + +Push-AppveyorArtifact "$ZIP" + +Remove-Item *.* -Force +Set-Location .. +Remove-Item $STAGE +Set-Location $SRC_DIR diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh new file mode 100644 index 0000000000..026dc2898d --- /dev/null +++ b/ci/before_deploy.sh @@ -0,0 +1,33 @@ +# This script takes care of building your crate and packaging it for release + +set -ex + +main() { + local src=$(pwd) \ + stage= + + case $TRAVIS_OS_NAME in + linux) + stage=$(mktemp -d) + ;; + osx) + stage=$(mktemp -d -t tmp) + ;; + esac + + test -f Cargo.lock || cargo generate-lockfile + + # TODO Update this to build the artifacts that matter to you + cross rustc --bin hello --target $TARGET --release -- -C lto + + # TODO Update this to package the right artifacts + cp target/$TARGET/release/hello $stage/ + + cd $stage + tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz * + cd $src + + rm -rf $stage +} + +main diff --git a/ci/install.sh b/ci/install.sh new file mode 100644 index 0000000000..4093c9b2d7 --- /dev/null +++ b/ci/install.sh @@ -0,0 +1,24 @@ +set -ex + +main() { + curl https://sh.rustup.rs -sSf | \ + sh -s -- -y --default-toolchain $TRAVIS_RUST_VERSION + + local target= + if [ $TRAVIS_OS_NAME = linux ]; then + target=x86_64-unknown-linux-gnu + else + target=x86_64-apple-darwin + fi + + # TODO At some point you'll probably want to use a newer release of `cross`, + # simply change the argument to `--tag`. + curl -LSfs https://japaric.github.io/trust/install.sh | \ + sh -s -- \ + --force \ + --git japaric/cross \ + --tag v0.1.4 \ + --target $target +} + +main diff --git a/ci/script.sh b/ci/script.sh new file mode 100644 index 0000000000..de1f77c5d4 --- /dev/null +++ b/ci/script.sh @@ -0,0 +1,24 @@ +# This script takes care of testing your crate + +set -ex + +# TODO This is the "test phase", tweak it as you see fit +main() { + cross build --target $TARGET + cross build --target $TARGET --release + + if [ -n $DISABLE_TESTS ]; then + return + fi + + cross test --target $TARGET + cross test --target $TARGET --release + + cross run --target $TARGET + cross run --target $TARGET --release +} + +# we don't run the "test phase" when doing deploys +if [ -z $TRAVIS_TAG ]; then + main +fi From 04b7bed304946f508190a30db1dc0432e1d59f79 Mon Sep 17 00:00:00 2001 From: Zac Berkowitz Date: Sat, 25 Feb 2017 02:26:20 +0000 Subject: [PATCH 04/12] Removed appveyor -- this is a unix only lib. --- appveyor.yml | 93 ---------------------------------------------------- 1 file changed, 93 deletions(-) delete mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index ca13308313..0000000000 --- a/appveyor.yml +++ /dev/null @@ -1,93 +0,0 @@ -# Based on the "trust" template v0.1.1 -# https://github.com/japaric/trust/tree/v0.1.1 - -environment: - global: - # TODO This is the Rust channel that build jobs will use by default but can be - # overridden on a case by case basis down below - RUST_VERSION: stable - - # TODO Update this to match the name of your project. - CRATE_NAME: trust - - # TODO These are all the build jobs. Adjust as necessary. Comment out what you - # don't need - matrix: - # MinGW - - TARGET: i686-pc-windows-gnu - - TARGET: x86_64-pc-windows-gnu - - # MSVC - - TARGET: i686-pc-windows-msvc - - TARGET: x86_64-pc-windows-msvc - - # Testing other channels - - TARGET: x86_64-pc-windows-gnu - RUST_VERSION: nightly - - TARGET: x86_64-pc-windows-msvc - RUST_VERSION: nightly - -install: - - ps: >- - If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') { - $Env:PATH += ';C:\msys64\mingw64\bin' - } ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') { - $Env:PATH += ';C:\msys64\mingw32\bin' - } - - curl -sSf -o rustup-init.exe https://win.rustup.rs/ - - rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_VERSION% - - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin - - rustc -Vv - - cargo -V - -# TODO This is the "test phase", tweak it as you see fit -test_script: - # we don't run the "test phase" when doing deploys - - if [%APPVEYOR_REPO_TAG%]==[false] ( - cargo build --target %TARGET% && - cargo build --target %TARGET% --release && - cargo test --target %TARGET% && - cargo test --target %TARGET% --release && - cargo run --target %TARGET% && - cargo run --target %TARGET% --release - ) - -before_deploy: - # TODO Update this to build the artifacts that matter to you - - cargo rustc --target %TARGET% --release --bin hello -- -C lto - - ps: ci\before_deploy.ps1 - -deploy: - artifact: /.*\.zip/ - # TODO update `auth_token.secure` - # - Create a `public_repo` GitHub token. Go to: https://github.com/settings/tokens/new - # - Encrypt it. Go to https://ci.appveyor.com/tools/encrypt - # - Paste the output down here - auth_token: - secure: t3puM/2hOig26EHhAodcZBc61NywF7/PFEpimR6SwGaCiqS07KR5i7iAhSABmBp7 - description: '' - on: - # TODO Here you can pick which targets will generate binary releases - # In this example, there are some targets that are tested using the stable - # and nightly channels. This condition makes sure there is only one release - # for such targets and that's generated using the stable channel - RUST_VERSION: stable - appveyor_repo_tag: true - provider: GitHub - -cache: - - C:\Users\appveyor\.cargo\registry - - target - -branches: - only: - # Release tags - - /^v\d+\.\d+\.\d+.*$/ - - master - -notifications: - - provider: Email - on_build_success: false - -# disable automatic builds -build: false From a75785a5275225c2404ab85399e3304fb6557a4f Mon Sep 17 00:00:00 2001 From: Zac Berkowitz Date: Sat, 25 Feb 2017 02:41:20 +0000 Subject: [PATCH 05/12] Updated .travis.yml --- .travis.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index cf1fa42932..87d36fd0be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,20 +6,19 @@ language: rust services: docker sudo: required -# TODO This is the Rust channel that build jobs will use by default but can be +# This is the Rust channel that build jobs will use by default but can be # overridden on a case by case basis down below rust: stable env: global: - # TODO Update this to match the name of your project. - - CRATE_NAME=trust + - CRATE_NAME=nix # default job - TARGET=x86_64-unknown-linux-gnu matrix: - # TODO These are all the build jobs. Adjust as necessary. Comment out what you + # These are all the build jobs. Adjust as necessary. Comment out what you # don't need include: # Linux @@ -44,12 +43,12 @@ matrix: - env: TARGET=armv7-unknown-linux-gnueabihf - env: TARGET=mips-unknown-linux-gnu - env: TARGET=mips64-unknown-linux-gnuabi64 - - env: TARGET=mips64el-unknown-linux-gnuabi64 - - env: TARGET=mipsel-unknown-linux-gnu + # - env: TARGET=mips64el-unknown-linux-gnuabi64 + # - env: TARGET=mipsel-unknown-linux-gnu - env: TARGET=powerpc-unknown-linux-gnu - env: TARGET=powerpc64-unknown-linux-gnu - - env: TARGET=powerpc64le-unknown-linux-gnu - - env: TARGET=s390x-unknown-linux-gnu DISABLE_TESTS=1 + # - env: TARGET=powerpc64le-unknown-linux-gnu + # - env: TARGET=s390x-unknown-linux-gnu DISABLE_TESTS=1 # Testing other channels - env: TARGET=x86_64-unknown-linux-gnu @@ -74,15 +73,17 @@ deploy: # - Encrypt it: `travis encrypt GH_TOKEN=0123456789012345678901234567890123456789` # - Paste the output down here api_key: - secure: A9v3PIzQQ4U08OHFmDPQzNXbNHEb7YHyLXCvMF+dXFuNSvhUNlmQYykxqUf3dvikhJL2/bsZ14umm7ni7fQh0tGwJ4+lPpNzYAcweGgNXnWvjTpY6ovuRbr3gs4/srkyxp/GBDmSW5L8wFN3hKCB+Lm0YnIPB9IA2afP8a30+8VTXT9nv7pNqGny4ilN41ycr4DZi3sQoXdbruy7ClN7gsWW/GUiudBccHVIjmTapOFKLwZHODaUl/1/RDWQzh+i+17e1ivXuJPktDSrqmHPTZ15OjklnHKd6t179ry6VkGRg4R/R/YukVIqGzeaXGWAwdAQ5gE8cjGZghJLVi2jkDBJ85z8MvT+zLZLyliiuhLc/X8y7mkE1n0FKFtXXzFVt0l7V1LaEKbIbiV6XX3jsir4qgkqWjPHBZqO5mkGNFS16Dmt30/ZtEPAzXiINFXbWuWrpQ/LZ4NSto8IMrRTcoyDbAga/KYxJiNIeVuCe1E9dbytDM7K0GLtxJTul/WnnSeI6r//EFyC4bxYjyHhCXaag4q14KM+ak4rB0QgxsYzyGuh2MqyCoVj8YJLjLdKnL/SV7W7LPD40xlxvI6VCYTVi2ILHwL6vCxpukXYteX0c5IAIWkISDKu6nNBEgmCHXXPSqYSrgE5g7/QoCQHI8++nR8iKe0s7TWxZRydby8= + secure: S1ktt0eqmfrEHnYPf4WO7mZtatz/FWfYWBp8nwdc0nd8H6UNZ9Dwy3tJpVe0N9rpB9vAFnkdw6R4jdkIcgxfory2F3F8k/mh8cWn0mkvh2N34YjHMYLnuVzOoFrWai7IcPfROpdlY0tGBlwNj5KMkeBnHUJzd2q4j/4j/tlrfmg= file_glob: true file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.* on: - # TODO Here you can pick which targets will generate binary releases + # Here you can pick which targets will generate binary releases # In this example, there are some targets that are tested using the stable # and nightly channels. This condition makes sure there is only one release # for such targets and that's generated using the stable channel - condition: $TRAVIS_RUST_VERSION = stable + # + # Here we make it so we never generate binary releases + condition: $DEPLOY = never tags: true provider: releases skip_cleanup: true From fe76e1a017b57cb49130e5ab8298e1104952f03a Mon Sep 17 00:00:00 2001 From: Zac Berkowitz Date: Sat, 25 Feb 2017 20:02:22 +0000 Subject: [PATCH 06/12] Enabled tests for BSD. Added mipsel & mips64el --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 87d36fd0be..1bfce8d1ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,21 +34,21 @@ matrix: os: osx # *BSD - - env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1 - - env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1 - - env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1 + - env: TARGET=i686-unknown-freebsd + - env: TARGET=x86_64-unknown-freebsd + - env: TARGET=x86_64-unknown-netbsd # Other architectures - env: TARGET=aarch64-unknown-linux-gnu - env: TARGET=armv7-unknown-linux-gnueabihf - env: TARGET=mips-unknown-linux-gnu - env: TARGET=mips64-unknown-linux-gnuabi64 - # - env: TARGET=mips64el-unknown-linux-gnuabi64 - # - env: TARGET=mipsel-unknown-linux-gnu + - env: TARGET=mips64el-unknown-linux-gnuabi64 + - env: TARGET=mipsel-unknown-linux-gnu - env: TARGET=powerpc-unknown-linux-gnu - env: TARGET=powerpc64-unknown-linux-gnu # - env: TARGET=powerpc64le-unknown-linux-gnu - # - env: TARGET=s390x-unknown-linux-gnu DISABLE_TESTS=1 + # - env: TARGET=s390x-unknown-linux-gnu # Testing other channels - env: TARGET=x86_64-unknown-linux-gnu From 939d9cc16a9ffc6bdfd4872339fd1cedb9b0e45e Mon Sep 17 00:00:00 2001 From: Zac Berkowitz Date: Sat, 25 Feb 2017 20:40:10 +0000 Subject: [PATCH 07/12] Added/removed CI arches. Added: - arm-unknown-linux-gnueabi - arm-unknown-linux-musleabi Removed: - powerpc64-unknown-linux-gnu (not suppported by nix) - mips64el-unknown-linux-gnu (not suppported by nix) - mipsel-unknown-linux-gnu (not suppported by nix) --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1bfce8d1ac..6b0afab542 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,9 +46,11 @@ matrix: - env: TARGET=mips64el-unknown-linux-gnuabi64 - env: TARGET=mipsel-unknown-linux-gnu - env: TARGET=powerpc-unknown-linux-gnu - - env: TARGET=powerpc64-unknown-linux-gnu + # - env: TARGET=powerpc64-unknown-linux-gnu # - env: TARGET=powerpc64le-unknown-linux-gnu # - env: TARGET=s390x-unknown-linux-gnu + - env: TARGET=arm-unknown-linux-gnueabi + - env: TARGET=arm-unknown-linux-musleabi # Testing other channels - env: TARGET=x86_64-unknown-linux-gnu From 922fa29d11b18a528a906199e51fb10c4f31d58f Mon Sep 17 00:00:00 2001 From: Zac Berkowitz Date: Sat, 25 Feb 2017 20:59:35 +0000 Subject: [PATCH 08/12] Removed arches. Removed: - mips64-unknown-linux-gnu - mips64el-unknown-linux-gnu - arm-unknown-linux-musleabi --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6b0afab542..8f780bdcf3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,15 +42,15 @@ matrix: - env: TARGET=aarch64-unknown-linux-gnu - env: TARGET=armv7-unknown-linux-gnueabihf - env: TARGET=mips-unknown-linux-gnu - - env: TARGET=mips64-unknown-linux-gnuabi64 - - env: TARGET=mips64el-unknown-linux-gnuabi64 + # - env: TARGET=mips64-unknown-linux-gnuabi64 + # - env: TARGET=mips64el-unknown-linux-gnuabi64 - env: TARGET=mipsel-unknown-linux-gnu - env: TARGET=powerpc-unknown-linux-gnu # - env: TARGET=powerpc64-unknown-linux-gnu # - env: TARGET=powerpc64le-unknown-linux-gnu # - env: TARGET=s390x-unknown-linux-gnu - env: TARGET=arm-unknown-linux-gnueabi - - env: TARGET=arm-unknown-linux-musleabi + # - env: TARGET=arm-unknown-linux-musleabi # Testing other channels - env: TARGET=x86_64-unknown-linux-gnu From 99509a5c7e6658cff4edfdd362fcf7a3c491c5a4 Mon Sep 17 00:00:00 2001 From: Zac Berkowitz Date: Sat, 25 Feb 2017 21:00:36 +0000 Subject: [PATCH 09/12] Fixed ci/script.sh to run tests when desired. --- ci/script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/script.sh b/ci/script.sh index de1f77c5d4..ddd7f9362a 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -7,7 +7,7 @@ main() { cross build --target $TARGET cross build --target $TARGET --release - if [ -n $DISABLE_TESTS ]; then + if [ ! -z $DISABLE_TESTS ]; then return fi From 95023879f5c0b1e21e6edb139639c5ebfacf4036 Mon Sep 17 00:00:00 2001 From: Zac Berkowitz Date: Sat, 25 Feb 2017 21:18:53 +0000 Subject: [PATCH 10/12] Removed 'cargo run' directives from ci script. --- ci/script.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ci/script.sh b/ci/script.sh index ddd7f9362a..260fb073ab 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -2,8 +2,8 @@ set -ex -# TODO This is the "test phase", tweak it as you see fit main() { + # Build debug and release targets cross build --target $TARGET cross build --target $TARGET --release @@ -11,11 +11,13 @@ main() { return fi + # Run tests on debug and release targets. cross test --target $TARGET cross test --target $TARGET --release - cross run --target $TARGET - cross run --target $TARGET --release + # nix is a library -- no run target + # cross run --target $TARGET + # cross run --target $TARGET --release } # we don't run the "test phase" when doing deploys From e177695898734d9f6ee8e9ac52ecd71a9204785f Mon Sep 17 00:00:00 2001 From: Zac Berkowitz Date: Sat, 25 Feb 2017 21:33:30 +0000 Subject: [PATCH 11/12] Disable tests on BSD targets. --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8f780bdcf3..53bc090e02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,9 +34,9 @@ matrix: os: osx # *BSD - - env: TARGET=i686-unknown-freebsd - - env: TARGET=x86_64-unknown-freebsd - - env: TARGET=x86_64-unknown-netbsd + - env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1 + - env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1 + - env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1 # Other architectures - env: TARGET=aarch64-unknown-linux-gnu From ad8230789c3d3a721a2da45bcc6e3d9bbc653596 Mon Sep 17 00:00:00 2001 From: Zac Berkowitz Date: Sun, 26 Feb 2017 15:48:49 +0000 Subject: [PATCH 12/12] Removed commented `cargo run` targets in CI --- ci/script.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ci/script.sh b/ci/script.sh index 260fb073ab..39c3aeec73 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -14,10 +14,6 @@ main() { # Run tests on debug and release targets. cross test --target $TARGET cross test --target $TARGET --release - - # nix is a library -- no run target - # cross run --target $TARGET - # cross run --target $TARGET --release } # we don't run the "test phase" when doing deploys