Skip to content

Commit 2655637

Browse files
committed
Auto merge of #3418 - phansch:add_travis_windows_build, r=<try>
Fix Travis Windows build Closes #3306
2 parents 36fb646 + c61e4e1 commit 2655637

File tree

5 files changed

+43
-20
lines changed

5 files changed

+43
-20
lines changed

.travis.yml

+11-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ os:
77
- osx
88
- windows
99

10+
cache:
11+
directories:
12+
- $HOME/.cargo/bin/rustup-toolchain-install-master
13+
1014
branches:
1115
# Don't build these branches
1216
except:
@@ -45,7 +49,7 @@ matrix:
4549
- os: linux
4650
env: BASE_TESTS=true
4751
- os: windows
48-
env: CARGO_INCREMENTAL=0 BASE_TESTS=true
52+
env: CARGO_INCREMENTAL=0 BASE_TESTS=true OS_WINDOWS=true
4953

5054
# Builds that are only executed when a PR is r+ed or a try build is started
5155
# We don't want to run these always because they go towards
@@ -81,9 +85,6 @@ matrix:
8185
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
8286
- env: INTEGRATION=chronotope/chrono
8387
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
8788
# prevent these jobs with default env vars
8889
exclude:
8990
- os: linux
@@ -94,7 +95,11 @@ script:
9495
- |
9596
rm rust-toolchain
9697
./setup-toolchain.sh
97-
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib
98+
if [ "$TRAVIS_OS_NAME" == "windows" ]; then
99+
export PATH=$PATH:$(rustc --print sysroot)/bin
100+
else
101+
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib
102+
fi
98103
- |
99104
if [ -z ${INTEGRATION} ]; then
100105
travis_wait 30 ./ci/base-tests.sh && sleep 5
@@ -104,7 +109,7 @@ script:
104109
105110
after_success: |
106111
#!/bin/bash
107-
if [ $(uname) == Linux ]; then
112+
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
108113
set -ex
109114
if [ -z ${INTEGRATION} ]; then
110115
./.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

setup-toolchain.sh

+7
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@
33

44
cd "$(dirname "$0")"
55

6+
cratesio_version=$(cargo search rustup-toolchain-install-master | grep -o "[0-9]\.[0-9]\.[0-9]")
7+
rtim_version=$(rustup-toolchain-install-master --version | grep -o "[0-9]\.[0-9]\.[0-9]")
8+
69
if ! command -v rustup-toolchain-install-master > /dev/null; then
710
cargo install rustup-toolchain-install-master --debug
11+
else
12+
if [ $rtim_version != $cratesio_version ]; then
13+
cargo install rustup-toolchain-install-master --debug --force
14+
fi
815
fi
916

1017
RUSTC_HASH=$(git ls-remote https://github.com/rust-lang/rust.git master | awk '{print $1}')

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)