Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5b3b042
Update JDK version and paths in CI workflow
Thihup Jan 15, 2026
70c58d5
Upgrade Gradle wrapper to version 9.2.1
Thihup Jan 15, 2026
f7899b9
Update path for webgpu.h in copyWgpuHeaders task
Thihup Jan 15, 2026
82e6c6a
Upgrade Java version from 21 to 25
Thihup Jan 15, 2026
2b453bb
Initial plan
Copilot Jan 15, 2026
6c93548
Add Windows support to bindings build workflow
Copilot Jan 15, 2026
97c2842
Update natives build.gradle to support Windows toolchain
Copilot Jan 15, 2026
f8f161c
Simplify workflow by splitting extract steps
Copilot Jan 15, 2026
d38dbe4
Address code review feedback
Copilot Jan 15, 2026
b26be52
Add explicit permissions to workflow for security
Copilot Jan 15, 2026
8c1c112
Fix Windows jextract download to use tar.gz
Copilot Jan 15, 2026
3bcb1c8
Quote Gradle parameters to fix Windows parsing
Copilot Jan 16, 2026
9e77add
Merge pull request #1 from Thihup/copilot/add-windows-bindings-support
Thihup Jan 16, 2026
70f2906
Disable fail-fast in build and publish workflow
Thihup Jan 16, 2026
33d57d7
Add stacktrace option to bindings generation command
Thihup Jan 16, 2026
99323aa
Add OS detection for jextract executable
Thihup Jan 16, 2026
f5470c7
Move isWindows definition to a new line
Thihup Jan 16, 2026
47aaa53
Initial plan
Copilot Jan 16, 2026
4d7d649
Add sources JAR generation and publishing for JExtract generated code
Copilot Jan 16, 2026
f1e8030
Explicitly set archiveBaseName for sourcesJar task
Copilot Jan 16, 2026
48b9c36
Merge pull request #2 from Thihup/copilot/publish-source-code-jextract
Thihup Jan 16, 2026
0a289b8
Add '--library' option to jextract args
Thihup Jan 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 59 additions & 13 deletions .github/workflows/build-and-publish-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,60 @@ on:
required: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
include:
- os: ubuntu-latest
jextract_url: https://download.java.net/java/early_access/jextract/25/2/openjdk-25-jextract+2-4_linux-x64_bin.tar.gz
jextract_archive: jdk.tar.gz
os_name: linux
gradle_cmd: ./gradlew
- os: windows-latest
jextract_url: https://download.java.net/java/early_access/jextract/25/2/openjdk-25-jextract+2-4_windows-x64_bin.tar.gz
jextract_archive: jdk.tar.gz
os_name: windows
gradle_cmd: .\gradlew.bat
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- run: wget -O $RUNNER_TEMP/jdk.tar.gz https://download.java.net/java/early_access/jextract/22/5/openjdk-22-jextract+5-33_linux-x64_bin.tar.gz
- run: tar -xf $RUNNER_TEMP/jdk.tar.gz
- run: echo "JEXTRACT_HOME=$(pwd)/jextract-22" >> $GITHUB_ENV

- name: Download jextract (Linux)
if: matrix.os == 'ubuntu-latest'
run: wget -O $RUNNER_TEMP/${{ matrix.jextract_archive }} ${{ matrix.jextract_url }}

- name: Download jextract (Windows)
if: matrix.os == 'windows-latest'
run: |
Invoke-WebRequest -Uri "${{ matrix.jextract_url }}" -OutFile "$env:RUNNER_TEMP\${{ matrix.jextract_archive }}"
shell: pwsh

- name: Extract jextract (Linux)
if: matrix.os == 'ubuntu-latest'
run: tar -xf $RUNNER_TEMP/${{ matrix.jextract_archive }}

- name: Extract jextract (Windows)
if: matrix.os == 'windows-latest'
run: tar -xf $env:RUNNER_TEMP\${{ matrix.jextract_archive }}
shell: pwsh

- name: Set JEXTRACT_HOME (Linux)
if: matrix.os == 'ubuntu-latest'
run: echo "JEXTRACT_HOME=$(pwd)/jextract-25" >> $GITHUB_ENV

- name: Set JEXTRACT_HOME (Windows)
if: matrix.os == 'windows-latest'
run: echo "JEXTRACT_HOME=$((Get-Location).Path)\jextract-25" >> $env:GITHUB_ENV
shell: pwsh

- uses: actions/setup-java@v4
id: install-jdk
with:
java-version: 21
java-version: 25
distribution: temurin

- name: Setup Gradle
Expand All @@ -35,25 +79,27 @@ jobs:
gradle-version: wrapper

- name: Download natives
run: ./gradlew -PwgpuVersion=${{ inputs.wgpuVersion }} :natives:download
run: ${{ matrix.gradle_cmd }} "-PwgpuVersion=${{ inputs.wgpuVersion }}" "-Pos=${{ matrix.os_name }}" :natives:download

- name: Extract natives
run: ./gradlew -PwgpuVersion=${{ inputs.wgpuVersion }} :natives:unzip
run: ${{ matrix.gradle_cmd }} "-PwgpuVersion=${{ inputs.wgpuVersion }}" "-Pos=${{ matrix.os_name }}" :natives:unzip

- name: Copy headers
run: ./gradlew -PwgpuVersion=${{ inputs.wgpuVersion }} ':natives:copyWgpuHeaders'
run: ${{ matrix.gradle_cmd }} "-PwgpuVersion=${{ inputs.wgpuVersion }}" "-Pos=${{ matrix.os_name }}" ':natives:copyWgpuHeaders'

- name: Generate bindings
run: ./gradlew -PwgpuVersion=${{ inputs.wgpuVersion }} -Pjextract.home=${{ env.JEXTRACT_HOME }} :lib:bindings
run: ${{ matrix.gradle_cmd }} "--stacktrace" "-PwgpuVersion=${{ inputs.wgpuVersion }}" "-Pjextract.home=${{ env.JEXTRACT_HOME }}" :lib:bindings

- name: Publish bindings as artifact
uses: actions/upload-artifact@v4
with:
name: webgpu-bindings
path: lib/build/webgpu.jar
name: webgpu-bindings-${{ matrix.os_name }}
path: |
lib/build/webgpu.jar
lib/build/webgpu-sources.jar

- name: Publish bindings to GH packages
run: ./gradlew -PwgpuVersion=${{ inputs.wgpuVersion }} :lib:publish
run: ${{ matrix.gradle_cmd }} "-PwgpuVersion=${{ inputs.wgpuVersion }}" :lib:publish
env:
GITHUB_USER: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.PKG_PUBLISHING_AUTH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.PKG_PUBLISHING_AUTH_TOKEN }}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
28 changes: 20 additions & 8 deletions lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import java.nio.file.Paths
import org.gradle.internal.os.OperatingSystem

plugins {
id 'java-library'
id 'maven-publish'
}

def isWindows = OperatingSystem.current().isWindows()
def wgpuVersion = project.findProperty('wgpuVersion')

configurations {
Expand All @@ -20,13 +22,13 @@ def jextractHome = project.hasProperty('jextract.home')
: null

java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
languageVersion.set(JavaLanguageVersion.of(25))
}
}

Expand All @@ -50,15 +52,17 @@ task invokeJextract(type: Exec){
doFirst {
file('build/bindings').mkdirs()
}
def exeName = isWindows ? 'jextract.bat' : 'jextract'
if(jextractHome){
executable Paths.get(jextractHome as String, 'bin', 'jextract')
executable Paths.get(jextractHome as String, 'bin', exeName).toString()
}else{
executable 'jextract'
executable exeName
}
args (
configurations.headers.files[0],
'-t', 'com.myworldvw.webgpu',
'--output', 'build/bindings'
'--output', 'build/bindings',
'--library', 'wgpu_native'
)
}

Expand All @@ -77,8 +81,15 @@ task jextract(dependsOn: [invokeJextract, cleanupExtras])

tasks.findByName('compileJava').dependsOn jextract

task bindings(type: Copy, dependsOn: [jextract, jar]){
task sourcesJar(type: Jar, dependsOn: jextract) {
archiveBaseName = 'webgpu'
archiveClassifier = 'sources'
from 'build/bindings'
}

task bindings(type: Copy, dependsOn: [jextract, jar, sourcesJar]){
from jar
from sourcesJar
into 'build'
}

Expand All @@ -90,6 +101,7 @@ publishing {
version = "$wgpuVersion"

artifact file("build/webgpu.jar")
artifact sourcesJar
}
}
repositories {
Expand All @@ -103,4 +115,4 @@ publishing {
}
}
}
}
}
17 changes: 11 additions & 6 deletions natives/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@ def wgpuVersion = project.findProperty('wgpuVersion')
def os = project.hasProperty('os') ? project.findProperty('os') : 'linux'
def arch = project.hasProperty('arch') ? project.findProperty('arch') : 'x86_64'
def type = project.hasProperty('type') ? project.findProperty('type') : 'debug'
def toolchain = project.hasProperty('toolchain') ? project.findProperty('toolchain') : (os == 'windows' ? 'msvc' : null)

// Construct the platform string based on OS
def platformString = (os == 'windows' && toolchain) ? "$os-$arch-$toolchain" : "$os-$arch"
def fileName = "wgpu-$platformString-${type}.zip"

task download(type: Download) {
src "https://github.com/gfx-rs/wgpu-native/releases/download/$wgpuVersion/wgpu-$os-$arch-${type}.zip"
dest "bin/$wgpuVersion/$os-$arch-${type}.zip"
src "https://github.com/gfx-rs/wgpu-native/releases/download/$wgpuVersion/$fileName"
dest "bin/$wgpuVersion/$fileName"
}

task unzip(type: Copy) {
from zipTree("bin/$wgpuVersion/$os-$arch-${type}.zip")
into "bin/$wgpuVersion/$os-$arch-$type"
from zipTree("bin/$wgpuVersion/$fileName")
into "bin/$wgpuVersion/$platformString-$type"
}

task copyWgpuHeaders(type: Copy) {
from "bin/$wgpuVersion/$os-$arch-$type/webgpu.h"
from "bin/$wgpuVersion/$platformString-$type/include/webgpu/webgpu.h"
into 'build/headers/'
}

artifacts {
headers file('build/headers/webgpu.h')
}
}