mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-01-13 17:40:23 -05:00
Support for unconventional builds (#1209)
We may build rusty_v8 on platforms other than the common ones (for example, linux/riscv64), though they are not officially supported and prebuilt binaries are not available. This patch adds several environment variables: - `DISABLE_CLANG`: use `is_clang=false` and disables Clang-specific options for building with GCC, etc. - `EXTRA_GN_ARGS`: allow to pass extra GN arguments, such as custom toolchain - `NO_PRINT_GN_ARGS`: Disables printing GN arguments to stdout. GN currently segfaults on riscv64 when printing arguments. Since it is trivial, we can have an option to simply disable it. Also added fallback `arch` and `os` declaration in `platform()` to remove compile-time error.
This commit is contained in:
parent
07f2e9f3b6
commit
10861ab9f5
1 changed files with 24 additions and 3 deletions
27
build.rs
27
build.rs
|
@ -35,6 +35,9 @@ fn main() {
|
|||
"V8_FORCE_DEBUG",
|
||||
"V8_FROM_SOURCE",
|
||||
"PYTHON",
|
||||
"DISABLE_CLANG",
|
||||
"EXTRA_GN_ARGS",
|
||||
"NO_PRINT_GN_ARGS",
|
||||
];
|
||||
for env in envs {
|
||||
println!("cargo:rerun-if-env-changed={}", env);
|
||||
|
@ -127,7 +130,11 @@ fn build_v8() {
|
|||
gn_args.push("host_cpu=\"arm64\"".to_string())
|
||||
}
|
||||
|
||||
if let Some(clang_base_path) = find_compatible_system_clang() {
|
||||
if env::var_os("DISABLE_CLANG").is_some() {
|
||||
gn_args.push("is_clang=false".into());
|
||||
// -gline-tables-only is Clang-only
|
||||
gn_args.push("line_tables_only=false".into());
|
||||
} else if let Some(clang_base_path) = find_compatible_system_clang() {
|
||||
println!("clang_base_path {}", clang_base_path.display());
|
||||
gn_args.push(format!("clang_base_path={:?}", clang_base_path));
|
||||
gn_args.push("treat_warnings_as_errors=false".to_string());
|
||||
|
@ -210,7 +217,9 @@ fn build_v8() {
|
|||
let gn_out = maybe_gen(&gn_root, gn_args);
|
||||
assert!(gn_out.exists());
|
||||
assert!(gn_out.join("args.gn").exists());
|
||||
print_gn_args(&gn_out);
|
||||
if env::var_os("NO_PRINT_GN_ARGS").is_none() {
|
||||
print_gn_args(&gn_out);
|
||||
}
|
||||
build("rusty_v8", None);
|
||||
}
|
||||
|
||||
|
@ -257,11 +266,19 @@ fn platform() -> String {
|
|||
let os = "mac";
|
||||
#[cfg(target_os = "windows")]
|
||||
let os = "windows";
|
||||
#[cfg(not(any(
|
||||
target_os = "linux",
|
||||
target_os = "macos",
|
||||
target_os = "windows"
|
||||
)))]
|
||||
let arch = "unknown";
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
let arch = "amd64";
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
let arch = "arm64";
|
||||
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
|
||||
let arch = "unknown";
|
||||
|
||||
format!("{os}-{arch}")
|
||||
}
|
||||
|
@ -670,7 +687,11 @@ pub fn maybe_gen(manifest_dir: &str, gn_args: GnArgs) -> PathBuf {
|
|||
let gn_out_dir = dirs.out.join("gn_out");
|
||||
|
||||
if !gn_out_dir.exists() || !gn_out_dir.join("build.ninja").exists() {
|
||||
let args = gn_args.join(" ");
|
||||
let args = if let Ok(extra_args) = env::var("EXTRA_GN_ARGS") {
|
||||
format!("{} {}", gn_args.join(" "), extra_args)
|
||||
} else {
|
||||
gn_args.join(" ")
|
||||
};
|
||||
|
||||
let path = env::current_dir().unwrap();
|
||||
println!("The current directory is {}", path.display());
|
||||
|
|
Loading…
Reference in a new issue