mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-13 00:51:20 +00:00
Add foundational emscripten functions and types to C API
This commit is contained in:
@ -12,7 +12,7 @@ fn main() {
|
||||
let mut out_wasmer_header_file = PathBuf::from(&out_dir);
|
||||
out_wasmer_header_file.push("wasmer");
|
||||
|
||||
const WASMER_PRE_HEADER: &str = r#"
|
||||
let mut pre_header = r#"
|
||||
#if !defined(WASMER_H_MACROS)
|
||||
#define WASMER_H_MACROS
|
||||
|
||||
@ -28,17 +28,27 @@ fn main() {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // WASMER_H_MACROS
|
||||
"#;
|
||||
"#
|
||||
.to_string();
|
||||
|
||||
#[cfg(feature = "emscripten")]
|
||||
{
|
||||
pre_header += "#define WASMER_EMSCRIPTEN_ENABLED\n";
|
||||
}
|
||||
|
||||
// close pre header
|
||||
pre_header += "#endif // WASMER_H_MACROS\n";
|
||||
|
||||
// Generate the C bindings in the `OUT_DIR`.
|
||||
out_wasmer_header_file.set_extension("h");
|
||||
Builder::new()
|
||||
.with_crate(crate_dir.clone())
|
||||
.with_language(Language::C)
|
||||
.with_include_guard("WASMER_H")
|
||||
.with_header(WASMER_PRE_HEADER)
|
||||
.with_header(&pre_header)
|
||||
.with_define("target_family", "windows", "_WIN32")
|
||||
.with_define("target_arch", "x86_64", "ARCH_X86_64")
|
||||
.with_define("feature", "emscripten", "WASMER_EMSCRIPTEN_ENABLED")
|
||||
.generate()
|
||||
.expect("Unable to generate C bindings")
|
||||
.write_to_file(out_wasmer_header_file.as_path());
|
||||
@ -49,9 +59,10 @@ fn main() {
|
||||
.with_crate(crate_dir)
|
||||
.with_language(Language::Cxx)
|
||||
.with_include_guard("WASMER_H")
|
||||
.with_header(WASMER_PRE_HEADER)
|
||||
.with_header(&pre_header)
|
||||
.with_define("target_family", "windows", "_WIN32")
|
||||
.with_define("target_arch", "x86_64", "ARCH_X86_64")
|
||||
.with_define("feature", "emscripten", "WASMER_EMSCRIPTEN_ENABLED")
|
||||
.generate()
|
||||
.expect("Unable to generate C++ bindings")
|
||||
.write_to_file(out_wasmer_header_file.as_path());
|
||||
|
Reference in New Issue
Block a user