Skip to content
Draft
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
File renamed without changes.
268 changes: 268 additions & 0 deletions bootstrap/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion wasm-validation/Cargo.toml → bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "wasm-validation"
name = "bootstrap"
version = "0.1.0"
authors = ["losfair <zhy20000919@hotmail.com>"]
edition = "2018"
Expand All @@ -12,3 +12,7 @@ lto = true

[dependencies]
wasmparser = "0.29"
protobuf = "2.4"

[build-dependencies]
protoc-rust = "2.4"
14 changes: 14 additions & 0 deletions bootstrap/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
extern crate protoc_rust;

use protoc_rust::Customize;

fn main() {
protoc_rust::run(protoc_rust::Args {
out_dir: "src/protos",
input: &["protos/module.proto"],
includes: &["protos"],
customize: Customize {
..Default::default()
},
}).expect("protoc");
}
22 changes: 22 additions & 0 deletions bootstrap/gen_go.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

cargo build --release --target wasm32-unknown-unknown
wasm-gc target/wasm32-unknown-unknown/release/wasm_validation.wasm
WASM_B64=$(base64 < target/wasm32-unknown-unknown/release/bootstrap.wasm)
VM_B64=$(../life -emit-bc-unsafe -bc-exports get_code_buf,check_and_parse target/wasm32-unknown-unknown/release/bootstrap.wasm | base64)
cat > wasm.go << EOF
package bootstrap

import "encoding/base64"

var WASMBytecode = _getCodeFromB64("${WASM_B64}")
var VMBytecode = _getCodeFromB64("${VM_B64}")

func _getCodeFromB64(input string) []byte {
code, err := base64.StdEncoding.DecodeString(input)
if err != nil {
panic(err)
}
return code
}
EOF
Loading