Browse Source

Merge pull request #401 from ebarnard/windows-min-ci

Run the `Minimum Rust` CI job on Windows and fix it on Linux
urgh
Alex Crichton 6 years ago
committed by GitHub
parent
commit
5ed2aebf78
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      azure-pipelines.yml
  2. 3
      ci/azure-install-rust.yml
  3. 2
      src/lib.rs
  4. 16
      src/windows_registry.rs

20
azure-pipelines.yml

@ -2,12 +2,24 @@ trigger:
- master - master
jobs: jobs:
- job: min - job: min_linux
displayName: Minimum Rust pool:
vmImage: ubuntu-16.04
displayName: Minimum Rust (Linux)
variables:
TOOLCHAIN: 1.16.0
steps:
- template: ci/azure-install-rust.yml
- script: cargo build
- job: min_Windows
pool:
vmImage: vs2017-win2016
displayName: Minimum Rust (Windows)
variables:
TOOLCHAIN: 1.16.0
steps: steps:
- template: ci/azure-install-rust.yml - template: ci/azure-install-rust.yml
parameters:
toolchain: 1.16.0
- script: cargo build - script: cargo build
- job: Linux - job: Linux

3
ci/azure-install-rust.yml

@ -11,8 +11,9 @@ steps:
condition: ne( variables['Agent.OS'], 'Windows_NT' ) condition: ne( variables['Agent.OS'], 'Windows_NT' )
- script: | - script: |
IF "%TOOLCHAIN%"=="" (SET TOOLCHAIN=stable-%TARGET%)
curl -sSf -o rustup-init.exe https://win.rustup.rs curl -sSf -o rustup-init.exe https://win.rustup.rs
rustup-init.exe -y --default-toolchain stable-%TARGET% rustup-init.exe -y --default-toolchain %TOOLCHAIN%
echo ##vso[task.prependpath]%USERPROFILE%\.cargo\bin echo ##vso[task.prependpath]%USERPROFILE%\.cargo\bin
displayName: Install rust (windows) displayName: Install rust (windows)
condition: eq( variables['Agent.OS'], 'Windows_NT' ) condition: eq( variables['Agent.OS'], 'Windows_NT' )

2
src/lib.rs

@ -2401,7 +2401,7 @@ fn spawn(cmd: &mut Command, program: &str) -> Result<(Child, JoinHandle<()>), Er
} }
fn fail(s: &str) -> ! { fn fail(s: &str) -> ! {
eprintln!("\n\nerror occurred: {}\n\n", s); let _ = writeln!(io::stderr(), "\n\nerror occurred: {}\n\n", s);
std::process::exit(1); std::process::exit(1);
} }

16
src/windows_registry.rs

@ -225,10 +225,10 @@ mod impl_ {
return Box::new(iter::empty()); return Box::new(iter::empty());
}; };
Box::new(instances.filter_map(|instance| { Box::new(instances.filter_map(|instance| {
let instance = instance.ok()?; let instance = otry!(instance.ok());
let installation_name = instance.installation_name().ok()?; let installation_name = otry!(instance.installation_name().ok());
if installation_name.to_str()?.starts_with("VisualStudio/16.") { if otry!(installation_name.to_str()).starts_with("VisualStudio/16.") {
Some(PathBuf::from(instance.installation_path().ok()?)) Some(PathBuf::from(otry!(instance.installation_path().ok())))
} else { } else {
None None
} }
@ -236,7 +236,7 @@ mod impl_ {
} }
fn find_tool_in_vs16_path(tool: &str, target: &str) -> Option<Tool> { fn find_tool_in_vs16_path(tool: &str, target: &str) -> Option<Tool> {
vs16_instances().find_map(|path| { vs16_instances().filter_map(|path| {
let path = path.join(tool); let path = path.join(tool);
if !path.is_file() { if !path.is_file() {
return None; return None;
@ -246,7 +246,7 @@ mod impl_ {
tool.env.push(("Platform".into(), "X64".into())); tool.env.push(("Platform".into(), "X64".into()));
} }
Some(tool) Some(tool)
}) }).next()
} }
fn find_msbuild_vs16(target: &str) -> Option<Tool> { fn find_msbuild_vs16(target: &str) -> Option<Tool> {
@ -307,7 +307,7 @@ mod impl_ {
.ok() .ok()
.and_then(|key| key.query_str("15.0").ok()) .and_then(|key| key.query_str("15.0").ok())
.map(|path| PathBuf::from(path).join(tool)) .map(|path| PathBuf::from(path).join(tool))
.filter(|ref path| path.is_file()); .and_then(|path| if path.is_file() { Some(path) } else { None });
} }
path.map(|path| { path.map(|path| {
@ -681,7 +681,7 @@ mod impl_ {
for subkey in key.iter().filter_map(|k| k.ok()) { for subkey in key.iter().filter_map(|k| k.ok()) {
let val = subkey let val = subkey
.to_str() .to_str()
.and_then(|s| s.trim_start_matches("v").replace(".", "").parse().ok()); .and_then(|s| s.trim_left_matches("v").replace(".", "").parse().ok());
let val = match val { let val = match val {
Some(s) => s, Some(s) => s,
None => continue, None => continue,

Loading…
Cancel
Save