Skip to content

Commit

Permalink
Fix wgpu subproject initialization on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
chances committed Jun 29, 2024
1 parent 8c5deee commit 49f2b8c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ docs.json
__dummy.html
docs/

# Intermediate Artifacts
wgpu_bindings.i

# Code coverage
*.lst
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ endif
ifeq ($(findstring sh.exe,$(SHELL)),sh.exe)
UNIX := true
endif
# Else, assume a unix system
UNIX ?= true
ifeq ($(OS),Windows_NT)
UNIX ?= false
else
# Assume a unix system
UNIX ?= true
endif
ifeq ($(OS),Darwin)
CC := clang
SED := gsed
Expand Down
2 changes: 0 additions & 2 deletions source/wgpu/api.d
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,6 @@ alias RenderPassDescriptor = WGPURenderPassDescriptor;
/// See_Also: <a href="https://docs.rs/wgpu/0.10.2/wgpu/struct.RenderPipelineDescriptor.html">wgpu::RenderPipelineDescriptor</a>
alias RenderPipelineDescriptor = WGPURenderPipelineDescriptor;

//static assert(false, std.traits.fullyQualifiedName!WGPUAdapterType);

// Structures

/// Describes the multi-sampling state of a render pipeline.
Expand Down
39 changes: 23 additions & 16 deletions subprojects/wgpu.Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# See https://github.com/gfx-rs/wgpu-native/tree/v0.19.1.1
VERSION := v0.19.1.1
OS ?= $(shell uname -s)
ifeq ($(findstring cmd.exe,$(SHELL)),cmd.exe)
UNIX := false
endif
ifeq ($(findstring sh.exe,$(SHELL)),sh.exe)
UNIX := true
endif
# Else, assume a unix system
UNIX ?= true
ifeq ($(OS),Windows_NT)
UNIX ?= false
else
# Assume a unix system
UNIX ?= true
endif

ifeq ($(OS),Windows_NT)
ifndef UNIX
$(error Unsupported build envinronment. Use Developer PowerShell for Visual Studio)
endif
endif

# Detect current system's CPU architecture
ifeq ($(OS),Windows_NT)
Expand Down Expand Up @@ -52,13 +59,13 @@ CONFIG ?= debug
BINARY_ARCHIVE := https://github.com/gfx-rs/wgpu-native/releases/download/$(VERSION)/wgpu-$(RELEASE)-$(ARCH)-$(CONFIG).zip
$(info Using $(CONFIG) wgpu-native $(VERSION) from: $(BINARY_ARCHIVE))
ifeq ($(OS),Windows_NT)
ifeq ($(UNIX),true)
ARCHIVE_DIR := $(shell echo $(USERPROFILE)/AppData/Local/WebGPU)
ARCHIVE_ZIP := $(shell echo $(USERPROFILE)/AppData/Local/WebGPU/wgpu.zip)
else
ARCHIVE_DIR := $(shell echo %USERPROFILE%/AppData/Local/WebGPU)
ARCHIVE_ZIP := $(shell echo %USERPROFILE%/AppData/Local/WebGPU/wgpu.zip)
endif
ifeq ($(UNIX),true)
ARCHIVE_DIR := $(shell echo $(USERPROFILE)/AppData/Local/WebGPU)
ARCHIVE_ZIP := $(shell echo $(USERPROFILE)/AppData/Local/WebGPU/wgpu.zip)
else
ARCHIVE_DIR := $(shell echo %USERPROFILE%/AppData/Local/WebGPU)
ARCHIVE_ZIP := $(shell echo %USERPROFILE%/AppData/Local/WebGPU/wgpu.zip)
endif
else
ARCHIVE_ZIP := /tmp/wgpu.zip
endif
Expand All @@ -76,10 +83,10 @@ endif

wgpu/$(LIB_WGPU): $(ARCHIVE_ZIP)
@echo Unzipping WebGPU Native binaries...
ifeq ($(UNIX),true)
@mkdir -p wgpu
@unzip -q -o $(ARCHIVE_ZIP) -d wgpu
else
ifeq ($(OS),Windows_NT)
@if not exist wgpu mkdir wgpu
@tar -xf $(ARCHIVE_ZIP) -C wgpu
else
@mkdir -p wgpu
@unzip -q -o $(ARCHIVE_ZIP) -d wgpu
endif

0 comments on commit 49f2b8c

Please sign in to comment.