Remove 2 suffix from gpui
Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
parent
3c81dda8e2
commit
f5ba22659b
225 changed files with 8511 additions and 41063 deletions
|
@ -1,13 +1,15 @@
|
|||
use std::{
|
||||
env,
|
||||
path::PathBuf,
|
||||
path::{Path, PathBuf},
|
||||
process::{self, Command},
|
||||
};
|
||||
|
||||
use cbindgen::Config;
|
||||
|
||||
fn main() {
|
||||
generate_dispatch_bindings();
|
||||
compile_metal_shaders();
|
||||
generate_shader_bindings();
|
||||
let header_path = generate_shader_bindings();
|
||||
compile_metal_shaders(&header_path);
|
||||
}
|
||||
|
||||
fn generate_dispatch_bindings() {
|
||||
|
@ -17,7 +19,12 @@ fn generate_dispatch_bindings() {
|
|||
let bindings = bindgen::Builder::default()
|
||||
.header("src/platform/mac/dispatch.h")
|
||||
.allowlist_var("_dispatch_main_q")
|
||||
.allowlist_var("DISPATCH_QUEUE_PRIORITY_DEFAULT")
|
||||
.allowlist_var("DISPATCH_TIME_NOW")
|
||||
.allowlist_function("dispatch_get_global_queue")
|
||||
.allowlist_function("dispatch_async_f")
|
||||
.allowlist_function("dispatch_after_f")
|
||||
.allowlist_function("dispatch_time")
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
||||
.layout_tests(false)
|
||||
.generate()
|
||||
|
@ -29,14 +36,61 @@ fn generate_dispatch_bindings() {
|
|||
.expect("couldn't write dispatch bindings");
|
||||
}
|
||||
|
||||
const SHADER_HEADER_PATH: &str = "./src/platform/mac/shaders/shaders.h";
|
||||
fn generate_shader_bindings() -> PathBuf {
|
||||
let output_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("scene.h");
|
||||
let crate_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||
let mut config = Config::default();
|
||||
config.include_guard = Some("SCENE_H".into());
|
||||
config.language = cbindgen::Language::C;
|
||||
config.export.include.extend([
|
||||
"Bounds".into(),
|
||||
"Corners".into(),
|
||||
"Edges".into(),
|
||||
"Size".into(),
|
||||
"Pixels".into(),
|
||||
"PointF".into(),
|
||||
"Hsla".into(),
|
||||
"ContentMask".into(),
|
||||
"Uniforms".into(),
|
||||
"AtlasTile".into(),
|
||||
"PathRasterizationInputIndex".into(),
|
||||
"PathVertex_ScaledPixels".into(),
|
||||
"ShadowInputIndex".into(),
|
||||
"Shadow".into(),
|
||||
"QuadInputIndex".into(),
|
||||
"Underline".into(),
|
||||
"UnderlineInputIndex".into(),
|
||||
"Quad".into(),
|
||||
"SpriteInputIndex".into(),
|
||||
"MonochromeSprite".into(),
|
||||
"PolychromeSprite".into(),
|
||||
"PathSprite".into(),
|
||||
"SurfaceInputIndex".into(),
|
||||
"SurfaceBounds".into(),
|
||||
]);
|
||||
config.no_includes = true;
|
||||
config.enumeration.prefix_with_name = true;
|
||||
cbindgen::Builder::new()
|
||||
.with_src(crate_dir.join("src/scene.rs"))
|
||||
.with_src(crate_dir.join("src/geometry.rs"))
|
||||
.with_src(crate_dir.join("src/color.rs"))
|
||||
.with_src(crate_dir.join("src/window.rs"))
|
||||
.with_src(crate_dir.join("src/platform.rs"))
|
||||
.with_src(crate_dir.join("src/platform/mac/metal_renderer.rs"))
|
||||
.with_config(config)
|
||||
.generate()
|
||||
.expect("Unable to generate bindings")
|
||||
.write_to_file(&output_path);
|
||||
|
||||
fn compile_metal_shaders() {
|
||||
let shader_path = "./src/platform/mac/shaders/shaders.metal";
|
||||
output_path
|
||||
}
|
||||
|
||||
fn compile_metal_shaders(header_path: &Path) {
|
||||
let shader_path = "./src/platform/mac/shaders.metal";
|
||||
let air_output_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("shaders.air");
|
||||
let metallib_output_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("shaders.metallib");
|
||||
|
||||
println!("cargo:rerun-if-changed={}", SHADER_HEADER_PATH);
|
||||
println!("cargo:rerun-if-changed={}", header_path.display());
|
||||
println!("cargo:rerun-if-changed={}", shader_path);
|
||||
|
||||
let output = Command::new("xcrun")
|
||||
|
@ -49,6 +103,8 @@ fn compile_metal_shaders() {
|
|||
"-MO",
|
||||
"-c",
|
||||
shader_path,
|
||||
"-include",
|
||||
&header_path.to_str().unwrap(),
|
||||
"-o",
|
||||
])
|
||||
.arg(&air_output_path)
|
||||
|
@ -79,18 +135,3 @@ fn compile_metal_shaders() {
|
|||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_shader_bindings() {
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header(SHADER_HEADER_PATH)
|
||||
.allowlist_type("GPUI.*")
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
||||
.layout_tests(false)
|
||||
.generate()
|
||||
.expect("unable to generate bindings");
|
||||
|
||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
bindings
|
||||
.write_to_file(out_path.join("shaders.rs"))
|
||||
.expect("couldn't write shader bindings");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue