Skip to content

Commit

Permalink
update Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
Timo de Kort authored and Timo-DK committed May 22, 2019
1 parent 5b6549f commit 3f385a5
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@ EXCLUDES:=
FEATURE_RUST:=
FEATURE_NATIVE:=

FFI_DIR:=ffi
BUILD_DIR:=build
CLEAN_FFI_DIR:=
CREATE_BUILD_DIR:=

ifeq (,$(TARGET))
CHECK_TARGET_FLAG=
else
CHECK_TARGET_FLAG=--target $(TARGET)
endif

ifeq ($(OS),Windows_NT)
CLEAN_FFI_DIR=del $(FFI_DIR)\*.* /Q /S
CREATE_BUILD_DIR=mkdir $(BUILD_DIR)

ifeq ($(TARGET),x86_64-pc-windows-gnu)
FEATURE_RUST=vulkan
FEATURE_NATIVE=gfx-backend-vulkan
Expand All @@ -18,6 +26,9 @@ ifeq ($(OS),Windows_NT)
FEATURE_NATIVE=gfx-backend-dx12
endif
else
CLEAN_FFI_DIR=rm $(FFI_DIR)/**
CREATE_BUILD_DIR=mkdir -p $(BUILD_DIR)

UNAME_S:=$(shell uname -s)
ifeq ($(UNAME_S),Linux)
FEATURE_RUST=vulkan
Expand Down Expand Up @@ -45,22 +56,22 @@ doc:

clear:
cargo clean
rm wgpu-bindings/wgpu.h wgpu-bindings/wgpu-remote.h
$(CLEAN_FFI_DIR)

lib-native: Cargo.lock wgpu-native/Cargo.toml $(wildcard wgpu-native/**/*.rs)
cargo build --manifest-path wgpu-native/Cargo.toml --features "local,$(FEATURE_NATIVE)"

lib-remote: Cargo.lock wgpu-remote/Cargo.toml $(wildcard wgpu-native/**/*.rs wgpu-remote/**/*.rs)
cargo build --manifest-path wgpu-remote/Cargo.toml --features $(FEATURE_RUST)

ffi/wgpu.h: wgpu-native/cbindgen.toml $(wildcard wgpu-native/src/**/*.rs)
rustup run nightly cbindgen wgpu-native >ffi/wgpu.h
ffi/wgpu.h: wgpu-native/cbindgen.toml $(wildcard wgpu-native/**/*.rs)
rustup run nightly cbindgen wgpu-native > $(FFI_DIR)/wgpu.h

ffi/wgpu-remote.h: wgpu-remote/cbindgen.toml $(wildcard wgpu-native/src/**/*.rs wgpu-remote/src/**/*.rs)
rustup run nightly cbindgen wgpu-remote >ffi/wgpu-remote.h
ffi/wgpu-remote.h: wgpu-remote/cbindgen.toml $(wildcard wgpu-native/**/*.rs wgpu-remote/**/*.rs)
rustup run nightly cbindgen wgpu-remote >$(FFI_DIR)/wgpu-remote.h

examples-native: lib-native ffi/wgpu.h examples/hello_triangle_c/main.c
cd examples/hello_triangle_c && mkdir -p build && cd build && cmake .. && make
examples-native: lib-native $(FFI_DIR)/wgpu.h examples/hello_triangle_c/main.c
cd examples/hello_triangle_c && $(CREATE_BUILD_DIR) && cd build && cmake .. && make

examples-remote: lib-remote ffi/wgpu-remote.h examples/hello_remote_c/main.c
cd examples/hello_remote_c && mkdir -p build && cd build && cmake .. && make
examples-remote: lib-remote $(FFI_DIR)/wgpu-remote.h examples/hello_remote_c/main.c
cd examples/hello_remote_c && $(CREATE_BUILD_DIR) && cd build && cmake .. && make

0 comments on commit 3f385a5

Please sign in to comment.