You need:
- Docker Desktop
- Git
- VSCode
- Visual Studio Code Remote Containers Extension
First, clone this project.
👋 you need to specify the architecture of the host machine: if needed, change the value of the WORKSPACE_ARCH
variable in this file: compose-dev.yaml
(for example, if you work on a Macbook Intel, use amd64
, on a Macbook M1, use arm64
- it's the same with Linux - not yet tested on Windows)
Then:
- Open Docker Desktop
- Go to the Dev Environments option menu
- Click on the Create button, then on the Get Started button
- Choose Local directory as the source
- Select the directory of this cloned repository
- Click on the Continue button, and wait for a moment
- Once the build finished, Click on the Continue button
- 🎉 and now, you can open your new Dev Environment in VSCode
Or you can test it like this: 🌍 Open the ARM version of this Dev Environment directly from GitLab
git clone https://github.com/dylibso/chicory
cd chicory
mvn clean install
mvn archetype:generate -DgroupId=garden.bots.app -DartifactId=hello -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
cd hello
curl https://raw.githubusercontent.com/dylibso/chicory/main/runtime/src/test/resources/wasm/iterfact.wat.wasm > factorial.wasm
<dependency>
<groupId>com.dylibso.chicory</groupId>
<artifactId>runtime</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
and:
<build>
<plugins>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<mainClass>garden.bots.app.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
package garden.bots.app;
import com.dylibso.chicory.wasm.types.Value;
import java.io.File;
import com.dylibso.chicory.runtime.*;
import com.dylibso.chicory.runtime.Module;
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
File wasmFile = new File("../factorial.wasm");
Module module = Module.build(wasmFile);
Instance instance = module.instantiate();
ExportFunction iterFact = instance.getExport("iterFact");
Value result = iterFact.apply(Value.i32(5))[0];
System.out.println(result.asInt());
}
}
this works
mvn package
java -jar target/hello-1.0-SNAPSHOT.jar
this works
mvn compile exec:java -Dexec.mainClass="garden.bots.app.App"