-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Use cmake to build wasmtime-c-api * Properly expose features when building via cmake * Install all headers to same directory * Add vets * attempt to fix ci * Run all tests on CI prtest:full * Set CARGO_BUILD_TARGET; add CMakeLists to package * Update comment on github action * Attempt to fix android build * Fix source dir modifications of c-api build * Re-add BINARY_DIR option * Fix build * Move header installation to a cmake script Try to avoid dealing with cmake configuration/platforms/etc. * Tweak build of headers * Install headers in build dir for examples * Add cmake files to dist, fix header install dir --------- Co-authored-by: Ryan Patterson <cgamesplay@cgamesplay.com> Co-authored-by: Alex Crichton <alex@alexcrichton.com>
- Loading branch information
1 parent
bfc10d9
commit 55611f3
Showing
11 changed files
with
142 additions
and
77 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
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
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,4 +1,45 @@ | ||
use std::env; | ||
use std::process::Command; | ||
|
||
// WASMTIME_FEATURE_LIST | ||
const FEATURES: &[&str] = &[ | ||
"ASYNC", | ||
"PROFILING", | ||
"CACHE", | ||
"PARALLEL_COMPILATION", | ||
"WASI", | ||
"LOGGING", | ||
"DISABLE_LOGGING", | ||
"COREDUMP", | ||
"ADDR2LINE", | ||
"DEMANGLE", | ||
"THREADS", | ||
"GC", | ||
"CRANELIFT", | ||
"WINCH", | ||
]; | ||
// ... if you add a line above this be sure to change the other locations | ||
// marked WASMTIME_FEATURE_LIST | ||
|
||
fn main() { | ||
let dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); | ||
println!("cargo:include={dir}/include"); | ||
println!("cargo:rerun-if-changed=cmake/features.cmake"); | ||
println!("cargo:rerun-if-changed=cmake/install-headers.cmake"); | ||
println!("cargo:rerun-if-changed=include"); | ||
|
||
let out_dir = std::env::var("OUT_DIR").unwrap(); | ||
let mut cmake = Command::new("cmake"); | ||
cmake.arg("-DWASMTIME_DISABLE_ALL_FEATURES=ON"); | ||
cmake.arg(format!("-DCMAKE_INSTALL_PREFIX={out_dir}")); | ||
for f in FEATURES { | ||
if env::var_os(format!("CARGO_FEATURE_{f}")).is_some() { | ||
cmake.arg(format!("-DWASMTIME_FEATURE_{f}=ON")); | ||
} | ||
} | ||
|
||
cmake.arg("-P").arg("cmake/install-headers.cmake"); | ||
|
||
let status = cmake.status().expect("failed to spawn `cmake`"); | ||
assert!(status.success()); | ||
|
||
println!("cargo:include={out_dir}/include"); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
set(WASMTIME_FEATURES "--no-default-features") | ||
|
||
option(WASMTIME_DISABLE_ALL_FEATURES | ||
"disable all features by default instead of enabling them" | ||
OFF) | ||
|
||
macro(feature rust_name default) | ||
string(TOUPPER "wasmtime_feature_${rust_name}" cmake_name) | ||
string(REPLACE "-" "_" cmake_name ${cmake_name}) | ||
if(${default}) | ||
if(${WASMTIME_DISABLE_ALL_FEATURES}) | ||
set(feature_default OFF) | ||
else() | ||
set(feature_default ON) | ||
endif() | ||
else() | ||
set(feature_default OFF) | ||
endif() | ||
|
||
option(${cmake_name} "enable the Cargo feature ${rust_name}" ${feature_default}) | ||
|
||
if(${cmake_name}) | ||
list(APPEND WASMTIME_FEATURES "--features=${rust_name}") | ||
message(STATUS "Enabling feature ${rust_name}") | ||
endif() | ||
endmacro() | ||
|
||
# WASMTIME_FEATURE_LIST | ||
feature(profiling ON) | ||
feature(wat ON) | ||
feature(cache ON) | ||
feature(parallel-compilation ON) | ||
feature(wasi ON) | ||
feature(logging ON) | ||
feature(disable-logging OFF) | ||
feature(coredump ON) | ||
feature(addr2line ON) | ||
feature(demangle ON) | ||
feature(threads ON) | ||
feature(gc ON) | ||
feature(async ON) | ||
feature(cranelift ON) | ||
feature(winch ON) | ||
# ... if you add a line above this be sure to change the other locations | ||
# marked WASMTIME_FEATURE_LIST |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
|
||
include(${CMAKE_CURRENT_LIST_DIR}/features.cmake) | ||
|
||
if(WASMTIME_HEADER_DST) | ||
set(dst "${WASMTIME_HEADER_DST}") | ||
else() | ||
set(dst "${CMAKE_INSTALL_PREFIX}/include") | ||
endif() | ||
set(include_src "${CMAKE_CURRENT_LIST_DIR}/../include") | ||
|
||
message(STATUS "Installing: ${dst}/wasmtime/conf.h") | ||
file(READ "${include_src}/wasmtime/conf.h.in" conf_h) | ||
file(CONFIGURE OUTPUT "${dst}/wasmtime/conf.h" CONTENT "${conf_h}") | ||
file(INSTALL "${include_src}/" | ||
DESTINATION "${dst}" | ||
FILES_MATCHING REGEX "\\.hh?$") |
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
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