aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared/embedder/build.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2023-10-05 19:47:39 +0200
committerMartin Robinson <mrobinson@igalia.com>2023-11-03 15:38:18 +0000
commitf4d3af296c05260dfbb3deea4f8fa400cb6887d3 (patch)
tree169db2cc68e01a755b30500dd525f1a2ec2da861 /components/shared/embedder/build.rs
parent863529d9622c68f0a9535225237eb5e5c5b8c757 (diff)
downloadservo-f4d3af296c05260dfbb3deea4f8fa400cb6887d3.tar.gz
servo-f4d3af296c05260dfbb3deea4f8fa400cb6887d3.zip
Move `*_traits` and other shared types to `shared`
This is the start of the organization of types that are in their own crates in order to break dependency cycles between other crates. The idea here is that putting these packages into their own directory is the first step toward cleaning them up. They have grown organically and it is difficult to explain to new folks where to put new shared types. Many of these crates contain more than traits or don't contain traits at all. Notably, `script_traits` isn't touched because it is vendored from Gecko. Eventually this will move to `third_party`.
Diffstat (limited to 'components/shared/embedder/build.rs')
-rw-r--r--components/shared/embedder/build.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/components/shared/embedder/build.rs b/components/shared/embedder/build.rs
new file mode 100644
index 00000000000..25c737ffaa9
--- /dev/null
+++ b/components/shared/embedder/build.rs
@@ -0,0 +1,23 @@
+/* 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::error::Error;
+use std::path::Path;
+
+fn main() -> Result<(), Box<dyn Error>> {
+ // Cargo does not expose the profile name to crates or their build scripts,
+ // but we can extract it from OUT_DIR and set a custom cfg() ourselves.
+ let out = std::env::var("OUT_DIR")?;
+ let out = Path::new(&out);
+ let krate = out.parent().unwrap();
+ let build = krate.parent().unwrap();
+ let profile = build.parent().unwrap();
+ if profile.file_name().unwrap() == "production" {
+ println!("cargo:rustc-cfg=servo_production");
+ } else {
+ println!("cargo:rustc-cfg=servo_do_not_use_in_production");
+ }
+
+ Ok(())
+}