Skip to content

Commit 95e4a6b

Browse files
wgpu.h: Don't require preprocessing to use.
Right now, `wgpu.h` can be included directly and it then includes `webgpu-headers/webgpu.h`. This is altered during creation of a distribution package to remove the `"webgpu-headers"`, but by adding `ffi/webgpu-headers` to the include search path, we can avoid having to preprocess the `wgpu.h`.
1 parent 67c2f15 commit 95e4a6b

File tree

9 files changed

+10
-6
lines changed

9 files changed

+10
-6
lines changed

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@ package: lib-native lib-native-release
5050
ARCHIVE=$(ARCHIVE_NAME)-$$RELEASE.zip; \
5151
LIBDIR=$(TARGET_DIR)/$$RELEASE; \
5252
rm -f dist/$$ARCHIVE; \
53-
sed 's/webgpu-headers\///' ffi/wgpu.h > wgpu.h ;\
5453
if [ $(OS_NAME) = windows ]; then \
55-
7z a -tzip dist/$$ARCHIVE ./$$LIBDIR/wgpu_native.dll ./$$LIBDIR/wgpu_native.dll.lib ./$$LIBDIR/wgpu_native.pdb ./$$LIBDIR/wgpu_native.lib ./ffi/webgpu-headers/*.h ./wgpu.h ./dist/commit-sha; \
54+
7z a -tzip dist/$$ARCHIVE ./$$LIBDIR/wgpu_native.dll ./$$LIBDIR/wgpu_native.dll.lib ./$$LIBDIR/wgpu_native.pdb ./$$LIBDIR/wgpu_native.lib ./ffi/webgpu-headers/*.h ./ffi/wgpu.h ./dist/commit-sha; \
5655
else \
57-
zip -j dist/$$ARCHIVE ./$$LIBDIR/libwgpu_native.so ./$$LIBDIR/libwgpu_native.dylib ./$$LIBDIR/libwgpu_native.a ./ffi/webgpu-headers/*.h ./wgpu.h ./dist/commit-sha; \
56+
zip -j dist/$$ARCHIVE ./$$LIBDIR/libwgpu_native.so ./$$LIBDIR/libwgpu_native.dylib ./$$LIBDIR/libwgpu_native.a ./ffi/webgpu-headers/*.h ./ffi/wgpu.h ./dist/commit-sha; \
5857
fi; \
59-
rm wgpu.h ;\
6058
done
6159

6260
clean:

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ fn main() {
4242
("WGPUTextureView", "WGPUTextureViewImpl"),
4343
];
4444
let mut builder = bindgen::Builder::default()
45-
.header("ffi/webgpu-headers/webgpu.h")
4645
.header("ffi/wgpu.h")
46+
.clang_arg("-Iffi/webgpu-headers")
4747
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
4848
.blocklist_function("wgpuGetProcAddress")
4949
.prepend_enum_name(false)

examples/capture/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ endif()
1212
add_definitions(-DSTB_IMAGE_WRITE_IMPLEMENTATION)
1313

1414
include_directories(${CMAKE_SOURCE_DIR}/../ffi)
15+
include_directories(${CMAKE_SOURCE_DIR}/../ffi/webgpu-headers)
1516
include_directories(${CMAKE_SOURCE_DIR}/framework)
1617

1718
if (WIN32)

examples/compute/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ else()
1010
endif()
1111

1212
include_directories(${CMAKE_SOURCE_DIR}/../ffi)
13+
include_directories(${CMAKE_SOURCE_DIR}/../ffi/webgpu-headers)
1314
include_directories(${CMAKE_SOURCE_DIR}/framework)
1415

1516
if (WIN32)

examples/enumerate_adapters/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ else()
1010
endif()
1111

1212
include_directories(${CMAKE_SOURCE_DIR}/../ffi)
13+
include_directories(${CMAKE_SOURCE_DIR}/../ffi/webgpu-headers)
1314
include_directories(${CMAKE_SOURCE_DIR}/framework)
1415

1516
if (WIN32)

examples/framework/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ else()
1010
endif()
1111

1212
include_directories(${CMAKE_SOURCE_DIR}/../ffi)
13+
include_directories(${CMAKE_SOURCE_DIR}/../ffi/webgpu-headers)
1314

1415
if (WIN32)
1516
set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32)

examples/texture_arrays/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ else()
1010
endif()
1111

1212
include_directories(${CMAKE_SOURCE_DIR}/../ffi)
13+
include_directories(${CMAKE_SOURCE_DIR}/../ffi/webgpu-headers)
1314
include_directories(${CMAKE_SOURCE_DIR}/framework)
1415

1516
if (WIN32)

examples/triangle/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ else()
1010
endif()
1111

1212
include_directories(${CMAKE_SOURCE_DIR}/../ffi)
13+
include_directories(${CMAKE_SOURCE_DIR}/../ffi/webgpu-headers)
1314
include_directories(${CMAKE_SOURCE_DIR}/framework)
1415

1516
if (WIN32)

ffi/wgpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef WGPU_H_
22
#define WGPU_H_
33

4-
#include "webgpu-headers/webgpu.h"
4+
#include "webgpu.h"
55

66
typedef enum WGPUNativeSType {
77
// Start at 0003 since that's allocated range for wgpu-native

0 commit comments

Comments
 (0)