0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-24 15:19:31 -05:00

Fix build for android (#1246)

This commit is contained in:
cions 2023-07-02 02:21:12 +09:00 committed by GitHub
parent 1990a6dff5
commit ca83ce53ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,6 +23,7 @@ fn main() {
let envs = vec![ let envs = vec![
"CCACHE", "CCACHE",
"CLANG_BASE_PATH", "CLANG_BASE_PATH",
"CXXSTDLIB",
"DENO_TRYBUILD", "DENO_TRYBUILD",
"DOCS_RS", "DOCS_RS",
"GN", "GN",
@ -261,25 +262,23 @@ fn maybe_install_sysroot(arch: &str) {
} }
fn platform() -> String { fn platform() -> String {
#[cfg(target_os = "linux")] let os = if cfg!(target_os = "linux") {
let os = "linux"; "linux"
#[cfg(target_os = "macos")] } else if cfg!(target_os = "macos") {
let os = "mac"; "mac"
#[cfg(target_os = "windows")] } else if cfg!(target_os = "windows") {
let os = "windows"; "windows"
#[cfg(not(any( } else {
target_os = "linux", "unknown"
target_os = "macos", };
target_os = "windows"
)))]
let arch = "unknown";
#[cfg(target_arch = "x86_64")] let arch = if cfg!(target_arch = "x86_64") {
let arch = "amd64"; "amd64"
#[cfg(target_arch = "aarch64")] } else if cfg!(target_arch = "aarch64") {
let arch = "arm64"; "arm64"
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))] } else {
let arch = "unknown"; "unknown"
};
format!("{os}-{arch}") format!("{os}-{arch}")
} }
@ -481,16 +480,24 @@ fn print_link_flags() {
if should_dyn_link_libcxx { if should_dyn_link_libcxx {
// Based on https://github.com/alexcrichton/cc-rs/blob/fba7feded71ee4f63cfe885673ead6d7b4f2f454/src/lib.rs#L2462 // Based on https://github.com/alexcrichton/cc-rs/blob/fba7feded71ee4f63cfe885673ead6d7b4f2f454/src/lib.rs#L2462
let target = env::var("TARGET").unwrap(); if let Ok(stdlib) = env::var("CXXSTDLIB") {
if target.contains("apple") if !stdlib.is_empty() {
|| target.contains("freebsd") println!("cargo:rustc-link-lib=dylib={}", stdlib);
|| target.contains("openbsd") }
{ } else {
println!("cargo:rustc-link-lib=dylib=c++"); let target = env::var("TARGET").unwrap();
} else if target.contains("linux") { if target.contains("msvc") {
println!("cargo:rustc-link-lib=dylib=stdc++"); // nothing to link to
} else if target.contains("android") { } else if target.contains("apple")
println!("cargo:rustc-link-lib=dylib=c++_shared"); || target.contains("freebsd")
|| target.contains("openbsd")
{
println!("cargo:rustc-link-lib=dylib=c++");
} else if target.contains("android") {
println!("cargo:rustc-link-lib=dylib=c++_shared");
} else {
println!("cargo:rustc-link-lib=dylib=stdc++");
}
} }
} }
@ -544,10 +551,6 @@ fn is_compatible_clang_version(clang_path: &Path) -> bool {
} }
fn find_compatible_system_clang() -> Option<PathBuf> { fn find_compatible_system_clang() -> Option<PathBuf> {
if cfg!(target_os = "android") {
return None;
}
if let Ok(p) = env::var("CLANG_BASE_PATH") { if let Ok(p) = env::var("CLANG_BASE_PATH") {
let base_path = Path::new(&p); let base_path = Path::new(&p);
let clang_path = base_path.join("bin").join("clang"); let clang_path = base_path.join("bin").join("clang");
@ -686,6 +689,10 @@ fn ninja(gn_out_dir: &Path, maybe_env: Option<NinjaEnv>) -> Command {
let mut cmd = Command::new(cmd_string); let mut cmd = Command::new(cmd_string);
cmd.arg("-C"); cmd.arg("-C");
cmd.arg(gn_out_dir); cmd.arg(gn_out_dir);
if let Ok(jobs) = env::var("NUM_JOBS") {
cmd.arg("-j");
cmd.arg(jobs);
}
if let Some(env) = maybe_env { if let Some(env) = maybe_env {
for item in env { for item in env {
cmd.env(item.0, item.1); cmd.env(item.0, item.1);