mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
stylo: Add a build log mechanism.
MozReview-Commit-ID: 4Zo1EveUYkK Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
ae1a7cc7b8
commit
a1930fc554
3 changed files with 50 additions and 1 deletions
|
@ -34,7 +34,7 @@ heapsize = "0.3.0"
|
||||||
heapsize_derive = {version = "0.1", optional = true}
|
heapsize_derive = {version = "0.1", optional = true}
|
||||||
html5ever-atoms = {version = "0.2", optional = true}
|
html5ever-atoms = {version = "0.2", optional = true}
|
||||||
lazy_static = "0.2"
|
lazy_static = "0.2"
|
||||||
log = "0.3.5"
|
log = "0.3"
|
||||||
matches = "0.1"
|
matches = "0.1"
|
||||||
nsstring_vendor = {path = "gecko_bindings/nsstring_vendor", optional = true}
|
nsstring_vendor = {path = "gecko_bindings/nsstring_vendor", optional = true}
|
||||||
num-integer = "0.1.32"
|
num-integer = "0.1.32"
|
||||||
|
@ -60,6 +60,7 @@ kernel32-sys = "0.2"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
lazy_static = "0.2"
|
lazy_static = "0.2"
|
||||||
|
log = "0.3"
|
||||||
bindgen = { version = "0.22", optional = true }
|
bindgen = { version = "0.22", optional = true }
|
||||||
regex = {version = "0.2", optional = true}
|
regex = {version = "0.2", optional = true}
|
||||||
walkdir = "1.0"
|
walkdir = "1.0"
|
||||||
|
|
|
@ -8,6 +8,8 @@ extern crate lazy_static;
|
||||||
#[cfg(feature = "bindgen")]
|
#[cfg(feature = "bindgen")]
|
||||||
extern crate bindgen;
|
extern crate bindgen;
|
||||||
#[cfg(feature = "bindgen")]
|
#[cfg(feature = "bindgen")]
|
||||||
|
extern crate log;
|
||||||
|
#[cfg(feature = "bindgen")]
|
||||||
extern crate regex;
|
extern crate regex;
|
||||||
extern crate walkdir;
|
extern crate walkdir;
|
||||||
|
|
||||||
|
|
|
@ -517,6 +517,49 @@ mod bindings {
|
||||||
write_binding_file(builder, structs_file(build_type), &fixups);
|
write_binding_file(builder, structs_file(build_type), &fixups);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn setup_logging() {
|
||||||
|
use log;
|
||||||
|
use std::fs;
|
||||||
|
|
||||||
|
struct BuildLogger {
|
||||||
|
file: Option<Mutex<fs::File>>,
|
||||||
|
filter: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl log::Log for BuildLogger {
|
||||||
|
fn enabled(&self, meta: &log::LogMetadata) -> bool {
|
||||||
|
self.file.is_some() && meta.target().contains(&self.filter)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn log(&self, record: &log::LogRecord) {
|
||||||
|
if !self.enabled(record.metadata()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut file = self.file.as_ref().unwrap().lock().unwrap();
|
||||||
|
let _ =
|
||||||
|
writeln!(file, "{} - {} - {} @ {}:{}",
|
||||||
|
record.level(),
|
||||||
|
record.target(),
|
||||||
|
record.args(),
|
||||||
|
record.location().file(),
|
||||||
|
record.location().line());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log::set_logger(|log_level| {
|
||||||
|
log_level.set(log::LogLevelFilter::Debug);
|
||||||
|
Box::new(BuildLogger {
|
||||||
|
file: env::var("STYLO_BUILD_LOG").ok().and_then(|path| {
|
||||||
|
fs::File::create(path).ok().map(Mutex::new)
|
||||||
|
}),
|
||||||
|
filter: env::var("STYLO_BUILD_FILTER").ok()
|
||||||
|
.unwrap_or_else(|| "bindgen".to_owned()),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.expect("Failed to set logger.");
|
||||||
|
}
|
||||||
|
|
||||||
pub fn generate_bindings() {
|
pub fn generate_bindings() {
|
||||||
let mut builder = Builder::get_initial_builder(BuildType::Release)
|
let mut builder = Builder::get_initial_builder(BuildType::Release)
|
||||||
.disable_name_namespacing()
|
.disable_name_namespacing()
|
||||||
|
@ -711,6 +754,8 @@ mod bindings {
|
||||||
static ref BINDINGS_PATH: PathBuf = Path::new(file!()).parent().unwrap().join("gecko_bindings");
|
static ref BINDINGS_PATH: PathBuf = Path::new(file!()).parent().unwrap().join("gecko_bindings");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn setup_logging() {}
|
||||||
|
|
||||||
pub fn generate_structs(build_type: BuildType) {
|
pub fn generate_structs(build_type: BuildType) {
|
||||||
let file = structs_file(build_type);
|
let file = structs_file(build_type);
|
||||||
let source = BINDINGS_PATH.join(file);
|
let source = BINDINGS_PATH.join(file);
|
||||||
|
@ -731,6 +776,7 @@ pub fn generate() {
|
||||||
use std::thread;
|
use std::thread;
|
||||||
println!("cargo:rerun-if-changed=build_gecko.rs");
|
println!("cargo:rerun-if-changed=build_gecko.rs");
|
||||||
fs::create_dir_all(&*OUTDIR_PATH).unwrap();
|
fs::create_dir_all(&*OUTDIR_PATH).unwrap();
|
||||||
|
bindings::setup_logging();
|
||||||
let threads = vec![
|
let threads = vec![
|
||||||
thread::spawn(|| bindings::generate_structs(BuildType::Debug)),
|
thread::spawn(|| bindings::generate_structs(BuildType::Debug)),
|
||||||
thread::spawn(|| bindings::generate_structs(BuildType::Release)),
|
thread::spawn(|| bindings::generate_structs(BuildType::Release)),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue