Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
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
41 changes: 41 additions & 0 deletions 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 @@ -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
Loading