mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-22 23:41:01 +01:00
Generate remote header
This commit is contained in:
1 parent
bd0de53f8e
commit
ea18c8fa85
4 files changed
+63
-40
No files matched your search
@@ -53,7 +53,7 @@ lib-native: Cargo.lock wgpu-native/Cargo.toml $(wildcard wgpu-native/**/*.rs)
|
||||
lib-rust: Cargo.lock wgpu-rs/Cargo.toml $(wildcard wgpu-rs/**/*.rs)
|
||||
cargo build --manifest-path wgpu-rs/Cargo.toml --features $(FEATURE_RUST)
|
||||
|
||||
wgpu-bindings/wgpu.h: Cargo.lock wgpu-bindings/src/*.rs lib-native
|
||||
wgpu-bindings/*.h: Cargo.lock wgpu-bindings/src/*.rs lib-native
|
||||
cargo +nightly-2018-12-27 run --manifest-path wgpu-bindings/Cargo.toml
|
||||
|
||||
examples-native: lib-native wgpu-bindings/wgpu.h $(wildcard wgpu-native/**/*.c)
|
||||
|
||||
+41
-32
@@ -2,42 +2,51 @@ extern crate cbindgen;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
const HEADER: &str = "
|
||||
#ifdef WGPU_REMOTE
|
||||
typedef uint32_t WGPUId;
|
||||
#else
|
||||
typedef void *WGPUId;
|
||||
#endif
|
||||
";
|
||||
struct Binding<'a> {
|
||||
library: &'a str,
|
||||
features: &'a [&'a str],
|
||||
output: &'a str,
|
||||
}
|
||||
|
||||
const BINDINGS: [Binding; 2] = [
|
||||
Binding {
|
||||
library: "wgpu-native",
|
||||
features: &["local"],
|
||||
output: "wgpu.h",
|
||||
},
|
||||
Binding {
|
||||
library: "wgpu-remote",
|
||||
features: &[],
|
||||
output: "wgpu-remote.h",
|
||||
},
|
||||
];
|
||||
|
||||
fn main() {
|
||||
let crate_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
let source_dir = crate_dir.parent().unwrap().join("wgpu-native");
|
||||
let parent = crate_dir.parent().unwrap();
|
||||
|
||||
let config = cbindgen::Config {
|
||||
header: Some(String::from(HEADER.trim())),
|
||||
enumeration: cbindgen::EnumConfig {
|
||||
prefix_with_name: true,
|
||||
for bind in &BINDINGS {
|
||||
let config = cbindgen::Config {
|
||||
enumeration: cbindgen::EnumConfig {
|
||||
prefix_with_name: true,
|
||||
..Default::default()
|
||||
},
|
||||
export: cbindgen::ExportConfig {
|
||||
prefix: Some(String::from("WGPU")),
|
||||
..Default::default()
|
||||
},
|
||||
language: cbindgen::Language::C,
|
||||
..Default::default()
|
||||
},
|
||||
export: cbindgen::ExportConfig {
|
||||
prefix: Some(String::from("WGPU")),
|
||||
exclude: vec![
|
||||
// We manually define `Id` is within the header, so exclude it here
|
||||
String::from("Id"),
|
||||
],
|
||||
..Default::default()
|
||||
},
|
||||
language: cbindgen::Language::C,
|
||||
..Default::default()
|
||||
};
|
||||
};
|
||||
|
||||
cbindgen::Builder::new()
|
||||
.with_crate(source_dir)
|
||||
.with_config(config)
|
||||
.with_parse_expand(&["wgpu-native"])
|
||||
.with_parse_expand_features(&["local"])
|
||||
.generate()
|
||||
.unwrap()
|
||||
.write_to_file(crate_dir.join("wgpu.h"));
|
||||
println!("Generating {}...", bind.output);
|
||||
cbindgen::Builder::new()
|
||||
.with_crate(parent.join(bind.library))
|
||||
.with_config(config)
|
||||
.with_parse_expand(&[bind.library])
|
||||
.with_parse_expand_features(bind.features)
|
||||
.generate()
|
||||
.unwrap()
|
||||
.write_to_file(crate_dir.join(bind.output));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct WGPUClient WGPUClient;
|
||||
|
||||
WGPUDeviceId wgpu_adapter_create_device(const WGPUClient *client,
|
||||
WGPUAdapterId adapter_id,
|
||||
const WGPUDeviceDescriptor *desc);
|
||||
|
||||
WGPUAdapterId wgpu_instance_get_adapter(const WGPUClient *client,
|
||||
WGPUInstanceId instance_id,
|
||||
const WGPUAdapterDescriptor *desc);
|
||||
@@ -1,9 +1,3 @@
|
||||
#ifdef WGPU_REMOTE
|
||||
typedef uint32_t WGPUId;
|
||||
#else
|
||||
typedef void *WGPUId;
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@@ -138,7 +132,8 @@ typedef enum {
|
||||
WGPUTextureFormat_R8g8b8a8Unorm = 0,
|
||||
WGPUTextureFormat_R8g8b8a8Uint = 1,
|
||||
WGPUTextureFormat_B8g8r8a8Unorm = 2,
|
||||
WGPUTextureFormat_D32FloatS8Uint = 3,
|
||||
WGPUTextureFormat_D32Float = 3,
|
||||
WGPUTextureFormat_D32FloatS8Uint = 4,
|
||||
} WGPUTextureFormat;
|
||||
|
||||
typedef enum {
|
||||
@@ -155,8 +150,11 @@ typedef enum {
|
||||
WGPUVertexFormat_FloatR32G32B32 = 1,
|
||||
WGPUVertexFormat_FloatR32G32 = 2,
|
||||
WGPUVertexFormat_FloatR32 = 3,
|
||||
WGPUVertexFormat_IntR8G8B8A8 = 4,
|
||||
} WGPUVertexFormat;
|
||||
|
||||
typedef uint32_t WGPUId;
|
||||
|
||||
typedef WGPUId WGPUDeviceId;
|
||||
|
||||
typedef WGPUId WGPUAdapterId;
|
||||
@@ -632,6 +630,8 @@ WGPUSwapChainId wgpu_device_create_swap_chain(WGPUDeviceId device_id,
|
||||
|
||||
WGPUTextureId wgpu_device_create_texture(WGPUDeviceId device_id, const WGPUTextureDescriptor *desc);
|
||||
|
||||
void wgpu_device_destroy(WGPUBufferId device_id);
|
||||
|
||||
WGPUQueueId wgpu_device_get_queue(WGPUDeviceId device_id);
|
||||
|
||||
WGPUSurfaceId wgpu_instance_create_surface_from_macos_layer(WGPUInstanceId instance_id,
|
||||
|
||||
Reference in new issue
Block a user