forked from wasmerio/wasmer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(runtime-c-api) Remove the flag `WASM_EMSCRIPTEN_GENERATE_C_API_H…
…EADERS`. 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.
- Loading branch information
Showing
3 changed files
with
9 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[package] | ||
name = "wasmer-runtime-c-api" | ||
version = "0.2.1" | ||
description = "Wasmer c-api library" | ||
description = "Wasmer C API library" | ||
license = "MIT" | ||
authors = ["The Wasmer Engineering Team <[email protected]>"] | ||
repository = "https://github.com/wasmerio/wasmer" | ||
|
@@ -17,9 +17,4 @@ libc = "0.2" | |
crate-type = ["cdylib"] | ||
|
||
[build-dependencies] | ||
cbindgen = { version = "0.8", optional = true } | ||
|
||
[features] | ||
generate-c-api-headers = ["cbindgen"] | ||
|
||
|
||
cbindgen = "0.8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,33 @@ | ||
#[cfg(feature = "generate-c-api-headers")] | ||
extern crate cbindgen; | ||
|
||
use cbindgen::{Builder, Language}; | ||
use std::{env, path::Path}; | ||
|
||
static CAPI_ENV_VAR: &str = "WASM_EMSCRIPTEN_GENERATE_C_API_HEADERS"; | ||
|
||
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 out_dir = env::var("OUT_DIR").unwrap(); | ||
let out_path = Path::new(&out_dir); | ||
|
||
let mut wasmer_h = out_path.to_path_buf(); | ||
wasmer_h.push("wasmer.h"); | ||
|
||
let mut wasmer_hh = out_path.to_path_buf(); | ||
wasmer_hh.push("wasmer.hh"); | ||
|
||
use cbindgen::Language; | ||
cbindgen::Builder::new() | ||
Builder::new() | ||
.with_crate(crate_dir.clone()) | ||
.with_language(Language::C) | ||
.with_include_guard("WASMER_H") | ||
.generate() | ||
.expect("Unable to generate C bindings") | ||
.write_to_file(wasmer_h); | ||
|
||
cbindgen::Builder::new() | ||
Builder::new() | ||
.with_crate(crate_dir) | ||
.with_language(Language::Cxx) | ||
.with_include_guard("WASMER_H") | ||
.generate() | ||
.expect("Unable to generate C++ bindings") | ||
.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") | ||
} |