From 6d4cee58c90eeea63c280870a924c830443f6725 Mon Sep 17 00:00:00 2001 From: akki <151368291+akki697222@users.noreply.github.com> Date: Thu, 15 Oct 2026 17:50:35 +0900 Subject: [PATCH 1/4] Maven: build JNI libraries for the host platform via OS-activated profiles - Root pom: six host-* profiles (Linux, Windows, macOS x x86_64, aarch64), activated from os.name/os.arch. Each sets native.rust.target, native.libdir (jar-jni folder) and native.lib.ext. - shuttle-java: the five cross/host profiles are replaced by one cargo build + copy step driven by those properties. No cross or Docker needed; macOS is now supported. - shuttle-wit-parser: same properties, so its library is copied on every platform (it was Linux x86_64 only, so its tests failed on Windows). - WitParserTest.throwsOnUnknownFile compares with the platform's own path spelling (backslashes on Windows). All five modules' tests pass on Windows without -P. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/maven.yml | 55 --- .github/workflows/native.yml | 59 --- pom.xml | 91 ++++ shuttle-java/pom.xml | 429 +++--------------- shuttle-wit-parser/pom.xml | 25 +- .../shuttle/wit/parser/WitParserTest.java | 6 +- 6 files changed, 161 insertions(+), 504 deletions(-) delete mode 100644 .github/workflows/maven.yml delete mode 100644 .github/workflows/native.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml deleted file mode 100644 index 601b405..0000000 --- a/.github/workflows/maven.yml +++ /dev/null @@ -1,55 +0,0 @@ -# Builds the Maven reactor (shuttle-java, the example and the WIT tooling) -# and runs its tests. -# -# - linux: native libraries for Linux x86_64 and aarch64 via `cross`; all modules. -# - windows: native library built on the host (MSVC); shuttle-java and the example -# only, because shuttle-wit-parser has no Windows native library yet. -# -# setup-rust-toolchain sets RUSTFLAGS=-D warnings, so Rust warnings fail the build. - -name: Java CI with Maven - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - linux: - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - target: wasm32-unknown-unknown # for the valuetest fixture - - uses: actions/checkout@v5 - - name: Set up JDK 21 - uses: actions/setup-java@v5 - with: - java-version: "21" - distribution: temurin - cache: maven - - name: Install cargo cross - run: cargo install cross - - name: Build with Maven - run: mvn -P build-linux-x86-64,build-linux-aarch64 -Dcargo.profile=release -Dcargo.profile.folder=release -B package --file pom.xml - - windows: - runs-on: windows-latest - timeout-minutes: 30 - steps: - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - target: wasm32-unknown-unknown # for the valuetest fixture - - uses: actions/checkout@v5 - - name: Set up JDK 21 - uses: actions/setup-java@v5 - with: - java-version: "21" - distribution: temurin - cache: maven - - name: Build with Maven - # bash, not PowerShell: PowerShell splits -Dcargo.profile=release at the dot - shell: bash - run: mvn -P build-host-windows-x86_64 -pl shuttle-java,shuttle-java-example -am -Dcargo.profile=release -Dcargo.profile.folder=release -B package --file pom.xml diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml deleted file mode 100644 index e4be225..0000000 --- a/.github/workflows/native.yml +++ /dev/null @@ -1,59 +0,0 @@ -# Builds the Shuttle native workspace (native/) on all six target platforms -# and runs the capture/restore verification on each. -name: Native (Shuttle) - -on: - push: - branches: [main] - paths: ["native/**", ".github/workflows/native.yml"] - pull_request: - paths: ["native/**", ".github/workflows/native.yml"] - workflow_dispatch: - -jobs: - # The C guests are plain wasm32 and identical everywhere: build them once. - guests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v5 - - name: Install clang and lld - run: sudo apt-get update && sudo apt-get install -y clang lld - - name: Build guests - run: sh native/guests/build.sh - - uses: actions/upload-artifact@v4 - with: - name: guests - path: native/guests/out/*.wasm - - build: - needs: guests - strategy: - fail-fast: false - matrix: - include: - - { name: linux-x86_64, os: ubuntu-latest } - - { name: linux-aarch64, os: ubuntu-24.04-arm } - - { name: windows-x86_64, os: windows-latest } - - { name: windows-aarch64, os: windows-11-arm } - - { name: macos-x86_64, os: macos-15-intel } - - { name: macos-aarch64, os: macos-latest } - name: build (${{ matrix.name }}) - runs-on: ${{ matrix.os }} - defaults: - run: - shell: bash - working-directory: native - steps: - - uses: actions/checkout@v5 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - cache-workspaces: native - rustflags: "" - - uses: actions/download-artifact@v4 - with: - name: guests - path: native/guests/out - - name: Build - run: cargo build --locked --release - - name: Verify capture/restore - run: ./target/release/shuttle-runner verify guests/out/bios.wasm guests/out/os.wasm guests/out/child.wasm diff --git a/pom.xml b/pom.xml index b0f9f54..ba48c61 100644 --- a/pom.xml +++ b/pom.xml @@ -147,6 +147,97 @@ + + + host-linux-x86-64 + + + linux + amd64 + + + + x86_64-unknown-linux-gnu + linux-x86-64 + so + + + + host-linux-aarch64 + + + linux + aarch64 + + + + aarch64-unknown-linux-gnu + linux-aarch64 + so + + + + host-windows-x86-64 + + + windows + amd64 + + + + x86_64-pc-windows-msvc + win32-x86-64 + dll + + + + host-windows-aarch64 + + + windows + aarch64 + + + + aarch64-pc-windows-msvc + win32-aarch64 + dll + + + + host-macos-x86-64 + + + mac + x86_64 + + + + x86_64-apple-darwin + darwin-x86-64 + dylib + + + + host-macos-aarch64 + + + mac + aarch64 + + + + aarch64-apple-darwin + darwin-aarch64 + dylib + + + release diff --git a/shuttle-java/pom.xml b/shuttle-java/pom.xml index 58f3ece..f3a399e 100644 --- a/shuttle-java/pom.xml +++ b/shuttle-java/pom.xml @@ -68,10 +68,32 @@ exec-maven-plugin 3.2.0 - - - - + + + build wasmtime-binding + + exec + + compile + + cargo + ${project.basedir}/src/main/rust/wasmtime-binding + + build + --profile + ${cargo.profile} + --target + ${native.rust.target} + --target-dir + ${project.build.directory}/rust + + + stable + + + build wasm test valuetest @@ -101,378 +123,35 @@ + + maven-resources-plugin + 3.3.1 + + + + copy wasmtime-binding + compile + + copy-resources + + + ${project.build.directory}/classes/jp/akkiserver/shuttle/libs/${native.libdir} + + + ${project.build.directory}/rust/${native.rust.target}/${cargo.profile.folder} + false + + *.${native.lib.ext} + + + + + + + + - - - - - build-linux-x86-64 - - - build-linux-x86-64 - true - - true - - - - - org.codehaus.mojo - exec-maven-plugin - 3.2.0 - - - - build linux x86 64 bit - - exec - - compile - - cross - - ${project.basedir}/src/main/rust/wasmtime-binding - - build - --profile - ${cargo.profile} - --target - x86_64-unknown-linux-gnu - --target-dir - ${project.build.directory}/rust - - - stable - - - - - - - - maven-resources-plugin - 3.3.1 - - - - - copy-lib-linux-x86-64 - compile - - copy-resources - - - - ${project.build.directory}/classes/jp/akkiserver/shuttle/libs/linux-x86-64 - - - - ${project.build.directory}/rust/x86_64-unknown-linux-gnu/${cargo.profile.folder} - false - - *.so - - - - - - - - - - - - - - build-linux-aarch64 - - - build-linux-aarch64 - true - - - - - - org.codehaus.mojo - exec-maven-plugin - 3.2.0 - - - - build linux ARM64 bit - - exec - - compile - - cross - - ${project.basedir}/src/main/rust/wasmtime-binding - - build - --profile - ${cargo.profile} - --target - aarch64-unknown-linux-gnu - --target-dir - ${project.build.directory}/rust - - - stable - - - - - - - - maven-resources-plugin - 3.3.1 - - - copy-lib-linux-aarch64 - compile - - copy-resources - - - - ${project.build.directory}/classes/jp/akkiserver/shuttle/libs/linux-aarch64 - - - - ${project.build.directory}/rust/aarch64-unknown-linux-gnu/${cargo.profile.folder} - false - - *.so - - - - - - - - - - - - - - build-windows-x86_64 - - - build-windows-x86_64 - true - - - - - - org.codehaus.mojo - exec-maven-plugin - 3.2.0 - - - build windows x86 64 bit - - exec - - compile - - cross - ${project.basedir}/src/main/rust/wasmtime-binding - - build - --profile - ${cargo.profile} - --target - x86_64-pc-windows-msvc - --target-dir - ${project.build.directory}/rust - - - stable - - - - - - - - maven-resources-plugin - 3.3.1 - - - copy-lib-windows-x86-64 - compile - - copy-resources - - - ${project.build.directory}/classes/jp/akkiserver/shuttle/libs/win32-x86-64 - - - ${project.build.directory}/rust/x86_64-pc-windows-msvc/${cargo.profile.folder} - false - - *.dll - - - - - - - - - - - - - - build-host-windows-x86_64 - - - build-host-windows-x86_64 - true - - - - - - org.codehaus.mojo - exec-maven-plugin - 3.2.0 - - - build host windows x86 64 bit - - exec - - compile - - cargo - ${project.basedir}/src/main/rust/wasmtime-binding - - build - --profile - ${cargo.profile} - --target - x86_64-pc-windows-msvc - --target-dir - ${project.build.directory}/rust - - - stable - - - - - - - - maven-resources-plugin - 3.3.1 - - - copy-lib-host-windows-x86-64 - compile - - copy-resources - - - ${project.build.directory}/classes/jp/akkiserver/shuttle/libs/win32-x86-64 - - - ${project.build.directory}/rust/x86_64-pc-windows-msvc/${cargo.profile.folder} - false - - *.dll - - - - - - - - - - - - - build-windows-aarch64 - - - build-windows-aarch64 - true - - - - - - org.codehaus.mojo - exec-maven-plugin - 3.2.0 - - - build windows aarch64 - - exec - - compile - - cross - ${project.basedir}/src/main/rust/wasmtime-binding - - build - --profile - ${cargo.profile} - --target - aarch64-pc-windows-msvc - --target-dir - ${project.build.directory}/rust - - - stable - - - - - - - - maven-resources-plugin - 3.3.1 - - - copy-lib-windows-aarch64 - compile - - copy-resources - - - ${project.build.directory}/classes/jp/akkiserver/shuttle/libs/win32-aarch64 - - - ${project.build.directory}/rust/aarch64-pc-windows-msvc/${cargo.profile.folder} - false - - *.dll - - - - - - - - - - - \ No newline at end of file diff --git a/shuttle-wit-parser/pom.xml b/shuttle-wit-parser/pom.xml index a10c212..5740bfb 100644 --- a/shuttle-wit-parser/pom.xml +++ b/shuttle-wit-parser/pom.xml @@ -50,11 +50,10 @@ exec-maven-plugin 3.2.0 - + build wit-parser-binding @@ -69,6 +68,8 @@ build --profile ${cargo.profile} + --target + ${native.rust.target} --target-dir ${project.build.directory}/rust @@ -84,26 +85,24 @@ maven-resources-plugin 3.3.1 - + - copy-lib-linux-x86-64 + copy wit-parser-binding compile copy-resources - ${project.build.directory}/classes/jp/akkiserver/shuttle/wit/parser/libs/linux-x86-64 + ${project.build.directory}/classes/jp/akkiserver/shuttle/wit/parser/libs/${native.libdir} - ${project.build.directory}/rust/${cargo.profile.folder} + ${project.build.directory}/rust/${native.rust.target}/${cargo.profile.folder} false - *.so + *.${native.lib.ext} diff --git a/shuttle-wit-parser/src/test/java/jp/akkiserver/shuttle/wit/parser/WitParserTest.java b/shuttle-wit-parser/src/test/java/jp/akkiserver/shuttle/wit/parser/WitParserTest.java index 8d0c115..4e84a13 100644 --- a/shuttle-wit-parser/src/test/java/jp/akkiserver/shuttle/wit/parser/WitParserTest.java +++ b/shuttle-wit-parser/src/test/java/jp/akkiserver/shuttle/wit/parser/WitParserTest.java @@ -44,9 +44,11 @@ void parsesGreetInterface() throws IOException { @Test void throwsOnUnknownFile() { + // Compare with the platform's own spelling of the path (backslashes on Windows). + Path missing = Path.of("/no/such/file.wit"); assertTrue(org.junit.jupiter.api.Assertions.assertThrows(RuntimeException.class, - () -> WitParser.parse(Path.of("/no/such/file.wit"))).getMessage() - .contains("no/such/file.wit")); + () -> WitParser.parse(missing)).getMessage() + .contains(missing.toString())); } /** From e435779edcc0e7bae283d5be7dcc11319ba86d89 Mon Sep 17 00:00:00 2001 From: akki <151368291+akki697222@users.noreply.github.com> Date: Thu, 15 Oct 2026 17:50:35 +0900 Subject: [PATCH 2/4] CI: merge native.yml and maven.yml into one build-only ci.yml Jobs: guests, native x6 and java x6 on GitHub-hosted runners for Linux, Windows and macOS (x86_64 and arm64). CI only builds (no tests, no shuttle-runner verify); tests run on the developer machine. Runs on push to main, every PR and manual dispatch. Rust warnings are errors in both builds. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 85 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c1517d0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,85 @@ +# Builds everything on all six target platforms. CI only builds; tests are run +# on the developer machine. +# +# - guests: the C test guests (wasm32, identical everywhere), built once +# - native: the native/ Cargo workspace (shuttle-core, shuttle-runner) +# - java: the Maven reactor; each runner builds the JNI libraries for its own +# platform through the host-* profile the root pom activates +# +# setup-rust-toolchain sets RUSTFLAGS=-D warnings, so Rust warnings fail the build. + +name: CI + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +jobs: + guests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Install clang and lld + run: sudo apt-get update && sudo apt-get install -y clang lld + - name: Build guests + run: sh native/guests/build.sh + + native: + strategy: + fail-fast: false + matrix: + include: + - { name: linux-x86_64, os: ubuntu-latest } + - { name: linux-aarch64, os: ubuntu-24.04-arm } + - { name: windows-x86_64, os: windows-latest } + - { name: windows-aarch64, os: windows-11-arm } + - { name: macos-x86_64, os: macos-15-intel } + - { name: macos-aarch64, os: macos-latest } + name: native (${{ matrix.name }}) + runs-on: ${{ matrix.os }} + timeout-minutes: 30 + defaults: + run: + shell: bash + working-directory: native + steps: + - uses: actions/checkout@v5 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + cache-workspaces: native + - name: Build + run: cargo build --locked --release + + java: + strategy: + fail-fast: false + matrix: + include: + - { name: linux-x86_64, os: ubuntu-latest } + - { name: linux-aarch64, os: ubuntu-24.04-arm } + - { name: windows-x86_64, os: windows-latest } + - { name: windows-aarch64, os: windows-11-arm } + - { name: macos-x86_64, os: macos-15-intel } + - { name: macos-aarch64, os: macos-latest } + name: java (${{ matrix.name }}) + runs-on: ${{ matrix.os }} + timeout-minutes: 45 + defaults: + run: + # bash on every OS: PowerShell would split -Dcargo.profile=release at the dot + shell: bash + steps: + - uses: actions/checkout@v5 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + target: wasm32-unknown-unknown # the valuetest fixture is built even with -DskipTests + - name: Set up JDK 21 + uses: actions/setup-java@v5 + with: + java-version: "21" + distribution: temurin + cache: maven + - name: Build with Maven + run: mvn -B -DskipTests -Dcargo.profile=release -Dcargo.profile.folder=release package From de7c502ffffd050975987d38851df58f75563fa1 Mon Sep 17 00:00:00 2001 From: akki <151368291+akki697222@users.noreply.github.com> Date: Thu, 15 Oct 2026 17:50:35 +0900 Subject: [PATCH 3/4] Docs: host profiles and unified CI; HANDOFF and CLAUDE.md decisions building.md documents the host-* profiles, platform-independent Maven commands and ci.yml; fixed known issues are removed from building.md and wit-codegen.md. README badge and quick start, native/README.md, CLAUDE.md and HANDOFF (state, decisions, known issues, next steps) updated. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 7 ++-- README.md | 10 +++--- docs/building.md | 81 ++++++++++++++++++++------------------------- docs/wit-codegen.md | 7 +--- native/HANDOFF.md | 62 +++++++++++++++++++++------------- native/README.md | 6 ++-- 6 files changed, 89 insertions(+), 84 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 631e4cf..4021ab4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -51,8 +51,11 @@ will include it by default. Current status and open decisions: - Maven: there is no `mvn` on PATH. Use IntelliJ's bundled Maven, `%LOCALAPPDATA%\Programs\IntelliJ IDEA\plugins\maven-plugin\lib\maven3\bin\mvn.cmd`, with `JAVA_HOME=%USERPROFILE%\.jdks\temurin-25.0.4` (the global - `JAVA_HOME` points at `bin\` and is wrong), and the profile - `-P build-host-windows-x86_64`. The default profile uses cross + Docker. + `JAVA_HOME` points at `bin\` and is wrong). No `-P` is needed: the root + pom activates the `host-windows-x86-64` profile automatically. Quote + `-D...` arguments in PowerShell (`"-Dcargo.profile=release"`). +- Tests run on this machine only; CI (`.github/workflows/ci.yml`) only builds, + on six platforms. - JNI class names are also written as strings in Rust (`java_type = "..."`). After renaming Java classes or packages, grep the `.rs` files and run the tests: a wrong name compiles but fails at run time. diff --git a/README.md b/README.md index d50efd2..44503a3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Native (Shuttle)](https://github.com/akkiserver-dev/shuttle/actions/workflows/native.yml/badge.svg)](https://github.com/akkiserver-dev/shuttle/actions/workflows/native.yml) +[![CI](https://github.com/akkiserver-dev/shuttle/actions/workflows/ci.yml/badge.svg)](https://github.com/akkiserver-dev/shuttle/actions/workflows/ci.yml) # Shuttle @@ -49,14 +49,14 @@ Native core (requires Rust, plus clang and wasm-ld for the C guests): `verify` boots BIOS → OS → child, then repeats the run with capture → restore into a fresh machine at every tick boundary and checks that the logs are identical. -Java bindings on Windows (requires JDK 21, Maven and Rust; no Docker): +Java bindings (requires JDK 21, Maven and Rust; Maven picks the native build for your OS and CPU automatically): -```powershell -mvn -P build-host-windows-x86_64 -pl shuttle-java,shuttle-java-example -am install +```sh +mvn -pl shuttle-java,shuttle-java-example -am install mvn -pl shuttle-java-example exec:java ``` -The second command runs the Weave example. Linux builds, the other Maven profiles, CI and known problems are covered in [docs/building.md](docs/building.md). +The second command runs the Weave example. Platform profiles, CI and known problems are covered in [docs/building.md](docs/building.md). ## Documentation diff --git a/docs/building.md b/docs/building.md index 710d10d..5b25e80 100644 --- a/docs/building.md +++ b/docs/building.md @@ -15,7 +15,7 @@ Neither build depends on the other. | clang + wasm-ld | the C guests in `native/guests`. Windows: the [LLVM installer](https://github.com/llvm/llvm-project/releases). Linux/WSL2: `sudo apt install clang lld` | | JDK 21 and Maven | the Maven reactor (`maven.compiler.release` is 21) | | Rust target `wasm32-unknown-unknown` | the `shuttle-java` tests (the `valuetest` fixture is built for it): `rustup target add wasm32-unknown-unknown` | -| [cross](https://github.com/cross-rs/cross) + Docker | only the Maven profiles that cross-compile (see below), and `build.sh --cross` | +| [cross](https://github.com/cross-rs/cross) + Docker | only `native/scripts/build.sh --cross` (the Maven build does not use it) | ## Native core (`native/`) @@ -63,23 +63,30 @@ The results of the last measured run are in [native/README.md](../native/README. ## Maven reactor -### Profiles +### Host platform profiles -The native library of `shuttle-java` (`wasmtime-binding`, built as `wasmtimebinding`) is compiled during the `compile` phase by a profile, and copied into the jar under `jp/akkiserver/shuttle/libs//`, where [jar-jni](https://github.com/questdb/jar-jni) finds it at runtime. Profiles defined in [`shuttle-java/pom.xml`](../shuttle-java/pom.xml): +The two JNI libraries, `wasmtimebinding` (in `shuttle-java`) and `witparserbinding` (in `shuttle-wit-parser`), are built with plain `cargo` during the `compile` phase, for the platform Maven runs on. They are copied into the jar under `.../libs//`, where [jar-jni](https://github.com/questdb/jar-jni) finds them at runtime. -| Profile | Rust target | Built with | Jar folder | +The root [`pom.xml`](../pom.xml) has one profile per platform. Maven activates the right one automatically from the JVM's `os.name` / `os.arch`, so no `-P` is needed: + +| Profile | Rust target | Jar folder | Library | | --- | --- | --- | --- | -| `build-linux-x86-64` (**active by default**) | `x86_64-unknown-linux-gnu` | `cross` (Docker) | `linux-x86-64` | -| `build-linux-aarch64` | `aarch64-unknown-linux-gnu` | `cross` (Docker) | `linux-aarch64` | -| `build-windows-x86_64` | `x86_64-pc-windows-msvc` | `cross` (Docker) | `win32-x86-64` | -| `build-windows-aarch64` | `aarch64-pc-windows-msvc` | `cross` (Docker) | `win32-aarch64` | -| `build-host-windows-x86_64` | `x86_64-pc-windows-msvc` | local `cargo` (no Docker) | `win32-x86-64` | +| `host-linux-x86-64` | `x86_64-unknown-linux-gnu` | `linux-x86-64` | `.so` | +| `host-linux-aarch64` | `aarch64-unknown-linux-gnu` | `linux-aarch64` | `.so` | +| `host-windows-x86-64` | `x86_64-pc-windows-msvc` | `win32-x86-64` | `.dll` | +| `host-windows-aarch64` | `aarch64-pc-windows-msvc` | `win32-aarch64` | `.dll` | +| `host-macos-x86-64` | `x86_64-apple-darwin` | `darwin-x86-64` | `.dylib` | +| `host-macos-aarch64` | `aarch64-apple-darwin` | `darwin-aarch64` | `.dylib` | + +Each profile only sets three properties (`native.rust.target`, `native.libdir`, `native.lib.ext`); the cargo and copy steps are written once in each module's `pom.xml`. Check which profile is active with: -There is no macOS profile yet, so `shuttle-java` cannot currently be packaged with a macOS library. +```sh +mvn -N help:active-profiles +``` -Maven turns off an `activeByDefault` profile as soon as another profile of the same POM is selected with `-P`. So `-P build-host-windows-x86_64` builds only the Windows library and does not call `cross`. +A jar built this way contains the library for one platform only. Collecting the libraries of all six platforms into one jar is not set up yet. -Profiles defined in the root [`pom.xml`](../pom.xml): +Other profiles in the root `pom.xml`: | Profile | Effect | | --- | --- | @@ -94,53 +101,37 @@ mvn -Dcargo.profile=release -Dcargo.profile.folder=release install ### Commands -Windows, local cargo only: - -```powershell -# shuttle-java and the example (with shuttle-java's tests) -mvn -P build-host-windows-x86_64 -pl shuttle-java,shuttle-java-example -am install - -# the whole reactor, skipping tests (see Known issues for why) -mvn -P build-host-windows-x86_64 -DskipTests install -``` - -Linux, default profile (needs `cross` and a running Docker): +The same on every platform: ```sh -mvn install +mvn test # build and run all tests +mvn install # build, test and install into ~/.m2 +mvn -pl shuttle-java,shuttle-java-example -am install # only shuttle-java and the example +mvn -pl shuttle-java-example exec:java # run the Weave example (after install) ``` -Several platforms in one jar: - -```sh -mvn -P build-linux-x86-64,build-linux-aarch64,build-windows-x86_64 install -``` - -Run the Weave example (after `shuttle-java` is installed in the local repository): - -```sh -mvn -pl shuttle-java-example exec:java -``` - -### `shuttle-wit-parser` - -`shuttle-wit-parser` always builds its JNI library (`witparserbinding`) with a plain host `cargo build`, without `cross` or a profile, because it only runs on the build machine while the WIT plugin is generating sources. +On Windows, run these from PowerShell with each `-D...` argument quoted (`"-Dcargo.profile=release"`), because PowerShell splits unquoted arguments at the dot. ### Tests +Tests are run on the developer machine; CI only builds. + - `shuttle-java`: JUnit 5 tests (`WeaveTest`, `WasmtimeValueTest`, `WasmtimeComponentTest`, `WasmtimeMemoryTest`, ...). In `generate-test-resources`, `exec-maven-plugin` builds the Rust fixture `src/test/rust/valuetest` for `wasm32-unknown-unknown` into `target/rust-test/valuetest`. The other fixtures are inline WAT or inline Wasm bytes. - `shuttle-wit-parser` and `shuttle-wit-maven-plugin`: parse the WIT files under `src/test/resources/wit` (`greet.wit`, `wasi-cli`, `wasi-sockets`) and compile the generated sources. - Coverage is recorded with JaCoCo (`prepare-agent`, report in `prepare-package`). ## CI -| Workflow | Trigger | What it does | +One workflow, [`ci.yml`](../.github/workflows/ci.yml) "CI", runs on pushes to `main`, on every pull request, and on manual dispatch. It only builds; it runs no tests. `setup-rust-toolchain` sets `RUSTFLAGS=-D warnings`, so Rust warnings fail the build. + +| Job | Runs on | What it does | | --- | --- | --- | -| [`native.yml`](../.github/workflows/native.yml) "Native (Shuttle)" | push to `main` or PR touching `native/**` or the workflow; manual dispatch | Builds the C guests once on Ubuntu and uploads them as an artifact. Then, on Linux, Windows and macOS (x86_64 and arm64 each, six jobs): `cargo build --locked --release` and `shuttle-runner verify`. | -| [`maven.yml`](../.github/workflows/maven.yml) "Java CI with Maven" | push or PR to `main` | Ubuntu, JDK 21 (Temurin): installs `cross`, then runs `mvn -P build-linux-x86-64,build-linux-aarch64,build-windows-x86_64 -Dcargo.profile=release -Dcargo.profile.folder=release -B package`. | +| `guests` | Ubuntu | Builds the C guests (`native/guests/build.sh`). | +| `native ()` | the six platforms below | `cargo build --locked --release` in `native/`. | +| `java ()` | the six platforms below | JDK 21 (Temurin): `mvn -B -DskipTests -Dcargo.profile=release -Dcargo.profile.folder=release package`, which builds the JNI libraries for that platform. | + +Platforms (GitHub-hosted runners): `ubuntu-latest`, `ubuntu-24.04-arm`, `windows-latest`, `windows-11-arm`, `macos-15-intel`, `macos-latest`. ## Known issues -- **`shuttle-wit-parser` tests fail on Windows.** Its `pom.xml` only copies the Linux x86_64 library (`*.so` into `jp/akkiserver/shuttle/wit/parser/libs/linux-x86-64`). On Windows the DLL is built but never copied into the jar folder, so loading fails with `cannot find .../win32-x86-64/witparserbinding.dll`. The `shuttle-wit-maven-plugin` tests use the parser too. On Windows, skip tests for these modules (`-DskipTests`) or build only `shuttle-java` (`-pl shuttle-java -am`). -- **"Java CI with Maven" is failing**, also on `main`. The cause has not been investigated yet. Possible factors: the workflow installs `wasm32-wasip1`/`wasm32-wasip2` targets (left over from the removed WASI modules) but not `wasm32-unknown-unknown`, which the `valuetest` fixture needs, and it cross-compiles `x86_64-pc-windows-msvc` with `cross`. -- **No macOS Maven profile.** `native/` builds on macOS in CI, but `shuttle-java` has no profile that builds or packages a macOS library. +- The JNI crates allow the `deprecated` lint: jni 0.22.4's `bind_java_type!` expands to `AtomicBool::fetch_update`, deprecated in Rust 1.99 ([jni-rs/jni-rs#846](https://github.com/jni-rs/jni-rs/issues/846)). Remove the `#![allow(deprecated)]` lines once jni ships a fix. diff --git a/docs/wit-codegen.md b/docs/wit-codegen.md index 94f468c..f790102 100644 --- a/docs/wit-codegen.md +++ b/docs/wit-codegen.md @@ -30,7 +30,7 @@ The result types are records: Supported: records, variants, enums, flags, options, results, tuples, lists, resources and all scalar types. Unsupported constructs throw: the WIT 0.3 async surface, `stream`/`future`, `map`, and fixed-length lists. -The native library is only packaged for Linux x86_64. On Windows the parser cannot load it (see [building.md](building.md#known-issues)). +The native library is built for the platform Maven runs on (Linux, Windows or macOS, x86_64 or arm64); see [building.md](building.md#host-platform-profiles). ## `shuttle-wit-maven-plugin` @@ -181,8 +181,3 @@ public class MyBundledContext implements FooContext, BarContext { // interfaces cannot hold state. } ``` - -## Known issues - -- **Generated imports for `variant`, `enum`, `result` and resources are broken.** The rename turned the import lines in `WitCodeGenerator.requiredImports` into `import component.jp.akkiserver.shuttle.WitVariant;` (and the same for `WitEnum`, `WitResult`, `WitResource`). The correct package is `jp.akkiserver.shuttle.component`. Generated code that uses any of these types does not compile until this is fixed. `greet.wit` is not affected. -- The parser only loads on Linux x86_64 (see [building.md](building.md#known-issues)). diff --git a/native/HANDOFF.md b/native/HANDOFF.md index 1147c6b..0768558 100644 --- a/native/HANDOFF.md +++ b/native/HANDOFF.md @@ -33,8 +33,8 @@ child programs. | What | Where | | --- | --- | | This repo | `akkiserver-dev/shuttle` (forked from StefanRichterHuber/wasmtime-ng) | -| Working branch | `feature/native-build`, rebased onto `main` (on top of `d400a75`) | -| Draft PR (CI check only, not for merging yet) | `akkiserver-dev/shuttle` PR #1 | +| Working branch | `feature/unified-ci` (from `main` after PR #2 was merged as `7109d4f`) | +| PRs | #1 closed (CI check only); #2 merged (native core, rename, docs, CI fixes) | | Weave fork | `akkiserver-dev/weave`, branch `shuttle-host-hooks` (commit `677cce6`) | | Firmware ABI spec (Japanese) | https://claude.ai/code/artifact/05272d17-ac4c-4f56-933a-374281672f79 | | Docs | `README.md` (overview), `docs/` (building, java-binding, wit-codegen), `native/README.md` | @@ -52,7 +52,7 @@ Modules (Maven groupId `jp.akkiserver`, parent artifactId `shuttle`): Old names (before commit `983dc25`): `wasmtimejavang`, `wasmtimejavang-example`, `wit-parser`, `wit-codegen-maven-plugin`, groupId `io.github.stefanrichterhuber`, packages `io.github.stefanrichterhuber.{wasmtimejavang,witparser,witcodegen}`. -`feature/shuttle-core` on the remote is an older subset of `feature/native-build`. +Remote branches `feature/native-build` and `feature/shuttle-core` are merged/obsolete (not deleted yet). ## 3. Current state (2026-10-15) @@ -66,15 +66,18 @@ packages `io.github.stefanrichterhuber.{wasmtimejavang,witparser,witcodegen}`. `$ErrorActionPreference='Stop'` aborts. A plain run works. Not fixed. - **WSL2 native build not run yet.** Ubuntu-26.04 has only git; it needs `sudo apt install clang lld build-essential` and rustup (owner runs sudo). - Plan: clone the repo into the WSL home and build there, so Linux and - Windows artifacts do not share `native/target/`. -- **Maven on Windows** (IntelliJ's bundled Maven, JDK 25, - `-P build-host-windows-x86_64`): `shuttle-java` 64/64 tests pass (incl. - WeaveTest 12). `shuttle-wit-parser` fails on Windows because its pom only - copies the Linux native library; `shuttle-wit-maven-plugin` was therefore - not tested locally. -- Rename to Shuttle, docs rewrite and a code-generator import fix are - committed. Pushed up to `7dbc5b8`; later commits are local only. + Decided: build directly in `/mnt/d/Projects/shuttle` (`.gitattributes` + keeps `*.sh` LF, so the scripts run under WSL). +- **Maven on Windows** (IntelliJ's bundled Maven, JDK 25, no `-P`; the + `host-windows-x86-64` profile activates itself), `RUSTFLAGS=-D warnings`: + all five modules pass: `shuttle-java` 64/64, `shuttle-wit-parser` 4/4, + `shuttle-wit-maven-plugin` 3/3. +- PR #2 (rename, docs, Java CI fixes) is merged; Java CI was green on Linux + and Windows before the merge. +- On `feature/unified-ci`: `native.yml` + `maven.yml` replaced by one + `ci.yml` (build only, six platforms); the cross-based Maven profiles + replaced by six OS-activated `host-*` profiles in the root pom, also used by + `shuttle-wit-parser`. - **Two Weave versions coexist**: `shuttle-java` pins `0f26893` (no `shuttle-host-hooks`), `native/` pins `677cce6`. How the `d400a75` Weave JNI layer and `native/shuttle-core` fit together is **not decided**. @@ -109,6 +112,18 @@ packages `io.github.stefanrichterhuber.{wasmtimejavang,witparser,witcodegen}`. WASI material was dropped because WASI was removed upstream (`44c4363`). - pom ``: akki (maintainer) + Stefan Richter-Huber (original author). +- CI (2026-10-15): one workflow `ci.yml` with separate jobs (`guests`, + `native` x6, `java` x6) on GitHub-hosted runners for all six platforms. + **CI only builds**: no tests and no `shuttle-runner verify`. Tests run on + the owner's Windows machine; if CI breaks on another platform, fix it + separately. Triggers: push to `main`, every PR, manual dispatch. No + per-path job filtering. Rust warnings are errors (`-D warnings`) in both. +- jni deprecation (jni-rs/jni-rs#846): `#![allow(deprecated)]` in the two + JNI crates' `lib.rs` until jni ships a fix. +- Maven native build: six `host-*` profiles in the root pom, activated from + `os.name`/`os.arch`, built with plain `cargo` (no cross, no Docker). Each + jar holds the host platform's library only; an all-platform jar is a later + task (distribution format not decided). ## 5. NOT approved yet (decided by Claude without asking; review each) @@ -129,13 +144,8 @@ packages `io.github.stefanrichterhuber.{wasmtimejavang,witparser,witcodegen}`. ## 6. Known issues (found 2026-10-15, not fixed) -- **`.github/workflows/maven.yml`** (probably why "Java CI with Maven" - fails): installs `wasm32-wasip1`/`wasip2`/nightly `wasip1-threads` - (leftovers from removed WASI modules) but not `wasm32-unknown-unknown`, - which the `valuetest` fixture needs; cross-compiles - `x86_64-pc-windows-msvc` with `cross`, which has no official msvc image. -- `shuttle-wit-parser` has no Windows/macOS native library copy step. -- No macOS profile in `shuttle-java/pom.xml`. +- No all-platform jar yet: each build packages only the host platform's + native libraries. - Generated WIT contexts default to version `0.2.6` (`WasmComponentContext.DEFAULT_VERSION`); a WIT package at `@1.0.0` is registered under the wrong version unless `getVersion()` is overridden. @@ -150,7 +160,13 @@ packages `io.github.stefanrichterhuber.{wasmtimejavang,witparser,witcodegen}`. ## 7. Next steps (ask before each) -See the end of the 2026-10-15 Claude Code session; the owner picks the -order. Candidates: WSL2 build, fixing `maven.yml`, reviewing section 5, and -deciding how the Weave JNI layer and `native/shuttle-core` relate (then -designing the Machine API JNI layer). +The owner picks the order. Candidates: + +1. Finish `feature/unified-ci` (CI green on all six platforms, PR, merge). +2. WSL2 native build (after the owner installs the tools). +3. Decide how the Weave JNI layer (`shuttle-java`, Weave `0f26893`) and + `native/shuttle-core` (`677cce6`) relate, then design the Machine API JNI + layer. Review section 5 as part of it. +4. All-platform jar / distribution (Maven Central, GitHub Releases, bundled + in the RC mod, ...). +5. Smaller known issues from section 6. diff --git a/native/README.md b/native/README.md index b23109c..cfddb22 100644 --- a/native/README.md +++ b/native/README.md @@ -53,9 +53,9 @@ cargo build ./target/debug/shuttle-runner verify guests/out/bios.wasm guests/out/os.wasm guests/out/child.wasm ``` -CI (`.github/workflows/native.yml`) builds the guests once on Linux, then -builds and runs `verify` on Linux, Windows and macOS, each on x86_64 and -arm64. +CI (`.github/workflows/ci.yml`) builds the guests once on Linux, and builds +the workspace on Linux, Windows and macOS, each on x86_64 and arm64. It does +not run `verify`; run it locally. `run` boots and prints the log until power-off. `verify` runs once without interruption, then once per tick boundary with capture → restore into a From 7506e9edaf514e6437fdf15a59a65fd9d8bd8583 Mon Sep 17 00:00:00 2001 From: akki <151368291+akki697222@users.noreply.github.com> Date: Thu, 15 Oct 2026 18:15:23 +0900 Subject: [PATCH 4/4] HANDOFF: WSL2 native build verified; Maven on WSL2 still open Co-Authored-By: Claude Opus 5.5 --- native/HANDOFF.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/native/HANDOFF.md b/native/HANDOFF.md index 0768558..ab9d4cc 100644 --- a/native/HANDOFF.md +++ b/native/HANDOFF.md @@ -60,14 +60,19 @@ Remote branches `feature/native-build` and `feature/shuttle-core` are merged/obs rustc 1.99.0, `cargo build` 2m13s; verify 26/26 identical, control 24/24 diverged. Re-run after the rebase: same result. - Snapshots on Windows are 5.6 KB (tick 1) and about 9.3 KB later; the - Linux numbers in `native/README.md` are 5.2-7.7 KB. Not investigated. + Linux numbers are 5.2-7.7 KB (confirmed on WSL2 below). - `build.ps1` dies if its output is redirected (`*>&1`) under Windows PowerShell 5.1: cargo's stderr becomes an error record and `$ErrorActionPreference='Stop'` aborts. A plain run works. Not fixed. -- **WSL2 native build not run yet.** Ubuntu-26.04 has only git; it needs - `sudo apt install clang lld build-essential` and rustup (owner runs sudo). - Decided: build directly in `/mnt/d/Projects/shuttle` (`.gitattributes` - keeps `*.sh` LF, so the scripts run under WSL). +- **WSL2 native build verified** (Ubuntu-26.04, run directly in + `/mnt/d/Projects/shuttle/native`, `.gitattributes` keeps `*.sh` LF): + `cargo build` 2m33s, verify 26/26 identical, control 24/24 diverged. + Snapshots 5.3 KB (tick 1) and about 7.6 KB later, matching the Linux numbers + in `native/README.md`; so the larger Windows snapshots (about 9.3 KB) are an + OS difference, cause not investigated. +- **WSL2 Maven not run yet**: needs `sudo apt install openjdk-21-jdk maven` + and `rustup target add wasm32-unknown-unknown`. The owner's bar for "done" + is build + tests passing on the Windows host and on WSL2. - **Maven on Windows** (IntelliJ's bundled Maven, JDK 25, no `-P`; the `host-windows-x86-64` profile activates itself), `RUSTFLAGS=-D warnings`: all five modules pass: `shuttle-java` 64/64, `shuttle-wit-parser` 4/4,