Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/use panama #11

Open
wants to merge 207 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
207 commits
Select commit Hold shift + click to select a range
f4e2fd0
Add jextract tool classes and update build settings
Dec 7, 2023
174fa94
Create jextract tool classes and update project settings
Dec 7, 2023
9f9325c
try to use jextract
Dec 7, 2023
7ad123a
Refactor code to utilise jextract for file parsing
Dec 28, 2023
8187d29
Expand parser implementation to support native structure types
Dec 28, 2023
8f01bc4
Add support for functions and type aliases in PanamaLibclangParser
Dec 28, 2023
37ba01b
Add union parsing support to LibClangParser
Dec 28, 2023
6d4323b
Update systemProperties to use inferPlatformClangPath
Dec 28, 2023
c725487
Update identifiers and add function in 'functions.h.ast.json'
Dec 28, 2023
c9747d3
Add new function to FunctionGenerationTest
Dec 28, 2023
20eff8c
Add Linux support to libclang path finder
Dec 28, 2023
805b5ce
Update libclang path finder for Linux support
Dec 28, 2023
27ae205
Refactor `parseFile` function in `LibClangParser`
Dec 28, 2023
60a1d6e
Update test.yml
ygdrasil-io Dec 28, 2023
56455c3
Add debug logging and libclang download task
Dec 30, 2023
9f47359
Update build configurations and library loading for cross-platform su…
Dec 31, 2023
7d628b2
Refactor Type.toTypeRef() method in TypeRef.kt
Dec 31, 2023
6d4f152
Add file separator to temporary directory path
Dec 31, 2023
6385f9c
Rename method names and fix typo in RuntimeHelper.java
Dec 31, 2023
8255ec0
Refactor parser functions in PanamaLibclangParser.kt
Jan 1, 2024
6c7f604
Refactor Type handling in TypeRef.kt
Jan 1, 2024
94f0c8b
Refactor type handling and structure fields conversion
Jan 1, 2024
785a297
Update KlangPlugin to include parsing method option
Jan 1, 2024
3cdbbba
Add Libclang parsing in KlangPlugin
Jan 2, 2024
ff39731
add SDL2 header to use it later on it test
Jan 6, 2024
722151f
Add task to unzip SDL2 headers in klang project
Jan 6, 2024
6353e4a
Update parsing function and add C-headers unzip task
Jan 6, 2024
793d87f
Improve type parsing and add exhaustive type definitions testing
Jan 8, 2024
f7e3c01
Add unzip tasks conditions and enhance type string conversion
Jan 9, 2024
23c649a
Update architecture recognition logic in RuntimeHelper
ygdrasil-io Jan 18, 2024
91bddfe
Refactor LibClangParser and update TestData
ygdrasil-io Jan 18, 2024
f28587a
Add pointer type and array count handling in TypeRef.kt
ygdrasil-io Jan 18, 2024
aca7ae0
Enable SDL2 parsing test only on Darwin OS
ygdrasil-io Jan 18, 2024
62bcb20
test
ygdrasil-io Jan 18, 2024
743ffd1
rollback test
ygdrasil-io Jan 18, 2024
b533086
Refactor build scripts and remove unused code
ygdrasil-io Jan 18, 2024
1c30bcc
Update Gradle distribution, Kotlin version, and build scripts
ygdrasil-io Jan 18, 2024
7617d81
Refactor "unzip" tasks and directory declarations in gradle file
ygdrasil-io Jan 20, 2024
bb49d14
Add Ubuntu Java Dockerfile and improve OS compatibility in Gradle.
ygdrasil-io Jan 21, 2024
c34a1b6
Add task dependencies and unpacking functionality in KlangPlugin
Jan 29, 2024
71136d4
Refactor KlangPlugin and introduce zip and file helper classes
ygdrasil-io Feb 1, 2024
98f2aca
Update concurrency behaviour in GitHub workflow
ygdrasil-io Feb 1, 2024
75b7ab9
Add new architectures to test matrix in GitHub workflow
ygdrasil-io Feb 1, 2024
1ab54ef
Refine GitHub Action workflows for diverse architectures
ygdrasil-io Feb 1, 2024
8eb4907
Fix syntax error in GitHub Actions workflow
ygdrasil-io Feb 1, 2024
7422b75
Correct syntax error in Dockerfile
ygdrasil-io Feb 1, 2024
954f142
Add logging to LibClangParser file parsing
ygdrasil-io Feb 1, 2024
7244ce3
Remove QEMU setup from GitHub actions workflow
ygdrasil-io Feb 1, 2024
139e626
Update QEMU setup in GitHub actions workflow
ygdrasil-io Feb 1, 2024
ae800bb
Update GitHub Actions workflow for QEMU setup
ygdrasil-io Feb 1, 2024
f05ee6b
Exclude x64 architecture from GitHub Actions workflow
ygdrasil-io Feb 1, 2024
ab59b9a
Correct indentation for exclusion list in GitHub Actions config
ygdrasil-io Feb 1, 2024
1f6969c
"Remove macOS specific handling and tests"
ygdrasil-io Feb 1, 2024
d4ac832
Update architecture checks in GitHub workflows
ygdrasil-io Feb 1, 2024
baf07a5
Reorder steps and refine architecture checks in workflow
ygdrasil-io Feb 1, 2024
49b29f7
Refactor build script and test suite
ygdrasil-io Feb 1, 2024
584557b
Update GitHub workflow for testing on new environments
ygdrasil-io Feb 2, 2024
fe1f629
Update GitHub workflow test environments
ygdrasil-io Feb 2, 2024
d42c96f
Refactor code to support detection and handling of various operating …
ygdrasil-io Feb 2, 2024
c4bc97b
Remove unused code from test.kt
ygdrasil-io Feb 2, 2024
fa30559
Update README.md with project details
ygdrasil-io Feb 2, 2024
34f67b3
Revise parsing mechanism and enhance repository functions
ygdrasil-io Feb 4, 2024
4c9ddc0
Refactor StructureField in NativeStructure to handle different field …
ygdrasil-io Feb 4, 2024
ae67043
Refactor unused imports throughout the codebase
ygdrasil-io Feb 4, 2024
dab921c
Improve code cleanliness by removing unused imports
ygdrasil-io Feb 4, 2024
0af980c
Improve code cleanliness by removing unused imports
ygdrasil-io Feb 4, 2024
88f83d5
Refactor build configuration for better readability
ygdrasil-io Feb 4, 2024
78ad052
temp file
ygdrasil-io Feb 9, 2024
34b50ed
Improve assertion message for missing header files
ygdrasil-io Feb 11, 2024
a7bac97
Update operating system based header path selection
ygdrasil-io Feb 11, 2024
19012bf
Update Docker build commands in build.sh script
ygdrasil-io Feb 11, 2024
1a1aa3d
Add logging to unzip function and adjust Docker run
ygdrasil-io Feb 12, 2024
a9cc318
Add logging to unzip function and adjust Docker run
ygdrasil-io Feb 12, 2024
d07e31b
Add libc checks for Ubuntu in workflow file
ygdrasil-io Feb 12, 2024
cfc9bbc
Remove libc linking step from Ubuntu workflow
ygdrasil-io Feb 12, 2024
b2f5784
Replace libc linking step with libc installation in Ubuntu workflow
ygdrasil-io Feb 12, 2024
90a5e3d
test
ygdrasil-io Feb 12, 2024
0cc6041
test
ygdrasil-io Feb 12, 2024
48a5e92
test
ygdrasil-io Feb 12, 2024
1c45645
test
ygdrasil-io Feb 12, 2024
17c51c0
Add option to load libclang from environment variable
ygdrasil-io Feb 12, 2024
13a91a7
test
ygdrasil-io Feb 12, 2024
3a45fec
test
ygdrasil-io Feb 12, 2024
daea1c5
Add operating system detection for C-headers
ygdrasil-io Feb 13, 2024
4218797
Implement HeaderManager for handling platform-specific headers
Feb 13, 2024
12cdc56
Add `DeclarationOrigin` to native declarations
Feb 13, 2024
0770f9b
add more integration tests
Feb 14, 2024
41129aa
Consolidate domain name types to NotBlankString
Feb 14, 2024
624414d
Refactor code to enforce non-blank domain names
Feb 14, 2024
f53bff6
Improve file path handling and update function mapping
Feb 14, 2024
54a98df
Refactor cHeadersDirectory path usage in KlangPlugin
ygdrasil-io Feb 14, 2024
fa0289a
Update NativeFunction name type to NotBlankString
ygdrasil-io Feb 14, 2024
f05ea45
Remove multiple class definitions in FixTypeAlias.kt
ygdrasil-io Feb 14, 2024
c1fea62
Upgrade Gradle and enhance gradlew script
ygdrasil-io Feb 15, 2024
d55f881
Optimize Dockerfile and cleanup apt cache
ygdrasil-io Feb 15, 2024
86701c9
Updated build process and signing implementation for Sonatype Central
ygdrasil-io Feb 15, 2024
4dffaa9
Update Sonatype login to use secrets in Github workflow
ygdrasil-io Feb 15, 2024
00582ed
Update angle library configuration settings
ygdrasil-io Feb 16, 2024
986723a
Add support for parsing native constants
ygdrasil-io Feb 16, 2024
075b76f
Refactor generator classes and add support for native constants
ygdrasil-io Feb 16, 2024
f3c7cad
Remove libsdl/Constants.kt and modify main.kt
ygdrasil-io Feb 16, 2024
9bec6b0
Refine handling of Long constants in NativeConstant
Feb 19, 2024
f277c67
Introduce ParsinMethod in build.gradle.kts
Feb 19, 2024
b0fa80f
Add 'snake' example to SDL bindings and update library
Feb 19, 2024
a4e1416
Add 'Tetris' example to SDL bindings
Feb 19, 2024
390cd6f
Remove several Kotlin files related to SDL and game implementations
ygdrasil-io Feb 20, 2024
323ec08
Implement 'Snake' game and optimize SDL example code
Feb 20, 2024
7684f7c
Delete all Angle and GLES bindings files from Kotlin library
Feb 20, 2024
a0161a5
Add texture management and refactor Snake game
Feb 20, 2024
d4d0ec4
Rename 'allocRect' function to 'rect'
Feb 20, 2024
dd6645f
Refactor SDL imports and update function names and calls
Feb 20, 2024
0de5ade
Refactored SDL bindings and functions in snake game
Feb 20, 2024
91a2b40
Refactor snake game SDL bindings and functions
Feb 20, 2024
d25d232
Refactor package structure and update SDL bindings
Feb 20, 2024
1a33230
Update jlink options and refactor JavaCompile task
Feb 20, 2024
d0b0933
Update Tetris game implementation in SDL
ygdrasil-io Feb 21, 2024
24237e4
Improve handling of nullable types in functions and alias
ygdrasil-io Feb 21, 2024
bc3eae9
Refactor code across several files and add new functionalities
ygdrasil-io Feb 22, 2024
dbfab33
Add functionality for macros in file parsing
ygdrasil-io Feb 22, 2024
0d584cb
Remove unused libclang parser files and enhance type alias generation
ygdrasil-io Feb 23, 2024
850a31a
Add logic to handle array types with type alias
ygdrasil-io Feb 23, 2024
174f468
Add array handling in type alias generation
ygdrasil-io Feb 23, 2024
228891e
Refactor code for SDL bindings in Kotlin
ygdrasil-io Feb 23, 2024
ecf20e6
Update .gitignore to ignore native libraries
ygdrasil-io Feb 23, 2024
f71a121
Update project names and improve build configurations
ygdrasil-io Feb 23, 2024
f21316e
Add new projects and enhance Gradle build scripts
ygdrasil-io Feb 23, 2024
852f953
Add new projects and enhance Gradle build scripts
ygdrasil-io Feb 23, 2024
f30e977
Add temporarily c files
ygdrasil-io Feb 23, 2024
e2b9fbc
Add logging and adapter setup to wgpu-native example
ygdrasil-io Feb 26, 2024
5f09821
Refactor Kotlin code and enhance Gradle configuration
Feb 26, 2024
20a70d5
Add SDL2SysHeader to SDL2ItTest and adjust fields merging
ygdrasil-io Feb 26, 2024
bb865ff
Update .gitignore to include .jar files
ygdrasil-io Feb 26, 2024
2e5b05d
The given commit message does not match the changes made in the diff.…
ygdrasil-io Feb 26, 2024
b415cdb
Add ObjectiveC and SDL2-WebGPU bindings for wgpu-native example
ygdrasil-io Feb 26, 2024
fd70843
Add support for SDL2-WebGPU and ObjectiveC bindings
ygdrasil-io Feb 26, 2024
f9ba2cb
add missing header
ygdrasil-io Feb 26, 2024
ac2907e
Updated bindings, added new Kotlin file, and refactored code
Feb 27, 2024
f3a5cab
Add shader module to triangle example in wgpu-native bindings
Feb 27, 2024
2d31079
Enhance graphics handling in main.kt and shader.kt
ygdrasil-io Feb 28, 2024
e96a730
Add triangle handling code and optimize pipeline layout
ygdrasil-io Feb 28, 2024
8bf2c77
Refactor structure generation and adjust string default values
ygdrasil-io Feb 29, 2024
e521e50
Update structure reference handling and nullable pointer introduction
ygdrasil-io Feb 29, 2024
3a01eeb
Update references for structure fields and ensure use of nullable poi…
ygdrasil-io Feb 29, 2024
e4e9495
Update Kotlin file generator and improve structure handling
ygdrasil-io Feb 29, 2024
8d6eb4c
Apply temporary fixes for Callback functionality in Kotlin files
ygdrasil-io Feb 29, 2024
b9eff7f
Improve Source File Management and Callback Functionality
ygdrasil-io Mar 1, 2024
c915fc0
Refactor TypeAlias file generation in Klang
ygdrasil-io Mar 1, 2024
87cfdba
Update nullable handling in type and callback mapping
ygdrasil-io Mar 1, 2024
cc9675f
Update rendering and resource handling in triangle example
ygdrasil-io Mar 1, 2024
1be7a70
Refactor rendering pipeline and error handling in triangle example
ygdrasil-io Mar 1, 2024
8eb2d79
Rename 'frame' to 'view' in helloTriangle.kt
ygdrasil-io Mar 1, 2024
d1f6a3b
Init a basic WebGPU binding on js
ygdrasil-io Mar 2, 2024
310e31e
Implement structure for WebGPU binding in JavaScript
ygdrasil-io Mar 2, 2024
b3f9914
Implement structure for WebGPU binding in JavaScript
ygdrasil-io Mar 2, 2024
62ec6b9
Update and refactor rendering in WebGPU bindings
ygdrasil-io Mar 2, 2024
ae6b8c4
Add essential components for WebGPU JVVM bindings
ygdrasil-io Mar 3, 2024
121ce8f
Refactor WebGPU JVM bindings
ygdrasil-io Mar 3, 2024
a5a03f8
Refactor rendering context setup in main and related classes
ygdrasil-io Mar 3, 2024
2d6eb25
Refactor main file and move it into the examples directory
ygdrasil-io Mar 3, 2024
54bcb85
Refactor graphic rendering code into BlueTitlingScene and Application…
ygdrasil-io Mar 3, 2024
66627aa
Refactor BlueTitlingScene class and enforce non-null return in Render…
ygdrasil-io Mar 3, 2024
07636e0
Implement createShaderModule and createPipelineLayout functions in wgpu
ygdrasil-io Mar 3, 2024
cd7ea5f
Update wgpu bindings with shader and pipeline layout creation
ygdrasil-io Mar 4, 2024
59c188f
Refactor createCommandEncoder and fix error messages
ygdrasil-io Mar 4, 2024
4a5a2de
Improve createRenderPipeline method in SimpleTriangleScene
ygdrasil-io Mar 4, 2024
7b6fa98
Refactor RenderingContext and webgpu_types files
ygdrasil-io Mar 4, 2024
6eafa1f
Refactor webgpu types and improve error handling in scene rendering
ygdrasil-io Mar 5, 2024
1f84ca2
Implement auto-closeable context for easier resource management
ygdrasil-io Mar 5, 2024
70c70c0
Refactor RenderPassEncoder and implement draw methods
ygdrasil-io Mar 5, 2024
738c301
Add NSFont, NSLevelIndicator, AlertSheetReturnCodeMapper, NSEvent cla…
ygdrasil-io Mar 7, 2024
2773f7f
Commit message:
ygdrasil-io Mar 7, 2024
5354cea
Move several darwin related files from wgpu to librococoa
ygdrasil-io Mar 7, 2024
0f0cda4
Remove multiple wgpu example files and move build file to SDL2 directory
ygdrasil-io Mar 7, 2024
91dc029
Refactor wgpu examples and update build.gradle.kts in SDL2
ygdrasil-io Mar 7, 2024
c2faee6
Update pipeline parameters and enhance render loop frequency
ygdrasil-io Mar 7, 2024
789b3cf
Refactor RenderPipelineDescriptor conversions and update field types
ygdrasil-io Mar 8, 2024
79e7f9a
Add Buffer creation in the device and define usage
ygdrasil-io Mar 8, 2024
e3f4119
Update Buffer creation and usage definition in the Device
ygdrasil-io Mar 9, 2024
86bf288
Refactored Buffer creation and usage
ygdrasil-io Mar 9, 2024
4c66abf
Refactor Buffer usage and creation for better performance
ygdrasil-io Mar 10, 2024
6db632f
Refactor CommandEncoder and update RotatingCube scene
ygdrasil-io Mar 10, 2024
f17a775
Enable 'maxDrawCount' in CommandEncoder
ygdrasil-io Mar 10, 2024
77269a6
Add @JsExport annotation and update methods in wgpu bindings
ygdrasil-io Mar 10, 2024
2b80c83
Add main multi-file infrastructure to WebGPU samples
ygdrasil-io Mar 10, 2024
ce8eb5c
Refactor web-js examples and WebGPU samples
ygdrasil-io Mar 10, 2024
2ee91bf
Refactor Buffer's map function and simplify application handling
ygdrasil-io Mar 10, 2024
0d65b49
Refactor Resource descriptor and add TwoCubes example
ygdrasil-io Mar 10, 2024
43d833e
Refactor TwoCubes example to use new kotlin library
ygdrasil-io Mar 11, 2024
8a4b59d
Refactor cube scene attributes usage in examples
ygdrasil-io Mar 11, 2024
9554ebe
Updated shaders in TwoCubes and RotatingCube; added TexturedCube and …
ygdrasil-io Mar 11, 2024
a1a0b2c
Add createSampler function and support in BindGroup and Device
ygdrasil-io Mar 11, 2024
1ae814b
Some tweaks
ygdrasil-io Mar 11, 2024
d96d318
Implement new asset management system and image copying feature
ygdrasil-io Mar 11, 2024
e3906c0
Add InstancedCubeScene and update shader file locations
ygdrasil-io Mar 11, 2024
8dca8f2
Update transformation matrix method in InstancedCube
ygdrasil-io Mar 12, 2024
947b580
Add FractalCubeScene and enhance texture handling
ygdrasil-io Mar 12, 2024
921ceba
WIP Add CubemapScene and related Shader
ygdrasil-io Mar 12, 2024
cf1b669
Implement CubemapScene with related buffer and shader improvements
ygdrasil-io Mar 14, 2024
97d9fd6
Add GLFW support(WIP) and system detection functionality
ygdrasil-io Mar 14, 2024
a616012
Refactor and enhance GLFW support
ygdrasil-io Mar 14, 2024
a5f74d3
This commit includes a significant refactoring and enhancement of the…
ygdrasil-io Mar 14, 2024
bead729
Rename Device.kt to Device.js.kt and modify format conversion
ygdrasil-io Mar 14, 2024
7287dc7
Update methods and import in wgpu module and update asset manager in …
ygdrasil-io Mar 14, 2024
f7ca37e
Implement log callback functionality in GlfwMain
ygdrasil-io Mar 14, 2024
d99a6cd
Refactor TextureDescriptor conversion and WGPUTextureDescriptor struc…
ygdrasil-io Mar 15, 2024
677c832
Update BindGroupDescriptor and introduce new test class
ygdrasil-io Mar 15, 2024
8a12558
Refactor BindGroupDescriptor handling and add tests
ygdrasil-io Mar 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 7 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
java-version: 21
cache: 'gradle'
- name: Build and publish with Gradle
run: |
cd ./klang
./gradlew build publish --info
./gradlew publishAll --info
env:
VERSION: ${{ github.event.release.tag_name }}
URL: ${{ vars.GITLAB_URL }}
TOKEN: ${{ secrets.GITLAB_TOKEN }}
SONATYPE_LOGIN: ${{ secrets.SONATYPE_LOGIN }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
PGP_PUBLIC: ${{ secrets.PGP_PUBLIC }}
PGP_PRIVATE: ${{ secrets.PGP_PRIVATE }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}

17 changes: 14 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,35 @@ concurrency:
jobs:
tests:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
os: [macos-14, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: print architecture
run: uname -m
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
java-version: 21
cache: 'gradle'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build & test klang
- name: Build & test klang macos
if: matrix.os == 'macos-14'
run: |
cd ./klang
./gradlew test
- name: Build & test klang ubuntu
if: matrix.os == 'ubuntu-latest'
env:
LIBCLANG_PATH: "/usr/lib/llvm-15/lib/libclang-15.so.1"
run: |
cd ./klang
./gradlew test
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ gradle-app.setting
.classpath
/.idea/
/toolkit/*.log

# Ignore native libraries
*.dll
*.dylib
*.so
*.jar
26 changes: 0 additions & 26 deletions .run/generate binding.run.xml

This file was deleted.

31 changes: 0 additions & 31 deletions .run/run integration test.run.xml

This file was deleted.

43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,42 @@
Experimental toolkit to auto generate binding from C/C++/Objective C library to Kotlin
# Klang Toolkit

*Experimental toolkit to generate bindings from C/C++/Objective-C library to Kotlin using Clang.*

## Status Overview

Currently, we are in the experimental phase of parsing headers. We have two main approaches:

### Approach 1: Standalone LibClang 15 Library

- **Advantages**
- More accurate header parsing.
- **Disadvantages**
- LibClang is part of the LLVM toolchain.

### Approach 2: Clang 15 from Docker for JSON AST Generation

- **Advantages**
- Easier to use.
- **Disadvantages**
- Limited information on JSON AST.
- Requires Docker on host for JSON AST generation.
- Hard to use OS-specific headers.

We can generate a good enough binding with JNA on a C library. Check the `bindings` folder for examples.

## Known Issues

Currently, with Gradle, the native library is loaded multiple times on the daemon. Therefore, the Klang plugin does not
support the Gradle daemon.

## Additional Information

The `Jextract` code is embedded almost as is, and the license may differ from Klang toolkit.

This project embeds C headers from different sources; namely:

1. `/klang/src/main/resource/darwin-headers.zip` is obtained from XCode. Refer to `/usr/bin/xcrun --show-sdk-path`.
2. `/klang/src/main/resource/c-headers.zip` is obtained from Clang 15 headers.

Clang dynamic libraries (version 15) are embedded. These are fetched
from [prebuilt version on GitHub](https://github.com/klang-toolkit/libclang-binary/releases/tag/15).
34 changes: 34 additions & 0 deletions bindings/angle/binaries/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import org.jetbrains.kotlin.de.undercouch.gradle.tasks.download.Download

plugins {
kotlin("jvm") version libs.versions.kotlin
`maven-publish`
}

publishing {
publications {
create<MavenPublication>("mavenJava") { from(components["java"]) }
}
}
version = "chrome-122.0.6261"

val directory = project.file("src/main/resources")
val baseUrl = "https://github.com/klang-toolkit/ANGLE-binary/releases/download/$version/"
val fileToDownload = listOf(
"libEGL.dylib" to directory.resolve("darwin").resolve("libEGL.dylib"),
"libGLESv2.dylib" to directory.resolve("darwin").resolve("libGLESv2.dylib"),
"libEGL.dll" to directory.resolve("win32").resolve("libEGL.dylib"),
"libGLESv2.dll" to directory.resolve("win32").resolve("libGLESv2.dylib"),
).forEach { (fileName, target) ->
val url = "$baseUrl$fileName"
val taskName = "downloadFile-$fileName"
tasks.register<Download>(taskName) {
onlyIf { !target.exists() }
src(url)
dest(target)
}

tasks.named("processResources") {
dependsOn(taskName)
}
}
47 changes: 46 additions & 1 deletion bindings/angle/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,59 @@

plugins {
kotlin("jvm") version libs.versions.kotlin
id("com.gradle.plugin-publish") version "1.0.0"
}

repositories {
mavenCentral()
}

group = "io.ygdrasil"
version = "1.0.0-SNAPSHOT"

allprojects {
subprojects {
apply(plugin = "maven-publish")
apply(plugin = "org.jetbrains.kotlin.jvm")

repositories {
mavenCentral()
}

group = "io.ygdrasil"
version = "1.0.0-SNAPSHOT"

publishing {

publications {
create<MavenPublication>("maven") {
from(components["java"])

pom {
name = "Klang-${project.name}"
description = "Angle binding"
url = "https://ygdrasil.io/"
licenses {
license {
name = "MIT"
url = "https://opensource.org/license/mit/"
}
}
developers {
developer {
id = "alexandremo"
name = "Alexandre Mommers"
email = "alexandre dot mommers at gmail do com"
}
}
scm {
connection = "scm:git:git://github.com/ygdrasil-io/klang.git"
developerConnection = "scm:git:ssh//[email protected]:ygdrasil-io/klang.git"
url = "https://github.com/ygdrasil-io/klang"
}
}
}
}
}
}


2 changes: 1 addition & 1 deletion bindings/angle/example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

plugins {
kotlin("jvm") version "1.9.10"
kotlin("jvm") version libs.versions.kotlin
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ class HelloTriangle : SampleApplication("HelloTriangle") {
libGLESv2Library.glViewport(0, 0, window.width, window.height)

// Clear the color buffer
libGLESv2Library.glClear(GL_COLOR_BUFFER_BIT)
libGLESv2Library.glClear(GL_COLOR_BUFFER_BIT.toInt())

// Use the program object
libGLESv2Library.glUseProgram(mProgram)

// Load the vertex data
libGLESv2Library.glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE.toByte(), 0, verticesBuffer)
libGLESv2Library.glVertexAttribPointer(0, 3, GL_FLOAT.toInt(), GL_FALSE.toByte(), 0, verticesBuffer)
libGLESv2Library.glEnableVertexAttribArray(0)

libGLESv2Library.glDrawArrays(GL_TRIANGLES, 0, 3)
libGLESv2Library.glDrawArrays(GL_TRIANGLES.toInt(), 0, 3)
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
package example.toolkit

import libangle.EGL_DONT_CARE
import libangle.EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE
import libangle.EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE
import libangle.Feature
import libangle.*
import java.util.*

class PlatformMethods

class EGLPlatformParameters {
var renderer: Int = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE
var majorVersion: Int = EGL_DONT_CARE
var minorVersion: Int = EGL_DONT_CARE
var majorVersion: Int = EGL_DONT_CARE.toInt()
var minorVersion: Int = EGL_DONT_CARE.toInt()
var deviceType: Int = EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE
var presentPath: Int = EGL_DONT_CARE
var debugLayersEnabled: Int = EGL_DONT_CARE
var robustness: Int = EGL_DONT_CARE
var displayPowerPreference: Int = EGL_DONT_CARE
var presentPath: Int = EGL_DONT_CARE.toInt()
var debugLayersEnabled: Int = EGL_DONT_CARE.toInt()
var robustness: Int = EGL_DONT_CARE.toInt()
var displayPowerPreference: Int = EGL_DONT_CARE.toInt()
var enabledFeatureOverrides: MutableList<Feature> = ArrayList()
var disabledFeatureOverrides: MutableList<Feature> = ArrayList()
var platformMethods: PlatformMethods? = null

constructor() // Constructor por defecto

constructor(renderer: Int) {
this.renderer = renderer
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,7 @@ class EGLWindow(window: OSWindow) {
}

fun initializeDisplay(osWindow: OSWindow, glWindowingLibrary: Library, driverType: GLESDriverType, params: EGLPlatformParameters): Boolean {
if (driverType == GLESDriverType.ZinkEGL) {
val driDirStream = StringBuilder()
val s = GetPathSeparator()
driDirStream.append(GetModuleDirectory()).append("mesa").append(s).append("src").append(s).append("gallium").append(s).append("targets").append(s).append("dri")

val driDir = driDirStream.toString()

SetEnvironmentVar("MESA_LOADER_DRIVER_OVERRIDE", "zink")
SetEnvironmentVar("LIBGL_DRIVERS_PATH", driDir)
}

if (ANGLE_USE_UTIL_LOADER) {
var getProcAddress: PFNEGLGETPROCADDRESSPROC
glWindowingLibrary.getAs("eglGetProcAddress", getProcAddress)
if (getProcAddress == null) {
println("Cannot load eglGetProcAddress")
return false
}

// Likely we will need to use a fallback to Library::getAs on non-ANGLE platforms.
LoadUtilEGL(getProcAddress)
}

// EGL_NO_DISPLAY + EGL_EXTENSIONS returns NULL before Android 10
val extensionString = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS) as String?
Expand Down Expand Up @@ -210,7 +189,6 @@ enum class GLESDriverType {
AngleVulkanSecondariesEGL,
SystemEGL,
SystemWGL,
ZinkEGL,
}

enum class GLWindowResult {
Expand Down
Loading
Loading