Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 0 additions & 41 deletions .github/workflows/redline.yaml

This file was deleted.

19 changes: 5 additions & 14 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,14 @@ jobs:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasip1

- id: install-secret-key
name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.GPG_PRIVATE_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG

- name: Build cranelift_bridge.wasm
working-directory: redline/wasm-build
run: make all

- name: Compile
run: ./mvnw --batch-mode -Dquickly -Predline
run: ./mvnw --batch-mode -Dquickly

- name: Setup Git
run: |
Expand All @@ -62,7 +53,7 @@ jobs:

- name: Set the version
run: |
./mvnw versions:set -DgenerateBackupPoms=false -DnewVersion=${{ github.event.inputs.release-version }} -Predline
./mvnw versions:set -DgenerateBackupPoms=false -DnewVersion=${{ github.event.inputs.release-version }}
git add .
git commit -m "Release version update ${{ github.event.inputs.release-version }}"
git push
Expand All @@ -74,16 +65,16 @@ jobs:
- name: Release to Maven Central
run: |
# -Dquickly is needed to locally publish wasm-corpus
./mvnw --batch-mode -Dquickly -Predline
./mvnw --batch-mode clean deploy -Drelease -Predline -DskipTests=true -X
./mvnw --batch-mode -Dquickly
./mvnw --batch-mode clean deploy -Drelease -DskipTests=true -X
env:
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

- name: Back to Snapshot
run: |
./mvnw versions:set -DgenerateBackupPoms=false -DnewVersion=999-SNAPSHOT -Predline
./mvnw versions:set -DgenerateBackupPoms=false -DnewVersion=999-SNAPSHOT
git add .
git commit -m "Snapshot version update"
git push
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/wasm-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Publish cranelift_bridge.wasm

on:
push:
branches: [main]
paths: ['redline/wasm-build/**']
workflow_dispatch:

# Must stay in sync with the imageRef tag in redline/bridge/pom.xml.
env:
WASM_VERSION: 999.0.0-SNAPSHOT

jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout sources
uses: actions/checkout@v7

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasip1

- name: Build cranelift_bridge.wasm
working-directory: redline/wasm-build
run: make all

- name: Install ORAS
uses: oras-project/setup-oras@v1

- name: Login to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | oras login ghcr.io -u ${{ github.actor }} --password-stdin

# Pushed from inside redline/ so the org.opencontainers.image.title
# annotation is a bare filename. A path like "redline/cranelift_bridge.wasm"
# makes the OCI client try to write into a directory that does not exist
# on pull.
#
# The tag must be valid semver: the wkg lock file rejects "latest".
- name: Push to GHCR
working-directory: redline
run: |
oras push \
ghcr.io/bytecodealliance/endive-cranelift-bridge:${{ env.WASM_VERSION }} \
cranelift_bridge.wasm:application/wasm

- name: Report new digest
run: |
echo "Published ${{ env.WASM_VERSION }}. Refresh the pinned digest with:" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo './mvnw generate-sources -pl :redline-bridge-experimental -Dinlay.update' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo 'then commit redline/wkg.lock.' >> $GITHUB_STEP_SUMMARY
5 changes: 5 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@
<artifactId>redline-bridge-experimental</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>run.endive</groupId>
<artifactId>redline-build-time-compiler-experimental</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>run.endive</groupId>
<artifactId>redline-compiler-experimental</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ public String[] getVersion() {
"The indexes of functions that should be interpreted, separated by commas")
Set<Integer> interpretedFunctions;

@CommandLine.Option(
order = 7,
names = "--module-interface",
description =
"Fully qualified class name for which to generate _ModuleExports and"
+ " _ModuleImports wrappers")
String moduleInterface;

@Override
public void run() {
var config =
Expand All @@ -82,6 +90,7 @@ public void run() {
.withTargetWasmFolder(targetWasmFolder)
.withInterpreterFallback(interpreterFallback)
.withInterpretedFunctions(interpretedFunctions)
.withModuleInterface(moduleInterface)
.build();

var generator = new Generator(config);
Expand All @@ -90,13 +99,15 @@ public void run() {
var interpretedFunctions = generator.generateResources();
generator.generateMetaWasm(interpretedFunctions);
generator.generateSources();
if (moduleInterface != null && !moduleInterface.isEmpty()) {
generator.generateModuleInterface(moduleInterface);
}
} catch (IOException e) {
throw new CommandLine.PicocliException("Failed to execute the command", e);
}
}

public static void main(String[] args) {
int exitCode = new CommandLine(new Cli()).execute(args);
System.exit(exitCode);
System.exit(new CommandLine(new Cli()).execute(args));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package run.endive.build.time.compiler;

import java.nio.file.Path;
import java.util.List;
import java.util.Set;
import java.util.StringJoiner;
import run.endive.compiler.InterpreterFallback;
Expand Down Expand Up @@ -46,6 +47,11 @@ public final class Config {
*/
private final String moduleInterface;

/**
* target triples for redline native compilation (empty = no native compilation)
*/
private final List<String> redlineTargets;

private Config(
Path wasmFile,
String name,
Expand All @@ -54,7 +60,8 @@ private Config(
Path targetWasmFolder,
InterpreterFallback interpreterFallback,
Set<Integer> interpretedFunctions,
String moduleInterface) {
String moduleInterface,
List<String> redlineTargets) {
this.wasmFile = wasmFile;
this.name = name;
this.targetClassFolder = targetClassFolder;
Expand All @@ -63,6 +70,7 @@ private Config(
this.interpreterFallback = interpreterFallback;
this.interpretedFunctions = interpretedFunctions;
this.moduleInterface = moduleInterface;
this.redlineTargets = redlineTargets;
}

public Path wasmFile() {
Expand Down Expand Up @@ -97,6 +105,14 @@ public String moduleInterface() {
return moduleInterface;
}

public List<String> redlineTargets() {
return redlineTargets;
}

public boolean hasRedlineTargets() {
return redlineTargets != null && !redlineTargets.isEmpty();
}

public static Builder builder() {
return new Builder();
}
Expand Down Expand Up @@ -126,6 +142,7 @@ public static final class Builder {
private InterpreterFallback interpreterFallback = InterpreterFallback.FAIL;
private Set<Integer> interpretedFunctions;
private String moduleInterface;
private List<String> redlineTargets = List.of();

private Builder() {}

Expand Down Expand Up @@ -169,6 +186,11 @@ public Builder withModuleInterface(String moduleInterface) {
return this;
}

public Builder withRedlineTargets(List<String> redlineTargets) {
this.redlineTargets = redlineTargets;
return this;
}

public Config build() {
return new Config(
wasmFile,
Expand All @@ -178,7 +200,8 @@ public Config build() {
targetWasmFolder,
interpreterFallback,
interpretedFunctions,
moduleInterface);
moduleInterface,
redlineTargets);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package run.endive.build.time.compiler;

import java.io.IOException;
import java.nio.file.Path;
import run.endive.compiler.InterpreterFallback;

public final class GeneratorMain {

private GeneratorMain() {}

public static void main(String[] args) throws IOException {
if (args.length < 5) {
throw new IllegalArgumentException(
"Usage: GeneratorMain <wasmFile> <name> <targetClassFolder>"
+ " <targetSourceFolder> <targetWasmFolder>"
+ " [interpreterFallback] [moduleInterface]");
}
var configBuilder =
Config.builder()
.withWasmFile(Path.of(args[0]))
.withName(args[1])
.withTargetClassFolder(Path.of(args[2]))
.withTargetSourceFolder(Path.of(args[3]))
.withTargetWasmFolder(Path.of(args[4]));
if (args.length > 5 && !args[5].isEmpty()) {
configBuilder.withInterpreterFallback(InterpreterFallback.valueOf(args[5]));
}
if (args.length > 6 && !args[6].isEmpty()) {
configBuilder.withModuleInterface(args[6]);
}
var config = configBuilder.build();
var generator = new Generator(config);
var interpreted = generator.generateResources();
generator.generateMetaWasm(interpreted);
generator.generateSources();
if (config.moduleInterface() != null && !config.moduleInterface().isEmpty()) {
generator.generateModuleInterface(config.moduleInterface());
}
}
}
4 changes: 4 additions & 0 deletions compiler-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<groupId>run.endive</groupId>
<artifactId>compiler</artifactId>
</dependency>
<dependency>
<groupId>run.endive</groupId>
<artifactId>redline-build-time-compiler-experimental</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
Expand Down
Loading
Loading