wgpu/Makefile

86 lines
2.4 KiB
Makefile
Raw Normal View History

2018-10-22 14:46:13 +00:00
RUST_BACKTRACE:=1
EXCLUDES:=
FEATURE_RUST:=
FEATURE_NATIVE:=
2019-06-05 00:39:58 +00:00
GENERATOR_PLATFORM:=
2019-05-18 20:12:38 +00:00
FFI_DIR:=ffi
BUILD_DIR:=build
CLEAN_FFI_DIR:=
CREATE_BUILD_DIR:=
2019-07-28 16:42:17 +00:00
WILDCARD_WGPU_NATIVE:=$(wildcard wgpu-native/**/*.rs)
WILDCARD_WGPU_NATIVE_AND_REMOTE:=$(wildcard wgpu-native/**/*.rs wgpu-remote/**/*.rs)
2018-10-22 14:46:13 +00:00
ifeq (,$(TARGET))
CHECK_TARGET_FLAG=
else
CHECK_TARGET_FLAG=--target $(TARGET)
endif
ifeq ($(OS),Windows_NT)
2019-05-18 20:12:38 +00:00
CLEAN_FFI_DIR=del $(FFI_DIR)\*.* /Q /S
CREATE_BUILD_DIR=mkdir $(BUILD_DIR)
2019-06-05 00:39:58 +00:00
GENERATOR_PLATFORM=-DCMAKE_GENERATOR_PLATFORM=x64
2019-05-18 20:12:38 +00:00
2018-10-22 14:46:13 +00:00
ifeq ($(TARGET),x86_64-pc-windows-gnu)
FEATURE_RUST=vulkan
FEATURE_NATIVE=gfx-backend-vulkan
else
FEATURE_RUST=dx12
FEATURE_NATIVE=gfx-backend-dx12
endif
else
2019-05-18 20:12:38 +00:00
CLEAN_FFI_DIR=rm $(FFI_DIR)/**
CREATE_BUILD_DIR=mkdir -p $(BUILD_DIR)
2018-10-22 14:46:13 +00:00
UNAME_S:=$(shell uname -s)
ifeq ($(UNAME_S),Linux)
FEATURE_RUST=vulkan
FEATURE_NATIVE=gfx-backend-vulkan
endif
ifeq ($(UNAME_S),Darwin)
FEATURE_RUST=metal
FEATURE_NATIVE=gfx-backend-metal
endif
endif
.PHONY: all check test doc clear lib-native lib-remote examples-compute example-triangle example-remote
2018-10-22 14:46:13 +00:00
all: examples-compute example-triangle example-remote
2018-10-22 14:46:13 +00:00
check:
cargo check --all
test:
cargo test --all --features "$(FEATURE_NATIVE) $(FEATURE_RUST)"
doc:
cargo doc --all
clear:
cargo clean
2019-05-18 20:12:38 +00:00
$(CLEAN_FFI_DIR)
2018-10-22 14:46:13 +00:00
2019-07-28 16:42:17 +00:00
lib-native: Cargo.lock wgpu-native/Cargo.toml $(WILDCARD_WGPU_NATIVE)
2019-02-26 16:18:31 +00:00
cargo build --manifest-path wgpu-native/Cargo.toml --features "local,$(FEATURE_NATIVE)"
2018-10-22 14:46:13 +00:00
2019-07-28 16:42:17 +00:00
lib-remote: Cargo.lock wgpu-remote/Cargo.toml $(WILDCARD_WGPU_NATIVE_AND_REMOTE)
cargo build --manifest-path wgpu-remote/Cargo.toml --features $(FEATURE_RUST)
$(FFI_DIR)/wgpu.h: wgpu-native/cbindgen.toml $(WILDCARD_WGPU_NATIVE)
2019-05-18 20:12:38 +00:00
rustup run nightly cbindgen wgpu-native > $(FFI_DIR)/wgpu.h
$(FFI_DIR)/wgpu-remote.h: wgpu-remote/cbindgen.toml $(WILDCARD_WGPU_NATIVE_AND_REMOTE)
2019-07-24 19:22:00 +00:00
rustup run nightly cbindgen wgpu-remote > $(FFI_DIR)/wgpu-remote.h
2019-07-24 19:22:00 +00:00
example-compute: lib-native $(FFI_DIR)/wgpu.h examples/compute/main.c
cd examples/compute && $(CREATE_BUILD_DIR) && cd build && cmake .. -DBACKEND=$(FEATURE_RUST) $(GENERATOR_PLATFORM) && cmake --build .
2019-07-24 19:22:00 +00:00
example-triangle: lib-native $(FFI_DIR)/wgpu.h examples/triangle/main.c
cd examples/triangle && $(CREATE_BUILD_DIR) && cd build && cmake .. -DBACKEND=$(FEATURE_RUST) $(GENERATOR_PLATFORM) && cmake --build .
example-remote: lib-remote $(FFI_DIR)/wgpu-remote.h examples/remote/main.c
cd examples/remote && $(CREATE_BUILD_DIR) && cd build && cmake .. && cmake --build .