Skip to content
Open
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ jobs:
!contains(github.event.pull_request.labels.*.name, 'no-fail-fast') }}
matrix:
config:
- os: macos-13
- os: macos-14
target: x86_64-apple-darwin
variant: debug
v8_enable_pointer_compression: false
cargo: cargo

- os: macos-13
- os: macos-14
target: x86_64-apple-darwin
variant: release
v8_enable_pointer_compression: false
cargo: cargo

- os: macos-13
- os: macos-14
target: x86_64-apple-darwin
variant: debug
v8_enable_pointer_compression: true
cargo: cargo

- os: macos-13
- os: macos-14
target: x86_64-apple-darwin
variant: release
v8_enable_pointer_compression: true
Expand Down Expand Up @@ -317,6 +317,11 @@ jobs:
pattern: src_binding_*.rs
merge-multiple: true

- name: Commit modified abseil options.h
run: |
git add third_party/abseil-cpp/absl/base/options.h
git commit -m "chore: commit modified abseil options.h"

- name: Publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
Expand Down
43 changes: 42 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,17 @@ fn build_v8(is_asan: bool) {
gn_args.push(r#"target_cpu="x86""#.to_string());
}

let repo_root = env::current_dir().unwrap();
let abseil_options_path = repo_root
.join("third_party")
.join("abseil-cpp")
.join("absl")
.join("base")
.join("options.h");

set_abseil_options_to_use_namespace(&abseil_options_path)
.expect("Failed to modify options.h");

let gn_out = run_gn_gen(&gn_args);
assert!(gn_out.exists());
assert!(gn_out.join("args.gn").exists());
Expand Down Expand Up @@ -451,7 +462,7 @@ fn static_lib_url() -> String {
if let Ok(custom_archive) = env::var("RUSTY_V8_ARCHIVE") {
return custom_archive;
}
let default_base = "https://github.com/denoland/rusty_v8/releases/download";
let default_base = "https://github.com/coasys/rusty_v8/releases/download";
let base =
env::var("RUSTY_V8_MIRROR").unwrap_or_else(|_| default_base.into());
let version = env::var("CARGO_PKG_VERSION").unwrap();
Expand Down Expand Up @@ -1079,6 +1090,36 @@ fn env_bool(key: &str) -> bool {
)
}

fn set_abseil_options_to_use_namespace(
options_path: &PathBuf,
) -> io::Result<()> {
// Read the contents of options.h
let current_content = fs::read_to_string(options_path)?;

// Create the expected content
let new_content = current_content
.lines()
.map(|line| {
if line.contains("#define ABSL_OPTION_USE_INLINE_NAMESPACE") {
"#define ABSL_OPTION_USE_INLINE_NAMESPACE 1".to_string()
} else if line.contains("#define ABSL_OPTION_INLINE_NAMESPACE_NAME") {
"#define ABSL_OPTION_INLINE_NAMESPACE_NAME v8".to_string()
} else {
line.to_string()
}
})
.collect::<Vec<String>>()
.join("\n");

// Only write if content actually changed
if current_content != new_content {
let mut file = fs::File::create(options_path)?;
file.write_all(new_content.as_bytes())?;
}

Ok(())
}

#[cfg(test)]
mod test {
use super::*;
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "1.86.0"
channel = "1.91.0"
components = ["rustfmt", "clippy"]
targets = [
"x86_64-apple-darwin",
Expand Down