Fix build scripts warnings.

This commit is contained in:
Simon Sapin 2015-03-18 21:53:48 +01:00
parent 1e858ecbc6
commit fef279a8f5
3 changed files with 22 additions and 33 deletions

View file

@ -2,17 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(io)] use std::process::Command;
use std::old_io::process::{Command, ProcessExit, StdioContainer};
fn main() { fn main() {
let result = Command::new("make") assert!(Command::new("make")
.args(&["-f", "makefile.cargo"]) .args(&["-f", "makefile.cargo"])
.stdout(StdioContainer::InheritFd(1))
.stderr(StdioContainer::InheritFd(2))
.status() .status()
.unwrap(); .unwrap()
assert_eq!(result, ProcessExit::ExitStatus(0)); .success());
} }

View file

@ -2,32 +2,33 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(env, old_io, old_path)] #![feature(io, path)]
use std::env; use std::env;
use std::old_path::Path; use std::fs::File;
use std::old_io::process::{Command, ProcessExit, StdioContainer}; use std::io::Write;
use std::old_io::File; use std::process::{Command, Stdio};
use std::path::Path;
fn main() { fn main() {
let python = if Command::new("python2.7").arg("--version").status() == Ok(ProcessExit::ExitStatus(0)) { let python = if Command::new("python2.7").arg("--version").status().unwrap().success() {
"python2.7" "python2.7"
} else { } else {
"python" "python"
}; };
let style = Path::new(file!()).dir_path(); let style = Path::new(file!()).parent().unwrap();
let mako = style.join("Mako-0.9.1.zip"); let mako = style.join("Mako-0.9.1.zip");
let template = style.join("properties.mako.rs"); let template = style.join("properties.mako.rs");
let result = Command::new(python) let result = Command::new(python)
.env("PYTHONPATH", mako.as_str().unwrap()) .env("PYTHONPATH", &mako)
.env("TEMPLATE", template.as_str().unwrap()) .env("TEMPLATE", &template)
.arg("-c") .arg("-c")
.arg("from os import environ; from mako.template import Template; print(Template(filename=environ['TEMPLATE']).render())") .arg("from os import environ; from mako.template import Template; print(Template(filename=environ['TEMPLATE']).render())")
.stderr(StdioContainer::InheritFd(2)) .stderr(Stdio::inherit())
.output() .output()
.unwrap(); .unwrap();
assert_eq!(result.status, ProcessExit::ExitStatus(0)); assert!(result.status.success());
let out = Path::new(env::var("OUT_DIR").unwrap()); let out = env::var("OUT_DIR").unwrap();
File::create(&out.join("properties.rs")).unwrap().write_all(&*result.output).unwrap(); File::create(&Path::new(&out).join("properties.rs")).unwrap().write_all(&result.stdout).unwrap();
} }

View file

@ -2,21 +2,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(env)] use std::process::Command;
#![feature(io)]
#![feature(old_io)]
use std::old_io::process::{Command, ProcessExit, StdioContainer};
use std::env; use std::env;
fn main() { fn main() {
let out_dir = env::var("OUT_DIR").unwrap(); assert!(Command::new("make")
let result = Command::new("make")
.args(&["-f", "makefile.cargo"]) .args(&["-f", "makefile.cargo"])
.stdout(StdioContainer::InheritFd(1))
.stderr(StdioContainer::InheritFd(2))
.status() .status()
.unwrap(); .unwrap()
assert_eq!(result, ProcessExit::ExitStatus(0)); .success());
println!("cargo:rustc-flags=-L native={}", out_dir); println!("cargo:rustc-flags=-L native={}", env::var("OUT_DIR").unwrap());
} }