diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df09845..2e9645e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,44 +13,87 @@ env: jobs: build-linux: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest + container: + image: electronstudio/ubuntu16-modern:latest + options: --user root + volumes: + # override /__e/node20 because GitHub Actions uses a version that requires too-recent glibc + - /tmp:/__e/node20 + steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: fix node + run: | + ln -s /usr/local/bin /__e/node20/bin + - uses: actions/checkout@v2 with: submodules: recursive - - uses: actions/setup-java@v2 + - name: Build raylib + run: | + cd raylib + mkdir build + cd build + cmake -DBUILD_EXAMPLES=OFF -DCUSTOMIZE_BUILD=ON -DSUPPORT_FILEFORMAT_JPG=ON -DSUPPORT_FILEFORMAT_FLAC=ON -DWITH_PIC=ON -DCMAKE_BUILD_TYPE=Release .. + make -j2 + make install + + - name: Build jaylib + env: + RAYLIB_PLATFORM: linux-x86_64 + run: | + ./build-java.sh + ./build-native.sh + ./build-docs.sh + + - name: Upload jar + uses: actions/upload-artifact@v4 with: - distribution: 'adopt' # See 'Supported distributions' for available options - java-version: '8' + name: jaylib-linux-x86_64 + path: ./jaylib*.jar + + build-linux-32bit: + runs-on: ubuntu-latest + container: + image: electronstudio/ubuntu16-modern:i386 + options: --user root + volumes: + # override /__e/node20 because GitHub Actions uses a version that requires too-recent glibc + - /tmp:/__e/node20 + steps: + - name: fix node + run: | + ln -s /usr/local/bin /__e/node20/bin + + - uses: actions/checkout@v2 + with: + submodules: recursive - name: Build raylib run: | - sudo apt update - sudo apt install libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev libwayland-dev libxkbcommon-dev cd raylib mkdir build cd build - cmake -DBUILD_EXAMPLES=OFF -DCUSTOMIZE_BUILD=ON -DSUPPORT_FILEFORMAT_JPG=ON -DSUPPORT_FILEFORMAT_FLAC=ON -DWITH_PIC=ON -DCMAKE_BUILD_TYPE=Release .. + cmake -DBUILD_EXAMPLES=OFF -DCUSTOMIZE_BUILD=ON -DOPENGL_VERSION=2.1 -DSUPPORT_FILEFORMAT_JPG=ON -DSUPPORT_FILEFORMAT_FLAC=ON -DWITH_PIC=ON -DCMAKE_BUILD_TYPE=Release .. make -j2 - sudo make install + make install - name: Build jaylib env: - RAYLIB_PLATFORM: linux-x86_64 + RAYLIB_PLATFORM: linux-x86 run: | ./build-java.sh ./build-native.sh ./build-docs.sh - name: Upload jar - uses: actions/upload-artifact@v3.2.1 + uses: actions/upload-artifact@v4 with: - name: jar - path: ./*.jar + name: jaylib-linux-x86 + path: ./jaylib-natives*.jar # build-linux-arm: # runs-on: rpi @@ -121,13 +164,13 @@ jobs: ./build-native.sh - name: Upload jar - uses: actions/upload-artifact@v3.2.1 + uses: actions/upload-artifact@v4 with: - name: jar + name: jaylib-macosx-x86_64 path: ./*macosx-x86_64*.jar build-windows: - runs-on: windows-2019 + runs-on: windows-2022 steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it @@ -164,13 +207,13 @@ jobs: shell: cmd - name: Upload jar - uses: actions/upload-artifact@v3.2.1 + uses: actions/upload-artifact@v4 with: - name: jar - path: ./*.jar + name: jaylib-windows-x86_64 + path: ./jaylib-natives*.jar build-windows32: - runs-on: windows-2019 + runs-on: windows-2022 steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it @@ -212,7 +255,24 @@ jobs: shell: cmd - name: Upload jar - uses: actions/upload-artifact@v3.2.1 + uses: actions/upload-artifact@v4 + with: + name: jaylib-windows-x86 + path: ./jaylib-natives*.jar + + merge-artifacts: + runs-on: ubuntu-latest + needs: [build-linux, build-linux-32bit, build-mac, build-windows, build-windows32] + + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + merge-multiple: true + + - name: Upload merged artifact + uses: actions/upload-artifact@v4 with: - name: jar - path: ./*.jar \ No newline at end of file + name: jaylib-all-platforms + path: artifacts/ \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..3d97606 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,91 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project Overview + +Jaylib is a Java Native Interface (JNI) binding library for Raylib 5.5, providing Java developers with access to the popular C game development library. The project uses JavaCPP to automatically generate JNI bindings from the native Raylib headers. + +## Build System and Commands + +### Primary Build Commands +- `./build-java.sh` - Main Java compilation and JAR creation (requires `RAYLIB_VERSION` environment variable) +- `./build-linux.sh` - Linux platform-specific build +- `./build-windows.sh` - Windows platform build (requires Visual Studio environment) +- `./build-native.sh` - Native library compilation + +### Testing +- `./run-test.sh` - Run the basic functionality test (requires `RAYLIB_PLATFORM` environment variable) +- `./run-test-jar.sh` - Run tests using the compiled JAR + +### Documentation +- `./build-docs.sh` - Generate Javadoc documentation + +### Environment Variables Required +- `RAYLIB_VERSION` - Version string for builds (e.g., "5.5.0-0") +- `RAYLIB_PLATFORM` - Platform identifier (e.g., "linux-x86_64", "windows-x86_64", "macosx-x86_64") + +## Architecture and Key Components + +### Core Structure +- **JavaCPP Integration**: Uses `javacpp.jar` and JavaCPP annotations in `RaylibConfig.java` to automatically generate JNI bindings +- **Multi-stage Build Process**: + 1. Generate Java bindings from C headers using JavaCPP + 2. Compile native code with platform-specific linkers + 3. Package everything into distributable JARs + +### Key Source Files +- `src/com/raylib/RaylibConfig.java` - JavaCPP configuration defining platform-specific linking and header includes +- `src/com/raylib/Raylib.java` - Auto-generated main binding class (created during build) +- `src/com/raylib/Colors.java` - Predefined color constants (RAYWHITE, BLACK, etc.) +- `src/com/raylib/Helpers.java` - Alternative constructor methods for structs +- `src/com/raylib/Test.java` - Basic functionality test and demo + +### Native Headers +The project includes Raylib C header files: +- `raylib.h` - Core Raylib API +- `rlgl.h` - OpenGL abstraction layer +- `raymath.h` - Math utility functions +- `physac.h` - Physics simulation +- `raygui.h` - Immediate mode GUI + +### Platform Support +Configured for cross-platform builds supporting: +- Windows x86_64 +- macOS x86_64 and ARM64 +- Linux x86_64 and ARM64 + +## JavaCPP Binding Specifics + +### Field Access Pattern +- Getters: `vector.x()` returns the x field value +- Setters: `vector.x(3)` sets the x field to 3 +- Position field renamed to `_position` due to JavaCPP's internal position field + +### Struct Initialization +JavaCPP uses fluent constructor syntax: +```java +var vec = new Vector3().x(1).y(2).z(3); +``` +Alternative constructors available in `Helpers.java`: +```java +var vec = Helpers.createVector3(1, 2, 3); +``` + +### Array Access +C arrays are not Java arrays - use position() method: +```java +model.materials().position(1).maps().position(2) // Second map of first material +``` + +## Build Dependencies +- Java 8+ (JDK required for compilation) +- Platform-specific C++ compiler (GCC on Linux, Visual Studio on Windows, Xcode on macOS) +- JavaCPP tool (included as `javacpp.jar`) +- Raylib native library (included as git submodule) + +## macOS Specific Requirements +When running Java applications on macOS, use the `-XstartOnFirstThread` JVM option: +```bash +java -XstartOnFirstThread -cp jaylib.jar:. MyGame +``` \ No newline at end of file