Auto merge of #3418 - phansch:add_travis_windows_build, r=me,flip1995

Fix Travis Windows build

Closes #3306
This commit is contained in:
bors 2019-07-15 05:20:34 +00:00
commit 48b50e80b1
4 changed files with 32 additions and 20 deletions

View File

@ -45,7 +45,7 @@ matrix:
- os: linux - os: linux
env: BASE_TESTS=true env: BASE_TESTS=true
- os: windows - os: windows
env: CARGO_INCREMENTAL=0 BASE_TESTS=true env: CARGO_INCREMENTAL=0 BASE_TESTS=true OS_WINDOWS=true
# Builds that are only executed when a PR is r+ed or a try build is started # Builds that are only executed when a PR is r+ed or a try build is started
# We don't want to run these always because they go towards # We don't want to run these always because they go towards
@ -81,9 +81,6 @@ matrix:
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
- env: INTEGRATION=chronotope/chrono - env: INTEGRATION=chronotope/chrono
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
allow_failures:
- os: windows
env: CARGO_INCREMENTAL=0 BASE_TESTS=true
# prevent these jobs with default env vars # prevent these jobs with default env vars
exclude: exclude:
- os: linux - os: linux
@ -94,7 +91,11 @@ script:
- | - |
rm rust-toolchain rm rust-toolchain
./setup-toolchain.sh ./setup-toolchain.sh
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib if [ "$TRAVIS_OS_NAME" == "windows" ]; then
export PATH=$PATH:$(rustc --print sysroot)/bin
else
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib
fi
- | - |
if [ -z ${INTEGRATION} ]; then if [ -z ${INTEGRATION} ]; then
travis_wait 30 ./ci/base-tests.sh && sleep 5 travis_wait 30 ./ci/base-tests.sh && sleep 5
@ -104,7 +105,7 @@ script:
after_success: | after_success: |
#!/bin/bash #!/bin/bash
if [ $(uname) == Linux ]; then if [ "$TRAVIS_OS_NAME" == "linux" ]; then
set -ex set -ex
if [ -z ${INTEGRATION} ]; then if [ -z ${INTEGRATION} ]; then
./.github/deploy.sh ./.github/deploy.sh

View File

@ -27,17 +27,20 @@ export CARGO_TARGET_DIR=`pwd`/target/
# Check running clippy-driver without cargo # Check running clippy-driver without cargo
( (
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib
# Check sysroot handling # Check sysroot handling
sysroot=$(./target/debug/clippy-driver --print sysroot) sysroot=$(./target/debug/clippy-driver --print sysroot)
test $sysroot = $(rustc --print sysroot) test $sysroot = $(rustc --print sysroot)
sysroot=$(./target/debug/clippy-driver --sysroot /tmp --print sysroot) if [ -z $OS_WINDOWS ]; then
test $sysroot = /tmp desired_sysroot=/tmp
else
desired_sysroot=C:/tmp
fi
sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
test $sysroot = $desired_sysroot
sysroot=$(SYSROOT=/tmp ./target/debug/clippy-driver --print sysroot) sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
test $sysroot = /tmp test $sysroot = $desired_sysroot
# Make sure this isn't set - clippy-driver should cope without it # Make sure this isn't set - clippy-driver should cope without it
unset CARGO_MANIFEST_DIR unset CARGO_MANIFEST_DIR

View File

@ -12,7 +12,7 @@ extern crate rustc_plugin;
use rustc_interface::interface; use rustc_interface::interface;
use rustc_tools_util::*; use rustc_tools_util::*;
use std::path::Path; use std::path::{Path, PathBuf};
use std::process::{exit, Command}; use std::process::{exit, Command};
mod lintlist; mod lintlist;
@ -270,12 +270,19 @@ pub fn main() {
let sys_root_arg = arg_value(&orig_args, "--sysroot", |_| true); let sys_root_arg = arg_value(&orig_args, "--sysroot", |_| true);
let have_sys_root_arg = sys_root_arg.is_some(); let have_sys_root_arg = sys_root_arg.is_some();
let sys_root = sys_root_arg let sys_root = sys_root_arg
.map(std::string::ToString::to_string) .map(PathBuf::from)
.or_else(|| std::env::var("SYSROOT").ok()) .or_else(|| std::env::var("SYSROOT").ok().map(PathBuf::from))
.or_else(|| { .or_else(|| {
let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME")); let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME"));
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN")); let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
home.and_then(|home| toolchain.map(|toolchain| format!("{}/toolchains/{}", home, toolchain))) home.and_then(|home| {
toolchain.map(|toolchain| {
let mut path = PathBuf::from(home);
path.push("toolchains");
path.push(toolchain);
path
})
})
}) })
.or_else(|| { .or_else(|| {
Command::new("rustc") Command::new("rustc")
@ -284,9 +291,10 @@ pub fn main() {
.output() .output()
.ok() .ok()
.and_then(|out| String::from_utf8(out.stdout).ok()) .and_then(|out| String::from_utf8(out.stdout).ok())
.map(|s| s.trim().to_owned()) .map(|s| PathBuf::from(s.trim()))
}) })
.or_else(|| option_env!("SYSROOT").map(String::from)) .or_else(|| option_env!("SYSROOT").map(PathBuf::from))
.map(|pb| pb.to_string_lossy().to_string())
.expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust"); .expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust");
// Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument. // Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument.

View File

@ -1,6 +1,6 @@
#[test] #[test]
fn dogfood() { fn dogfood() {
if option_env!("RUSTC_TEST_SUITE").is_some() { if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
return; return;
} }
let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
@ -30,7 +30,7 @@ fn dogfood() {
#[test] #[test]
fn dogfood_tests() { fn dogfood_tests() {
if option_env!("RUSTC_TEST_SUITE").is_some() { if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
return; return;
} }
let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));