diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6374e32b4b..3cdfa4b638 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,35 +31,35 @@ jobs: variant: release cargo: cargo - - os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-18.04' }} + - os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-20.04' }} target: x86_64-unknown-linux-gnu variant: debug cargo: cargo - - os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-18.04' }} + - os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-20.04' }} target: x86_64-unknown-linux-gnu variant: release cargo: cargo - - os: windows-2019 - target: x86_64-pc-windows-msvc - variant: release # Note: we do not support windows debug builds. - cargo: cargo + # - os: windows-2019 + # target: x86_64-pc-windows-msvc + # variant: release # Note: we do not support windows debug builds. + # cargo: cargo - - os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-18.04' }} - target: aarch64-unknown-linux-gnu - variant: debug - cargo: cargo + # - os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-20.04' }} + # target: aarch64-unknown-linux-gnu + # variant: debug + # cargo: cargo - - os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-18.04' }} - target: aarch64-unknown-linux-gnu - variant: release - cargo: cargo + # - os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-20.04' }} + # target: aarch64-unknown-linux-gnu + # variant: release + # cargo: cargo - - os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-18.04' }} - target: aarch64-linux-android - variant: release # Note: v8 debug builds on QEMU is buggy. - cargo: cross + # - os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-20.04' }} + # target: aarch64-linux-android + # variant: release # Note: v8 debug builds on QEMU is buggy. + # cargo: cross env: V8_FROM_SOURCE: true @@ -182,7 +182,7 @@ jobs: env: SCCACHE_IDLE_TIMEOUT: 0 run: - ${{ matrix.config.cargo }} test -vv --all-targets --locked ${{ env.CARGO_VARIANT_FLAG }} + ${{ matrix.config.cargo }} test --no-default-features -vv --all-targets --locked ${{ env.CARGO_VARIANT_FLAG }} --target ${{ matrix.config.target }} - name: Clippy @@ -203,7 +203,7 @@ jobs: # https://github.com/softprops/action-gh-release/issues/139 uses: softprops/action-gh-release@59c3b4891632ff9a897f99a91d7bc557467a3a22 if: >- - github.repository == 'denoland/rusty_v8' && + github.repository == 'getditto/rusty_v8' && startsWith(github.ref, 'refs/tags/') env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Cargo.toml b/Cargo.toml index 4b5316bed2..ab4f047e39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,6 +75,10 @@ exclude = [ "!v8/tools/testrunner/utils/dump_build_config.py", ] +[features] +default = ["use_custom_libcxx"] +use_custom_libcxx = [] + [dependencies] lazy_static = "1.4.0" libc = "0.2.93" diff --git a/build.rs b/build.rs index 19bcf30e07..7cc1013e57 100644 --- a/build.rs +++ b/build.rs @@ -12,6 +12,7 @@ use which::which; fn main() { println!("cargo:rerun-if-changed=src/binding.cc"); + println!("cargo:rerun-if-changed=build.rs"); // These are all the environment variables that we check. This is // probably more than what is needed, but missing an important @@ -109,6 +110,10 @@ fn build_v8() { vec!["is_debug=false".to_string()] }; + if cfg!(not(feature = "use_custom_libcxx")) { + gn_args.push("use_custom_libcxx=false".to_string()); + } + if !is_debug() { gn_args.push("v8_enable_handle_zapping=false".to_string()); } @@ -398,6 +403,25 @@ fn download_static_lib_binaries() { fn print_link_flags() { println!("cargo:rustc-link-lib=static=rusty_v8"); + let should_dyn_link_libcxx = cfg!(not(feature = "use_custom_libcxx")) + || env::var("GN_ARGS").map_or(false, |gn_args| { + gn_args + .split_whitespace() + .any(|ba| ba == "use_custom_libcxx=false") + }); + + if should_dyn_link_libcxx { + let target = env::var("TARGET").unwrap(); + if target.contains("apple") + || target.contains("freebsd") + || target.contains("openbsd") + { + println!("cargo:rustc-link-lib=dylib=c++"); + } else if target.contains("linux") { + println!("cargo:rustc-link-lib=dylib=stdc++"); + } + } + if cfg!(target_os = "windows") { println!("cargo:rustc-link-lib=dylib=winmm"); println!("cargo:rustc-link-lib=dylib=dbghelp");