Enable debug assertions for all builds other than official releases (#30509)

* Run main and try jobs with debug assertions

* use single quotes in workflow expressions

* set force-debug-assertions in main.yml

* set force-debug-assertions as part of decision job

* fix typo in MachCommands.build

* fix more hardcoded profile names

* fix tidy

* split cargo_profile_option on windows

* Fix running servoshell and unit tests through a symlink

* rename steps to make them less confusing

* fix more hardcoded cargo profile options

* fix missing inputs in linux-wpt and mac-wpt

* make filename an inherent method of Resource

* rework release-with-debug-assertions profile to production profile

* rework resource logic to eliminate std_test_override

* set production flag in nightly release builds

* clean up servobuild.example and windows.yml

* oops forgot to check in embedder_traits/build.rs

* fix mach test-unit behaviour through symlink

* unit tests only need current_dir and ancestors

* fix macOS package smoketest breakage

* expect css/css-color/currentcolor-003 to crash under layout 2013

* fix more references to {force,release-with}-debug-assertions

* fix local build failures under --profile production
This commit is contained in:
Delan Azabani 2023-10-26 16:22:14 +08:00 committed by GitHub
parent 88234309b0
commit a3d2f0c586
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 342 additions and 188 deletions

View file

@ -15,6 +15,7 @@ crate-type = ["cdylib"]
path = "lib.rs"
[dependencies]
cfg-if = { workspace = true }
crossbeam-channel = { workspace = true }
euclid = { workspace = true }
glib = "0.9"

View file

@ -2,6 +2,24 @@
* 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/. */
fn main() {
gst_plugin_version_helper::get_info()
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");
}
gst_plugin_version_helper::get_info();
Ok(())
}

View file

@ -10,6 +10,7 @@ use std::path::PathBuf;
use std::sync::Mutex;
use std::{env, fs};
use cfg_if::cfg_if;
use servo::embedder_traits::resources::{self, Resource};
lazy_static::lazy_static! {
@ -51,18 +52,29 @@ fn resources_dir_path() -> PathBuf {
path.pop();
}
// Try ./resources in the current directory, then each of its ancestors.
let mut path = std::env::current_dir().unwrap();
loop {
path.push("resources");
if path.is_dir() {
*dir = Some(path);
return dir.clone().unwrap();
}
path.pop();
if !path.pop() {
cfg_if! {
if #[cfg(servo_production)] {
panic!("Can't find resources directory")
} else {
// Static assert that this is really a non-production build, rather
// than a failure of the build scripts production check.
const _: () = assert!(cfg!(servo_do_not_use_in_production));
// Try ./resources in the current directory, then each of its ancestors.
// Not to be used in production builds without considering the security implications!
let mut path = std::env::current_dir().unwrap();
loop {
path.push("resources");
if path.is_dir() {
*dir = Some(path);
return dir.clone().unwrap();
}
path.pop();
if !path.pop() {
panic!("Can't find resources directory")
}
}
}
}
}

View file

@ -2,9 +2,25 @@
* 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;
use vergen::EmitBuilder;
fn main() {
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");
}
#[cfg(windows)]
{
let mut res = winres::WindowsResource::new();
@ -36,4 +52,6 @@ fn main() {
// linker to locate them. See `man dyld` for more info.
#[cfg(target_os = "macos")]
println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path/lib/");
Ok(())
}

View file

@ -62,7 +62,6 @@ pub fn register_user_prefs(opts_matches: &Matches) {
#[cfg(test)]
fn test_parse_pref(arg: &str) {
servo::embedder_traits::resources::set_for_tests();
let mut opts = getopts::Options::new();
opts.optmulti("", "pref", "", "");
let args = vec!["servo".to_string(), "--pref".to_string(), arg.to_string()];

View file

@ -6,6 +6,7 @@ use std::path::PathBuf;
use std::sync::Mutex;
use std::{env, fs};
use cfg_if::cfg_if;
use servo::embedder_traits::resources::{self, Resource};
lazy_static::lazy_static! {
@ -47,18 +48,29 @@ fn resources_dir_path() -> PathBuf {
path.pop();
}
// Try ./resources in the current directory, then each of its ancestors.
let mut path = std::env::current_dir().unwrap();
loop {
path.push("resources");
if path.is_dir() {
*dir = Some(path);
return dir.clone().unwrap();
}
path.pop();
if !path.pop() {
cfg_if! {
if #[cfg(servo_production)] {
panic!("Can't find resources directory")
} else {
// Static assert that this is really a non-production build, rather
// than a failure of the build scripts production check.
const _: () = assert!(cfg!(servo_do_not_use_in_production));
// Try ./resources in the current directory, then each of its ancestors.
// Not to be used in production builds without considering the security implications!
let mut path = std::env::current_dir().unwrap();
loop {
path.push("resources");
if path.is_dir() {
*dir = Some(path);
return dir.clone().unwrap();
}
path.pop();
if !path.pop() {
panic!("Can't find resources directory")
}
}
}
}
}