Skip to content

Commit

Permalink
Try #1916:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Dec 11, 2020
2 parents 0bfc7a3 + a0abe41 commit e881a8f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

### Added

* [#1916](https://github.com/wasmerio/wasmer/pull/1916) Add the `WASMER_VERSION*` constants in the Wasmer C API
* [#1867](https://github.com/wasmerio/wasmer/pull/1867) Added `Metering::get_remaining_points` and `Metering::set_remaining_points`
* [#1881](https://github.com/wasmerio/wasmer/pull/1881) Added `UnsupportedTarget` error to `CompileError`
* [#1908](https://github.com/wasmerio/wasmer/pull/1908) Implemented `TryFrom<Value<T>>` for `i32`/`u32`/`i64`/`u64`/`f32`/`f64`
Expand Down
35 changes: 29 additions & 6 deletions lib/c-api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ fn build_wasm_c_api_headers(crate_dir: &str, out_dir: &str) {
r#"// The Wasmer C/C++ header file compatible with the `wasm-c-api` standard API.
// This file is generated by lib/c-api/build.rs.
#if !defined(WASMER_WASM_H_MACROS)
#if !defined(WASMER_WASM_H_PRELUDE)
#define WASMER_WASM_H_MACROS
#define WASMER_WASM_H_PRELUDE
{pre_header}"#,
pre_header = PRE_HEADER
);
Expand All @@ -88,10 +88,12 @@ fn build_wasm_c_api_headers(crate_dir: &str, out_dir: &str) {
map_feature_as_c_define!("wasi", WASI_FEATURE_AS_C_DEFINE, pre_header);
map_feature_as_c_define!("emscripten", EMSCRIPTEN_FEATURE_AS_C_DEFINE, pre_header);

add_wasmer_version(&mut pre_header);

// Close pre header.
pre_header.push_str(
r#"
#endif // WASMER_WASM_H_MACROS
#endif // WASMER_WASM_H_PRELUDE
//
Expand Down Expand Up @@ -134,19 +136,22 @@ fn build_wasmer_headers(crate_dir: &str, out_dir: &str) {
let mut pre_header = format!(
r#"// The Wasmer C/C++ header file.
#if !defined(WASMER_H_MACROS)
#if !defined(WASMER_H_PRELUDE)
#define WASMER_H_MACROS
#define WASMER_H_PRELUDE
{pre_header}"#,
pre_header = PRE_HEADER
);

map_feature_as_c_define!("wasi", WASI_FEATURE_AS_C_DEFINE, pre_header);
map_feature_as_c_define!("emscritpen", EMSCRIPTEN_FEATURE_AS_C_DEFINE, pre_header);

add_wasmer_version(&mut pre_header);

// Close pre header.
pre_header.push_str(
r#"#endif // WASMER_H_MACROS
r#"
#endif // WASMER_H_PRELUDE
//
Expand Down Expand Up @@ -196,6 +201,24 @@ fn build_wasmer_headers(crate_dir: &str, out_dir: &str) {
}
}

fn add_wasmer_version(pre_header: &mut String) {
pre_header.push_str(&format!(
r#"
// This file corresponds to the following Wasmer version.
#define WASMER_VERSION "{full}"
#define WASMER_VERSION_MAJOR {major}
#define WASMER_VERSION_MINOR {minor}
#define WASMER_VERSION_PATCH {patch}
#define WASMER_VERSION_PRE "{pre}"
"#,
full = env!("CARGO_PKG_VERSION"),
major = env!("CARGO_PKG_VERSION_MAJOR"),
minor = env!("CARGO_PKG_VERSION_MINOR"),
patch = env!("CARGO_PKG_VERSION_PATCH"),
pre = env!("CARGO_PKG_VERSION_PRE"),
));
}

/// Create a fresh new `Builder`, already pre-configured.
fn new_builder(language: Language, crate_dir: &str, include_guard: &str, header: &str) -> Builder {
Builder::new()
Expand Down
14 changes: 11 additions & 3 deletions lib/c-api/wasmer.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// The Wasmer C/C++ header file.

#if !defined(WASMER_H_MACROS)
#if !defined(WASMER_H_PRELUDE)

#define WASMER_H_MACROS
#define WASMER_H_PRELUDE

// Define the `ARCH_X86_X64` constant.
#if defined(MSVC) && defined(_M_AMD64)
Expand Down Expand Up @@ -30,7 +30,15 @@

// The `wasi` feature has been enabled for this build.
#define WASMER_WASI_ENABLED
#endif // WASMER_H_MACROS

// This file corresponds to the following Wasmer version.
#define WASMER_VERSION "1.0.0-beta1"
#define WASMER_VERSION_MAJOR 1
#define WASMER_VERSION_MINOR 0
#define WASMER_VERSION_PATCH 0
#define WASMER_VERSION_PRE "beta1"

#endif // WASMER_H_PRELUDE


//
Expand Down
14 changes: 11 additions & 3 deletions lib/c-api/wasmer.hh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// The Wasmer C/C++ header file.

#if !defined(WASMER_H_MACROS)
#if !defined(WASMER_H_PRELUDE)

#define WASMER_H_MACROS
#define WASMER_H_PRELUDE

// Define the `ARCH_X86_X64` constant.
#if defined(MSVC) && defined(_M_AMD64)
Expand Down Expand Up @@ -30,7 +30,15 @@

// The `wasi` feature has been enabled for this build.
#define WASMER_WASI_ENABLED
#endif // WASMER_H_MACROS

// This file corresponds to the following Wasmer version.
#define WASMER_VERSION "1.0.0-beta1"
#define WASMER_VERSION_MAJOR 1
#define WASMER_VERSION_MINOR 0
#define WASMER_VERSION_PATCH 0
#define WASMER_VERSION_PRE "beta1"

#endif // WASMER_H_PRELUDE


//
Expand Down
13 changes: 10 additions & 3 deletions lib/c-api/wasmer_wasm.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// The Wasmer C/C++ header file compatible with the `wasm-c-api` standard API.
// This file is generated by lib/c-api/build.rs.

#if !defined(WASMER_WASM_H_MACROS)
#if !defined(WASMER_WASM_H_PRELUDE)

#define WASMER_WASM_H_MACROS
#define WASMER_WASM_H_PRELUDE

// Define the `ARCH_X86_X64` constant.
#if defined(MSVC) && defined(_M_AMD64)
Expand Down Expand Up @@ -38,7 +38,14 @@
// The `wasi` feature has been enabled for this build.
#define WASMER_WASI_ENABLED

#endif // WASMER_WASM_H_MACROS
// This file corresponds to the following Wasmer version.
#define WASMER_VERSION "1.0.0-beta1"
#define WASMER_VERSION_MAJOR 1
#define WASMER_VERSION_MINOR 0
#define WASMER_VERSION_PATCH 0
#define WASMER_VERSION_PRE "beta1"

#endif // WASMER_WASM_H_PRELUDE


//
Expand Down

0 comments on commit e881a8f

Please sign in to comment.