This repository was archived by the owner on Apr 28, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
62 lines (54 loc) · 2.15 KB
/
Copy pathbuild.rs
File metadata and controls
62 lines (54 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Compile XCBBuildService proto files
tonic_prost_build::configure()
.build_server(true)
.build_client(false) // We only need the server side
.compile_protos(
&["proto/xcode/cas.proto", "proto/xcode/keyvalue.proto"],
&["proto/xcode"],
)?;
// Compile Bazel Remote Execution API proto files
// Use our custom google.rpc.Status to avoid path issues
tonic_prost_build::configure()
.build_server(true)
.build_client(false) // We only need the server side
.compile_well_known_types(true)
.extern_path(".google.protobuf", "::prost_types")
.extern_path(".google.rpc.Status", "crate::bazel::rpc_status::Status")
.compile_protos(
&[
"proto/bazel/remote_execution.proto",
"proto/google/bytestream/bytestream.proto",
],
&["proto"],
)?;
// Compile P2P proto files
tonic_prost_build::configure()
.build_server(true)
.build_client(true) // We need both server and client for P2P
.compile_protos(&["proto/p2p.proto"], &["proto"])?;
// Generate C header file using cbindgen
let crate_dir = std::env::var("CARGO_MANIFEST_DIR")?;
let output_file = std::path::Path::new(&crate_dir)
.join("include")
.join("fabrik.h");
// Create include directory if it doesn't exist
if let Some(parent) = output_file.parent() {
std::fs::create_dir_all(parent)?;
}
let cbindgen_config = std::path::Path::new(&crate_dir).join("cbindgen.toml");
cbindgen::Builder::new()
.with_crate(&crate_dir)
.with_config(cbindgen::Config::from_file(&cbindgen_config)?)
.generate()
.map_err(|e| format!("Unable to generate bindings: {:?}", e))?
.write_to_file(&output_file);
println!("cargo:rerun-if-changed=src/capi/mod.rs");
println!("cargo:rerun-if-changed=cbindgen.toml");
// Link AppKit framework on macOS (required for notify-rust)
#[cfg(target_os = "macos")]
{
println!("cargo:rustc-link-lib=framework=AppKit");
}
Ok(())
}