aboutsummaryrefslogtreecommitdiffstats
path: root/components/compositing/build.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-08-28 01:36:54 -0700
committerGitHub <noreply@github.com>2024-08-28 08:36:54 +0000
commita6b9640c99da121641dd63765835ab55aa1d378d (patch)
tree4a8c074744b85ed5049f41e3af80779edb64c172 /components/compositing/build.rs
parent5092cece7a7b2962fdc961183c00f5f146ed0b78 (diff)
downloadservo-a6b9640c99da121641dd63765835ab55aa1d378d.tar.gz
servo-a6b9640c99da121641dd63765835ab55aa1d378d.zip
compositor: Do not parse the Cargo.lock file while building (#33222)
The compositor's `build.rs` script was parsing the `Cargo.lock` file in order to tag WebRender captures with the WebRender version. The embedder already knows what version of Servo we are using, which should be enough to infer the WebRender revision. This changes does that and generally does a bit of cleaning up of how captures are done. - The name of the capture directory is now `webrender-captures` - There is console output now when captures are done. Before it was hard to know if it succeeded. - Simplify the Compositor constructor a little to avoid passing arguments so much. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/compositing/build.rs')
-rw-r--r--components/compositing/build.rs52
1 files changed, 0 insertions, 52 deletions
diff --git a/components/compositing/build.rs b/components/compositing/build.rs
deleted file mode 100644
index 828bf622fcb..00000000000
--- a/components/compositing/build.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-/* 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 https://mozilla.org/MPL/2.0/. */
-
-use std::env;
-use std::fs::File;
-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 mut lockfile = String::new();
- 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");
-
- 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()))
- .unwrap_or("unknown");
-
- let parsed: Vec<&str> = source.split('#').collect();
- let revision = if parsed.len() > 1 { parsed[1] } else { source };
-
- let mut revision_module_file = File::create(revision_file_path).unwrap();
- write!(&mut revision_module_file, "\"{}\"", revision).unwrap();
- },
- _ => panic!("Cannot find package definitions in lockfile"),
- }
- },
- Err(e) => panic!("{}", e),
- }
-}