Skip to content

Commit

Permalink
Fix released artifact execution (#368)
Browse files Browse the repository at this point in the history
* Fix workflow release file

* Include bytes at compile time in compiler

* Update readme for compiler
  • Loading branch information
redoC-A2k authored May 31, 2024
1 parent dbe9070 commit c488be8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions JS/wasm/crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,22 @@ fn main() -> Result<()> {
}

println!("\nStarting to build arakoo compatible module");
let wasm: Vec<u8> =
if let Ok(wasm_bytes) = std::fs::read(concat!(env!("OUT_DIR"), "/engine.wasm")) {
wasm_bytes
} else {
// Provide a fallback wasm binary if the file is not found
panic!("Engine wasm not found");
};
// let wasm: Vec<u8> =
// if let Ok(wasm_bytes) = std::fs::read(concat!(env!("OUT_DIR"), "/engine.wasm")) {
// wasm_bytes
// } else {
// // Provide a fallback wasm binary if the file is not found
// panic!("Engine wasm not found");
// };
let wasm: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/engine.wasm"));

println!("Preinitializing using Wizer");
let mut wasm = Wizer::new()
.allow_wasi(true)?
.inherit_stdio(true)
.wasm_bulk_memory(true)
.inherit_env(true)
.run(wasm.as_slice())?;
.run(wasm)?;

let codegen_config = CodegenConfig {
optimization_level: 3,
Expand All @@ -72,13 +73,12 @@ fn main() -> Result<()> {
}

println!("Adapting module for component model");
let adapter_path = concat!(env!("OUT_DIR"), "/adapter.wasm");
wasm = ComponentEncoder::default()
.validate(true)
.module(&wasm)?
.adapter(
"wasi_snapshot_preview1",
&fs::read(adapter_path).expect("Unable to read adapter"),
include_bytes!(concat!(env!("OUT_DIR"), "/adapter.wasm"))
)?
.encode()?;

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ as $$
1. Select latest successful workflow run from [here](https://github.com/arakoodev/EdgeChains/actions/workflows/release-wasm.yml) .
2. Then scroll to bottom and download artifact . A zip will be downloaded to your system
3. Extract the zip .
4. You will have two binaries `arakoo` *(this is runtime)* and `javy` *(this is our extended javy compiler)*
4. You will have two binaries `arakoo` *(this is runtime)* and `arakoo-compiler` *(this is our extended javy compiler)*
5. Copy these two binaries to `~/.local/bin` or `/usr/bin` *(if you want all users to access the binaries )*
6. Open terminal and grant executable permission to installed binaries by running `chmod +x "<path of installed javy>"` and `chmod +x "<path of installed arakoo>"`
6. Open terminal and grant executable permission to copied binaries by running `chmod +x "<path of copied arakoo-compiler>"` and `chmod +x "<path of copied arakoo>"`

*You are now good to go ! Have look at below section which describe how you can create apis in hono and compile them to wasm*

Expand Down Expand Up @@ -212,7 +212,7 @@ build({
```
12. Now compile bundled file with javy
```
javy compile dist.js
arakoo-compiler dist.js
```
13. You should see a new file `index.wasm` in the directory

Expand Down

0 comments on commit c488be8

Please sign in to comment.