Skip to content

Commit

Permalink
Add support for ESP32 (#23)
Browse files Browse the repository at this point in the history
* Add wamr as an esp-idf component
  • Loading branch information
AlixANNERAUD authored Apr 22, 2024
1 parent d7f1a8c commit ceeffbe
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,14 @@ keywords = ["api-bindings", "wasm", "webassembly"]
[dependencies]
wamr-sys = { path = "crates/wamr-sys", version = "0.1.0" }

[target.'cfg( target_os = "espidf" )'.dependencies]
esp-idf-sys = { version = "0.34" }

[[package.metadata.esp-idf-sys.extra_components]]
bindings_header = "./crates/wamr-sys/wasm-micro-runtime/core/iwasm/include/wasm_export.h"
component_dirs = ["./crates/wamr-sys/wasm-micro-runtime/build-scripts/esp-idf"]



# [features]
# llvmjit = ["wamr-sys/llvmjit"]
44 changes: 24 additions & 20 deletions crates/wamr-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,31 @@ fn main() {
let wamr_root = wamr_root.join("wasm-micro-runtime");
assert!(wamr_root.exists());

let enable_llvm_jit = if cfg!(feature = "llvmjit") { "1" } else { "0" };
// TODO: define LLVM_DIR
let dst = Config::new(&wamr_root)
// running mode
.define("WAMR_BUILD_AOT", "1")
.define("WAMR_BUILD_INTERP", "1")
.define("WAMR_BUILD_FAST_INTERP", "1")
.define("WAMR_BUILD_JIT", enable_llvm_jit)
// mvp
.define("WAMR_BUILD_BULK_MEMORY", "1")
.define("WAMR_BUILD_REF_TYPES", "1")
.define("WAMR_BUILD_SIMD", "1")
// wasi
.define("WAMR_BUILD_LIBC_WASI", "1")
// `nostdlib`
.define("WAMR_BUILD_LIBC_BUILTIN", "1")
.build_target("iwasm_static")
.build();
let is_espidf = env::var("CARGO_CFG_TARGET_OS").unwrap() != "espidf";

println!("cargo:rustc-link-search=native={}/build", dst.display());
println!("cargo:rustc-link-lib=static=vmlib");
if is_espidf {
let enable_llvm_jit = if cfg!(feature = "llvmjit") { "1" } else { "0" };
// TODO: define LLVM_DIR
let dst = Config::new(&wamr_root)
// running mode
.define("WAMR_BUILD_AOT", "1")
.define("WAMR_BUILD_INTERP", "1")
.define("WAMR_BUILD_FAST_INTERP", "1")
.define("WAMR_BUILD_JIT", enable_llvm_jit)
// mvp
.define("WAMR_BUILD_BULK_MEMORY", "1")
.define("WAMR_BUILD_REF_TYPES", "1")
.define("WAMR_BUILD_SIMD", "1")
// wasi
.define("WAMR_BUILD_LIBC_WASI", "1")
// `nostdlib`
.define("WAMR_BUILD_LIBC_BUILTIN", "1")
.build_target("iwasm_static")
.build();

println!("cargo:rustc-link-search=native={}/build", dst.display());
println!("cargo:rustc-link-lib=static=vmlib");
}

//TODO: support macos?
if cfg!(feature = "llvmjit") {
Expand Down
2 changes: 1 addition & 1 deletion crates/wamr-sys/wasm-micro-runtime

0 comments on commit ceeffbe

Please sign in to comment.