mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 12:15:33 +00:00
2af5b6e579
Without this, build.py can't be found when servo is built as a dependency. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 34e0805b125ae77b9c05ff096c4bbc8d8ffd8bfc --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 4bd98e7af82ecd570e1248cc0119bfe980a48e13
92 lines
2.5 KiB
Rust
92 lines
2.5 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* 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/. */
|
|
|
|
#[macro_use]
|
|
extern crate lazy_static;
|
|
#[cfg(feature = "bindgen")]
|
|
extern crate bindgen;
|
|
#[cfg(feature = "bindgen")]
|
|
extern crate log;
|
|
#[cfg(feature = "bindgen")]
|
|
extern crate regex;
|
|
#[cfg(feature = "bindgen")]
|
|
extern crate toml;
|
|
extern crate walkdir;
|
|
|
|
use std::env;
|
|
use std::path::Path;
|
|
use std::process::{Command, exit};
|
|
use walkdir::WalkDir;
|
|
|
|
#[cfg(feature = "gecko")]
|
|
mod build_gecko;
|
|
|
|
#[cfg(not(feature = "gecko"))]
|
|
mod build_gecko {
|
|
pub fn generate() {}
|
|
}
|
|
|
|
#[cfg(windows)]
|
|
fn find_python() -> String {
|
|
if Command::new("python2.7.exe").arg("--version").output().is_ok() {
|
|
return "python2.7.exe".to_owned();
|
|
}
|
|
|
|
if Command::new("python27.exe").arg("--version").output().is_ok() {
|
|
return "python27.exe".to_owned();
|
|
}
|
|
|
|
if Command::new("python.exe").arg("--version").output().is_ok() {
|
|
return "python.exe".to_owned();
|
|
}
|
|
|
|
panic!(concat!("Can't find python (tried python2.7.exe, python27.exe, and python.exe)! ",
|
|
"Try fixing PATH or setting the PYTHON env var"));
|
|
}
|
|
|
|
#[cfg(not(windows))]
|
|
fn find_python() -> String {
|
|
if Command::new("python2.7").arg("--version").output().unwrap().status.success() {
|
|
"python2.7"
|
|
} else {
|
|
"python"
|
|
}.to_owned()
|
|
}
|
|
|
|
lazy_static! {
|
|
pub static ref PYTHON: String = env::var("PYTHON").ok().unwrap_or_else(find_python);
|
|
}
|
|
|
|
fn generate_properties() {
|
|
for entry in WalkDir::new("properties") {
|
|
let entry = entry.unwrap();
|
|
match entry.path().extension().and_then(|e| e.to_str()) {
|
|
Some("mako") | Some("rs") | Some("py") | Some("zip") => {
|
|
println!("cargo:rerun-if-changed={}", entry.path().display());
|
|
}
|
|
_ => {}
|
|
}
|
|
}
|
|
|
|
let script = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap())
|
|
.join("properties").join("build.py");
|
|
let product = if cfg!(feature = "gecko") { "gecko" } else { "servo" };
|
|
let status = Command::new(&*PYTHON)
|
|
.arg(&script)
|
|
.arg(product)
|
|
.arg("style-crate")
|
|
.status()
|
|
.unwrap();
|
|
if !status.success() {
|
|
exit(1)
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
println!("cargo:out_dir={}", env::var("OUT_DIR").unwrap());
|
|
generate_properties();
|
|
build_gecko::generate();
|
|
}
|