mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-22 21:21:33 +00:00
feat(runtime-c-api) Remove the flag WASM_EMSCRIPTEN_GENERATE_C_API_HEADERS
.
This patch removes the `WASM_EMSCRIPTEN_GENERATE_C_API_HEADERS` flag. Consequently, the C header files will be generated for each build. The `generate-c-api-headers` feature is also removed, since it becomes useless.
This commit is contained in:
2
Makefile
2
Makefile
@ -13,7 +13,7 @@ emtests:
|
|||||||
WASM_EMSCRIPTEN_GENERATE_EMTESTS=1 cargo build -p wasmer-emscripten
|
WASM_EMSCRIPTEN_GENERATE_EMTESTS=1 cargo build -p wasmer-emscripten
|
||||||
|
|
||||||
capi:
|
capi:
|
||||||
WASM_EMSCRIPTEN_GENERATE_C_API_HEADERS=1 cargo build --manifest-path lib/runtime-c-api/Cargo.toml --features generate-c-api-headers
|
cargo build --manifest-path lib/runtime-c-api/Cargo.toml
|
||||||
|
|
||||||
# clean:
|
# clean:
|
||||||
# rm -rf artifacts
|
# rm -rf artifacts
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "wasmer-runtime-c-api"
|
name = "wasmer-runtime-c-api"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
description = "Wasmer c-api library"
|
description = "Wasmer C API library"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||||
repository = "https://github.com/wasmerio/wasmer"
|
repository = "https://github.com/wasmerio/wasmer"
|
||||||
@ -17,9 +17,4 @@ libc = "0.2"
|
|||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cbindgen = { version = "0.8", optional = true }
|
cbindgen = "0.8"
|
||||||
|
|
||||||
[features]
|
|
||||||
generate-c-api-headers = ["cbindgen"]
|
|
||||||
|
|
||||||
|
|
@ -1,28 +1,21 @@
|
|||||||
#[cfg(feature = "generate-c-api-headers")]
|
|
||||||
extern crate cbindgen;
|
extern crate cbindgen;
|
||||||
|
|
||||||
|
use cbindgen::{Builder, Language};
|
||||||
use std::{env, path::Path};
|
use std::{env, path::Path};
|
||||||
|
|
||||||
static CAPI_ENV_VAR: &str = "WASM_EMSCRIPTEN_GENERATE_C_API_HEADERS";
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if env::var(CAPI_ENV_VAR).unwrap_or("0".to_string()) == "1" {
|
|
||||||
build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "generate-c-api-headers")]
|
|
||||||
fn build() {
|
|
||||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||||
|
|
||||||
let out_dir = env::var("OUT_DIR").unwrap();
|
let out_dir = env::var("OUT_DIR").unwrap();
|
||||||
let out_path = Path::new(&out_dir);
|
let out_path = Path::new(&out_dir);
|
||||||
|
|
||||||
let mut wasmer_h = out_path.to_path_buf();
|
let mut wasmer_h = out_path.to_path_buf();
|
||||||
wasmer_h.push("wasmer.h");
|
wasmer_h.push("wasmer.h");
|
||||||
|
|
||||||
let mut wasmer_hh = out_path.to_path_buf();
|
let mut wasmer_hh = out_path.to_path_buf();
|
||||||
wasmer_hh.push("wasmer.hh");
|
wasmer_hh.push("wasmer.hh");
|
||||||
|
|
||||||
use cbindgen::Language;
|
Builder::new()
|
||||||
cbindgen::Builder::new()
|
|
||||||
.with_crate(crate_dir.clone())
|
.with_crate(crate_dir.clone())
|
||||||
.with_language(Language::C)
|
.with_language(Language::C)
|
||||||
.with_include_guard("WASMER_H")
|
.with_include_guard("WASMER_H")
|
||||||
@ -30,7 +23,7 @@ fn build() {
|
|||||||
.expect("Unable to generate C bindings")
|
.expect("Unable to generate C bindings")
|
||||||
.write_to_file(wasmer_h);
|
.write_to_file(wasmer_h);
|
||||||
|
|
||||||
cbindgen::Builder::new()
|
Builder::new()
|
||||||
.with_crate(crate_dir)
|
.with_crate(crate_dir)
|
||||||
.with_language(Language::Cxx)
|
.with_language(Language::Cxx)
|
||||||
.with_include_guard("WASMER_H")
|
.with_include_guard("WASMER_H")
|
||||||
@ -38,8 +31,3 @@ fn build() {
|
|||||||
.expect("Unable to generate C++ bindings")
|
.expect("Unable to generate C++ bindings")
|
||||||
.write_to_file(wasmer_hh);
|
.write_to_file(wasmer_hh);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "generate-c-api-headers"))]
|
|
||||||
fn build() {
|
|
||||||
panic!("environment var set to generate wasmer c API headers but generate-c-api-headers feature not enabled")
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user