Detect required wgpu version from the bindings
This commit is contained in:
@@ -4,12 +4,11 @@ set -e
|
|||||||
|
|
||||||
PROJECT="sindri"
|
PROJECT="sindri"
|
||||||
VERSION="dev-$(date -u '+%Y-%m-%d')-$(git rev-parse --short HEAD)"
|
VERSION="dev-$(date -u '+%Y-%m-%d')-$(git rev-parse --short HEAD)"
|
||||||
WGPU_VERSION="v29.0.1.1"
|
|
||||||
|
|
||||||
# ------------------------------------------
|
# ------------------------------------------
|
||||||
|
|
||||||
# Setup compiled wgpu binary
|
# Setup compiled wgpu binary
|
||||||
./scripts/wgpu-init.sh "$WGPU_VERSION"
|
./scripts/wgpu-init.sh
|
||||||
|
|
||||||
# ------------------------------------------
|
# ------------------------------------------
|
||||||
|
|
||||||
@@ -18,8 +17,16 @@ mkdir -p build
|
|||||||
if [ "$1" = "debug" ]; then
|
if [ "$1" = "debug" ]; then
|
||||||
shift
|
shift
|
||||||
|
|
||||||
odin build src/ -show-timings -collection:sindri=src -collection:gram=vendor/gram/src -out:build/$PROJECT -microarch:native -use-separate-modules -define:VERSION="$VERSION-debug" -debug "$@"
|
odin build src/ -show-timings \
|
||||||
|
-collection:sindri=src \
|
||||||
|
-collection:gram=vendor/gram/src \
|
||||||
|
-collection:wgpu=vendor \
|
||||||
|
-out:build/$PROJECT -microarch:native -use-separate-modules -define:VERSION="$VERSION-debug" -debug "$@"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
odin build src/ -show-timings -collection:sindri=src -collection:gram=vendor/gram/src -out:build/$PROJECT -microarch:native -o:speed -define:VERSION="$VERSION" "$@"
|
odin build src/ -show-timings \
|
||||||
|
-collection:sindri=src \
|
||||||
|
-collection:gram=vendor/gram/src \
|
||||||
|
-collection:wgpu=vendor \
|
||||||
|
-out:build/$PROJECT -microarch:native -o:speed -define:VERSION="$VERSION" "$@"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"collections": [
|
"collections": [
|
||||||
{ "name": "sindri", "path": "src" },
|
{ "name": "sindri", "path": "src" },
|
||||||
{ "name": "gram", "path": "vendor/gram/src" }
|
{ "name": "gram", "path": "vendor/gram/src" },
|
||||||
|
{ "name": "wgpu", "path": "vendor" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+72
-49
@@ -1,63 +1,41 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
WGPU_VERSION="$1"
|
|
||||||
|
|
||||||
if [ "$1" = "" ]; then
|
|
||||||
echo "error: WGPU_VERSION was not set"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
SCRIPT_DIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
|
SCRIPT_DIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
|
||||||
VENDOR_DIR="$SCRIPT_DIR/../vendor"
|
VENDOR_DIR="$SCRIPT_DIR/../vendor"
|
||||||
|
|
||||||
# ------------------------------------------
|
# ------------------------------------------
|
||||||
# Copy vendor/wgpu
|
|
||||||
|
|
||||||
# Check if wgpu was copied already
|
|
||||||
if [ -d "$VENDOR_DIR/wgpu" ]; then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Copy wgpu
|
|
||||||
wgpu_path="$(odin root)/vendor/wgpu"
|
|
||||||
cp -r "$wgpu_path" "$VENDOR_DIR"
|
|
||||||
chmod +w "$VENDOR_DIR/wgpu/lib"
|
|
||||||
|
|
||||||
# ------------------------------------------
|
|
||||||
# Download
|
|
||||||
|
|
||||||
ASSET_BASE="https://github.com/gfx-rs/wgpu-native/releases/download/${WGPU_VERSION}"
|
|
||||||
|
|
||||||
# Platform detection
|
# Platform detection
|
||||||
|
|
||||||
|
# OS detection
|
||||||
case "$(uname -s)" in
|
case "$(uname -s)" in
|
||||||
Darwin)
|
Darwin)
|
||||||
os="macos"
|
os="macos"
|
||||||
;;
|
;;
|
||||||
Linux)
|
Linux)
|
||||||
os="linux"
|
os="linux"
|
||||||
;;
|
;;
|
||||||
MINGW* | MSYS* | CYGWIN*)
|
MINGW* | MSYS* | CYGWIN*)
|
||||||
os="windows"
|
os="windows"
|
||||||
extra="-msvc"
|
extra="-msvc"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "wgpu setup: unsupported OS '$(uname -s)'" >&2
|
echo "wgpu setup: unsupported OS '$(uname -s)'" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Arch detection
|
# Arch detection
|
||||||
case "$(uname -m)" in
|
case "$(uname -m)" in
|
||||||
arm64 | aarch64)
|
arm64 | aarch64)
|
||||||
arch="aarch64"
|
arch="aarch64"
|
||||||
;;
|
;;
|
||||||
x86_64 | amd64)
|
x86_64 | amd64)
|
||||||
arch="x86_64"
|
arch="x86_64"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "wgpu setup: unsupported arch '$(uname -m)'" >&2
|
echo "wgpu setup: unsupported arch '$(uname -m)'" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Download filename
|
# Download filename
|
||||||
@@ -66,6 +44,51 @@ name="wgpu-${os}-${arch}${extra:-}-release"
|
|||||||
# Compiler filename: lib/wgpu-macos-aarch64-release/lib/libwgpu_native.a
|
# Compiler filename: lib/wgpu-macos-aarch64-release/lib/libwgpu_native.a
|
||||||
target="$VENDOR_DIR/wgpu/lib/$name"
|
target="$VENDOR_DIR/wgpu/lib/$name"
|
||||||
|
|
||||||
|
# ------------------------------------------
|
||||||
|
# WGPU version detection
|
||||||
|
|
||||||
|
# Detect the wgpu-native version the bundled bindings expect, can be overridden
|
||||||
|
if [ "$1" != "" ]; then
|
||||||
|
WGPU_VERSION="$1"
|
||||||
|
else
|
||||||
|
WGPU_VERSION="v$(sed -n 's/.*BINDINGS_VERSION_STRING :: "\([^"]*\)".*/\1/p' "$(odin root)/vendor/wgpu/wgpu_native_types.odin")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$WGPU_VERSION" = "v" ]; then
|
||||||
|
echo "wgpu setup: could not detect the wgpu-native version" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Detect the version of the vendored wgpu bindings
|
||||||
|
current="v$(sed -n 's/.*BINDINGS_VERSION_STRING :: "\([^"]*\)".*/\1/p' "$VENDOR_DIR/wgpu/wgpu_native_types.odin" 2> /dev/null)"
|
||||||
|
|
||||||
|
# Check if the vendored wgpu is already up to date
|
||||||
|
if [ "$current" = "$WGPU_VERSION" ] && [ -d "$target" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ------------------------------------------
|
||||||
|
# Copy vendor/wgpu
|
||||||
|
|
||||||
|
# Remove any stale copy
|
||||||
|
rm -rf "$VENDOR_DIR/wgpu"
|
||||||
|
|
||||||
|
# Copy wgpu
|
||||||
|
wgpu_path="$(odin root)/vendor/wgpu"
|
||||||
|
cp -r "$wgpu_path" "$VENDOR_DIR"
|
||||||
|
chmod -R +w "$VENDOR_DIR/wgpu"
|
||||||
|
|
||||||
|
# Point imports at the copied vendor wgpu package
|
||||||
|
grep -rl '"vendor:wgpu"' "$VENDOR_DIR/wgpu" --include='*.odin' |
|
||||||
|
while IFS= read -r file; do
|
||||||
|
sed 's|"vendor:wgpu"|"wgpu:wgpu"|g' "$file" >"$file.tmp" && mv "$file.tmp" "$file"
|
||||||
|
done
|
||||||
|
|
||||||
|
# ------------------------------------------
|
||||||
|
# Download
|
||||||
|
|
||||||
|
ASSET_BASE="https://github.com/gfx-rs/wgpu-native/releases/download/${WGPU_VERSION}"
|
||||||
|
|
||||||
# Download
|
# Download
|
||||||
if [ ! -d "$target" ]; then
|
if [ ! -d "$target" ]; then
|
||||||
url="${ASSET_BASE}/${name}.zip"
|
url="${ASSET_BASE}/${name}.zip"
|
||||||
@@ -73,5 +96,5 @@ if [ ! -d "$target" ]; then
|
|||||||
tmp=$(mktemp -d)
|
tmp=$(mktemp -d)
|
||||||
trap 'rm -rf "$tmp"' EXIT
|
trap 'rm -rf "$tmp"' EXIT
|
||||||
curl -fL --retry 3 -o "$tmp/wgpu.zip" "$url"
|
curl -fL --retry 3 -o "$tmp/wgpu.zip" "$url"
|
||||||
unzip -o -q "$tmp/wgpu.zip" -d "$VENDOR_DIR/wgpu/lib/$name"
|
unzip -o -q "$tmp/wgpu.zip" -d "$target"
|
||||||
fi
|
fi
|
||||||
|
|||||||
+1
-1
@@ -2,9 +2,9 @@ package sindri
|
|||||||
|
|
||||||
import "base:runtime"
|
import "base:runtime"
|
||||||
import "core:fmt"
|
import "core:fmt"
|
||||||
import "vendor:wgpu"
|
|
||||||
|
|
||||||
import "gram:chunks"
|
import "gram:chunks"
|
||||||
|
import "wgpu:wgpu"
|
||||||
|
|
||||||
VERSION :: #config(VERSION, "dev")
|
VERSION :: #config(VERSION, "dev")
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,10 +1,10 @@
|
|||||||
package sindri
|
package sindri
|
||||||
|
|
||||||
import "core:time"
|
import "core:time"
|
||||||
|
|
||||||
import "vendor:glfw"
|
import "vendor:glfw"
|
||||||
import "vendor:wgpu"
|
|
||||||
import "vendor:wgpu/glfwglue"
|
import "wgpu:wgpu"
|
||||||
|
import "wgpu:wgpu/glfwglue"
|
||||||
|
|
||||||
OS :: struct {
|
OS :: struct {
|
||||||
window: glfw.WindowHandle,
|
window: glfw.WindowHandle,
|
||||||
|
|||||||
Reference in New Issue
Block a user