Skip to content

Commit 48b50e8

Browse files
committed
Auto merge of #3418 - phansch:add_travis_windows_build, r=me,flip1995
Fix Travis Windows build Closes #3306
2 parents 36fb646 + ce2a7b0 commit 48b50e8

File tree

4 files changed

+32
-20
lines changed

4 files changed

+32
-20
lines changed

.travis.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ matrix:
4545
- os: linux
4646
env: BASE_TESTS=true
4747
- os: windows
48-
env: CARGO_INCREMENTAL=0 BASE_TESTS=true
48+
env: CARGO_INCREMENTAL=0 BASE_TESTS=true OS_WINDOWS=true
4949

5050
# Builds that are only executed when a PR is r+ed or a try build is started
5151
# We don't want to run these always because they go towards
@@ -81,9 +81,6 @@ matrix:
8181
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
8282
- env: INTEGRATION=chronotope/chrono
8383
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
84-
allow_failures:
85-
- os: windows
86-
env: CARGO_INCREMENTAL=0 BASE_TESTS=true
8784
# prevent these jobs with default env vars
8885
exclude:
8986
- os: linux
@@ -94,7 +91,11 @@ script:
9491
- |
9592
rm rust-toolchain
9693
./setup-toolchain.sh
97-
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib
94+
if [ "$TRAVIS_OS_NAME" == "windows" ]; then
95+
export PATH=$PATH:$(rustc --print sysroot)/bin
96+
else
97+
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib
98+
fi
9899
- |
99100
if [ -z ${INTEGRATION} ]; then
100101
travis_wait 30 ./ci/base-tests.sh && sleep 5
@@ -104,7 +105,7 @@ script:
104105
105106
after_success: |
106107
#!/bin/bash
107-
if [ $(uname) == Linux ]; then
108+
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
108109
set -ex
109110
if [ -z ${INTEGRATION} ]; then
110111
./.github/deploy.sh

ci/base-tests.sh

+9-6
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,20 @@ export CARGO_TARGET_DIR=`pwd`/target/
2727

2828
# Check running clippy-driver without cargo
2929
(
30-
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib
31-
3230
# Check sysroot handling
3331
sysroot=$(./target/debug/clippy-driver --print sysroot)
3432
test $sysroot = $(rustc --print sysroot)
3533

36-
sysroot=$(./target/debug/clippy-driver --sysroot /tmp --print sysroot)
37-
test $sysroot = /tmp
34+
if [ -z $OS_WINDOWS ]; then
35+
desired_sysroot=/tmp
36+
else
37+
desired_sysroot=C:/tmp
38+
fi
39+
sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
40+
test $sysroot = $desired_sysroot
3841

39-
sysroot=$(SYSROOT=/tmp ./target/debug/clippy-driver --print sysroot)
40-
test $sysroot = /tmp
42+
sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
43+
test $sysroot = $desired_sysroot
4144

4245
# Make sure this isn't set - clippy-driver should cope without it
4346
unset CARGO_MANIFEST_DIR

src/driver.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern crate rustc_plugin;
1212
use rustc_interface::interface;
1313
use rustc_tools_util::*;
1414

15-
use std::path::Path;
15+
use std::path::{Path, PathBuf};
1616
use std::process::{exit, Command};
1717

1818
mod lintlist;
@@ -270,12 +270,19 @@ pub fn main() {
270270
let sys_root_arg = arg_value(&orig_args, "--sysroot", |_| true);
271271
let have_sys_root_arg = sys_root_arg.is_some();
272272
let sys_root = sys_root_arg
273-
.map(std::string::ToString::to_string)
274-
.or_else(|| std::env::var("SYSROOT").ok())
273+
.map(PathBuf::from)
274+
.or_else(|| std::env::var("SYSROOT").ok().map(PathBuf::from))
275275
.or_else(|| {
276276
let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME"));
277277
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
278-
home.and_then(|home| toolchain.map(|toolchain| format!("{}/toolchains/{}", home, toolchain)))
278+
home.and_then(|home| {
279+
toolchain.map(|toolchain| {
280+
let mut path = PathBuf::from(home);
281+
path.push("toolchains");
282+
path.push(toolchain);
283+
path
284+
})
285+
})
279286
})
280287
.or_else(|| {
281288
Command::new("rustc")
@@ -284,9 +291,10 @@ pub fn main() {
284291
.output()
285292
.ok()
286293
.and_then(|out| String::from_utf8(out.stdout).ok())
287-
.map(|s| s.trim().to_owned())
294+
.map(|s| PathBuf::from(s.trim()))
288295
})
289-
.or_else(|| option_env!("SYSROOT").map(String::from))
296+
.or_else(|| option_env!("SYSROOT").map(PathBuf::from))
297+
.map(|pb| pb.to_string_lossy().to_string())
290298
.expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust");
291299

292300
// Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument.

tests/dogfood.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[test]
22
fn dogfood() {
3-
if option_env!("RUSTC_TEST_SUITE").is_some() {
3+
if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
44
return;
55
}
66
let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
@@ -30,7 +30,7 @@ fn dogfood() {
3030

3131
#[test]
3232
fn dogfood_tests() {
33-
if option_env!("RUSTC_TEST_SUITE").is_some() {
33+
if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
3434
return;
3535
}
3636
let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));

0 commit comments

Comments
 (0)