mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-14 19:06:35 +02:00
test-css-tokenizer is updated to run both the C++ and Rust tokenizers and compare their output, to ensure they behave identically. The Parser still uses the C++ Tokenizer. The LibWeb crate, FFI layer etc are all based on the existing ones for other libraries. This is a direct AI translation to get us started, and not idiomatic Rust. Future work can be done to make it more sensible.
41 lines
1.1 KiB
Rust
41 lines
1.1 KiB
Rust
/*
|
|
* Copyright (c) 2026-present, the Ladybird developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
use std::env;
|
|
use std::error::Error;
|
|
use std::path::PathBuf;
|
|
|
|
fn main() -> Result<(), Box<dyn Error>> {
|
|
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?);
|
|
let out_dir = PathBuf::from(env::var("OUT_DIR")?);
|
|
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
println!("cargo:rerun-if-changed=cbindgen.toml");
|
|
println!("cargo:rerun-if-env-changed=FFI_OUTPUT_DIR");
|
|
println!("cargo:rerun-if-changed=src");
|
|
|
|
let ffi_out_dir = env::var("FFI_OUTPUT_DIR")
|
|
.map(PathBuf::from)
|
|
.unwrap_or_else(|_| out_dir.clone());
|
|
|
|
cbindgen::generate(manifest_dir).map_or_else(
|
|
|error| match error {
|
|
cbindgen::Error::ParseSyntaxError { .. } => {}
|
|
other => panic!("{other:?}"),
|
|
},
|
|
|bindings| {
|
|
let header_path = out_dir.join("RustFFI.h");
|
|
bindings.write_to_file(&header_path);
|
|
|
|
if ffi_out_dir != out_dir {
|
|
bindings.write_to_file(ffi_out_dir.join("RustFFI.h"));
|
|
}
|
|
},
|
|
);
|
|
|
|
Ok(())
|
|
}
|