Skip to content

Commit

Permalink
Vendor the latest GLFW library
Browse files Browse the repository at this point in the history
  • Loading branch information
chances committed Jan 28, 2024
1 parent 7332fc2 commit 0928514
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 36 deletions.
12 changes: 0 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 3,6 @@ bin/
src/*.o
*.dwarf

# Vendored wgpu sources
vendor/wgpu-*/
vendor/wgpu-*.zip

# Example Artifacts
/examples/headless
/examples/headless.app
/examples/red.png
/examples/triangle
/examples/triangle.app
/examples/triangle.png

# Temporary Files
*~

Expand Down
27 changes: 16 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 31,33 @@ ${SUBMODULES} &:
# Wren
ifeq (${CONFIG},debug)
LIBS = wren_d
LIBWREN := wren/lib/libwren_d.a
LIBWREN_CONFIG := debug_64bit
LIB_WREN := wren/lib/libwren_d.a
LIB_WREN_CONFIG := debug_64bit
else
LIBS = wren
endif
LIB_DIRS = wren/lib
LIBWREN ?= wren/lib/libwren.a
LIBWREN_CONFIG ?= release_64bit
${LIBWREN}: wren
@make --no-print-directory -C wren/projects/make wren config=${LIBWREN_CONFIG}
LIB_WREN ?= wren/lib/libwren.a
LIB_WREN_CONFIG ?= release_64bit
${LIB_WREN}: wren
@make --no-print-directory -C wren/projects/make wren config=${LIB_WREN_CONFIG}

# Wren Libraries
libs:
vendor/wren-vector/wren_modules:
@cd vendor/wren-vector && wrenc package.wren install
.PHONY: libs

######################
# Vendored Libraries
######################

vendor: native.lock.yml
@CONFIG=${CONFIG} vendor/download.sh
# TODO: Download wgpu-native binaries on Windows
.PHONY: vendor

# WebGPU
WGPU := wgpu-${shell echo ${OS} | tr '[:upper:]' '[:lower:]'}-${ARCH}-${CONFIG}
WGPU_DEST := vendor/${WGPU}
vendor: ${WGPU_DEST}
.PHONY: vendor

ifneq (${OS},Windows)
# LIBS = ${WGPU_DEST}/libwgpu_native.a
LIBS = wgpu_native
Expand Down
4 changes: 4 additions & 0 deletions vendor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 1,4 @@
glfw-*/
glfw-*.zip
wgpu-*/
wgpu-*.zip
47 changes: 34 additions & 13 deletions vendor/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 10,40 @@ ARCH=`uname -m`
if [[ -z $CONFIG ]]; then
CONFIG=debug
fi
ZIP="wgpu-${OS}-${ARCH}-${CONFIG}.zip"
DEST=`echo ${ZIP} | cut --delimiter=. --fields 1`

# Short-circut if binaries are already downloaded
if [[ -e "${DEST}/commit-sha" ]]; then
echo "Using cached wgpu-native release: ${DEST}"
exit 0
fi

# Download wgpu-native binaries
VERSION=`tail ../native.lock.yml -n1 | cut --delimiter=':' --fields=2 | tr -d '[:space:]'`
URL="https://github.com/gfx-rs/wgpu-native/releases/download/v${VERSION}/${ZIP}.zip"
function wgpu() {
ZIP="wgpu-${OS}-${ARCH}-${CONFIG}.zip"
DEST=`echo ${ZIP} | cut --delimiter=. --fields 1`
VERSION=`tail ../native.lock.yml -n1 | cut --delimiter=':' --fields=2 | tr -d '[:space:]'`
URL="https://github.com/gfx-rs/wgpu-native/releases/download/v${VERSION}/${ZIP}.zip"

# Short-circut if it's already downloaded
if [[ -e "${DEST}/commit-sha" ]]; then
echo "Using cached wgpu-native release: ${DEST}"
return 0
fi

echo Downloading wgpu-native from: ${URL}
wget -q ${URL}
unzip ${ZIP} -d ${DEST}
rm ${ZIP}
}

# Download glfw sources
function glfw() {
ZIP=glfw-3.3.9.zip
DEST=`basename ${ZIP} .zip`

# Short-circut if it's already downloaded
if [[ -e "${DEST}/CMakeLists.txt" ]]; then
echo "Using cached GLFW release: ${DEST}"
return 0
fi

wget -q "https://github.com/glfw/glfw/releases/download/3.3.9/glfw-3.3.9.zip"
unzip ${ZIP}
rm ${ZIP}
}

echo Donloading wgpu-native from: ${URL}
wget -q ${URL}
unzip ${ZIP} -d ${DEST}
wgpu && glfw

0 comments on commit 0928514

Please sign in to comment.