mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Format component compositing #21373
This commit is contained in:
parent
1ee3deea27
commit
e4cd04399e
5 changed files with 363 additions and 255 deletions
|
@ -10,24 +10,33 @@ use std::io::{Read, Write};
|
|||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
let lockfile_path = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()).join("..").join("..").join("Cargo.lock");
|
||||
let revision_file_path = Path::new(&env::var_os("OUT_DIR").unwrap()).join("webrender_revision.rs");
|
||||
let lockfile_path = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap())
|
||||
.join("..")
|
||||
.join("..")
|
||||
.join("Cargo.lock");
|
||||
let revision_file_path =
|
||||
Path::new(&env::var_os("OUT_DIR").unwrap()).join("webrender_revision.rs");
|
||||
|
||||
let mut lockfile = String::new();
|
||||
File::open(lockfile_path).expect("Cannot open lockfile")
|
||||
File::open(lockfile_path)
|
||||
.expect("Cannot open lockfile")
|
||||
.read_to_string(&mut lockfile)
|
||||
.expect("Failed to read lockfile");
|
||||
|
||||
match toml::from_str::<toml::value::Table>(&lockfile) {
|
||||
Ok(result) => {
|
||||
let packages = result.get("package").expect("Cargo lockfile should contain package list");
|
||||
let packages = result
|
||||
.get("package")
|
||||
.expect("Cargo lockfile should contain package list");
|
||||
|
||||
match *packages {
|
||||
toml::Value::Array(ref arr) => {
|
||||
let source = arr
|
||||
.iter()
|
||||
.find(|pkg| pkg.get("name").and_then(|name| name.as_str()).unwrap_or("") == "webrender")
|
||||
.and_then(|pkg| pkg.get("source").and_then(|source| source.as_str()))
|
||||
.find(|pkg| {
|
||||
pkg.get("name").and_then(|name| name.as_str()).unwrap_or("") ==
|
||||
"webrender"
|
||||
}).and_then(|pkg| pkg.get("source").and_then(|source| source.as_str()))
|
||||
.unwrap_or("unknown");
|
||||
|
||||
let parsed: Vec<&str> = source.split("#").collect();
|
||||
|
@ -36,9 +45,9 @@ fn main() {
|
|||
let mut revision_module_file = File::create(&revision_file_path).unwrap();
|
||||
write!(&mut revision_module_file, "{}", format!("\"{}\"", revision)).unwrap();
|
||||
},
|
||||
_ => panic!("Cannot find package definitions in lockfile")
|
||||
_ => panic!("Cannot find package definitions in lockfile"),
|
||||
}
|
||||
},
|
||||
Err(e) => panic!(e)
|
||||
Err(e) => panic!(e),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue