From 94f2e3445db3936536d2e8bc6ff282a84b556d74 Mon Sep 17 00:00:00 2001 From: Ryan Patterson Date: Mon, 29 Jul 2024 10:28:15 +0600 Subject: [PATCH 01/16] Use cmake to build wasmtime-c-api --- Cargo.lock | 10 ++++++++++ crates/c-api/CMakeLists.txt | 2 ++ crates/c-api/Cargo.toml | 3 +++ crates/c-api/README.md | 2 +- crates/c-api/build.rs | 10 ++++++++-- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fd7e5727d4aa..b91fd27b895d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -455,6 +455,15 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + [[package]] name = "cobs" version = "0.2.3" @@ -3467,6 +3476,7 @@ version = "25.0.0" dependencies = [ "anyhow", "cap-std", + "cmake", "env_logger", "futures", "log", diff --git a/crates/c-api/CMakeLists.txt b/crates/c-api/CMakeLists.txt index 1235c61a0f00..e5cd90c05067 100644 --- a/crates/c-api/CMakeLists.txt +++ b/crates/c-api/CMakeLists.txt @@ -146,6 +146,8 @@ target_include_directories(wasmtime INTERFACE ${CMAKE_BINARY_DIR}/include) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/include/wasmtime/conf.h.in ${WASMTIME_GENERATED_CONF_H}) +add_custom_target(conf_h + DEPENDS ${WASMTIME_GENERATED_CONF_H}) include(GNUInstallDirs) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ diff --git a/crates/c-api/Cargo.toml b/crates/c-api/Cargo.toml index 5b8a964f25ec..78fa559ed632 100644 --- a/crates/c-api/Cargo.toml +++ b/crates/c-api/Cargo.toml @@ -38,6 +38,9 @@ wasmtime-wasi = { workspace = true, optional = true, features = ["preview1"] } # Optional dependencies for the `async` feature futures = { workspace = true, optional = true } +[build-dependencies] +cmake = "0.1" + [features] async = ['wasmtime/async', 'futures'] profiling = ["wasmtime/profiling"] diff --git a/crates/c-api/README.md b/crates/c-api/README.md index 8f093855a091..da2ce6a4a03f 100644 --- a/crates/c-api/README.md +++ b/crates/c-api/README.md @@ -59,7 +59,7 @@ fn main() { // Wasm C API headers. cfg .include(std::env::var("DEP_WASMTIME_C_API_INCLUDE").unwrap()); - .include(std::env::var("DEP_WASMTIME_C_API_WASM_INCLUDE").unwrap()); + .include(std::env::var("DEP_WASMTIME_C_API_CONF_INCLUDE").unwrap()); // Compile your C code. cfg diff --git a/crates/c-api/build.rs b/crates/c-api/build.rs index 7c9151fbe7ab..5ca3ac89a8e7 100644 --- a/crates/c-api/build.rs +++ b/crates/c-api/build.rs @@ -1,4 +1,10 @@ +use cmake; +use std::{env, path::PathBuf}; + fn main() { - let dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); - println!("cargo:include={dir}/include"); + let dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()); + let dst = cmake::Config::new(&dir).build_target("conf_h").build(); + + println!("cargo:conf-include={}/build/include", dst.display()); + println!("cargo:include={}/include", dir.display()); } From c0c8d1938b8a1962fe714bf9cf91a7bf8d8d8306 Mon Sep 17 00:00:00 2001 From: Ryan Patterson Date: Tue, 30 Jul 2024 07:01:26 +0600 Subject: [PATCH 02/16] Properly expose features when building via cmake --- crates/c-api/CMakeLists.txt | 7 +++--- crates/c-api/Cargo.toml | 6 ++--- crates/c-api/artifact/Cargo.toml | 7 +++--- crates/c-api/build.rs | 33 ++++++++++++++++++++++++- crates/c-api/include/wasmtime/conf.h.in | 3 +++ 5 files changed, 44 insertions(+), 12 deletions(-) diff --git a/crates/c-api/CMakeLists.txt b/crates/c-api/CMakeLists.txt index e5cd90c05067..df5075281fa5 100644 --- a/crates/c-api/CMakeLists.txt +++ b/crates/c-api/CMakeLists.txt @@ -41,6 +41,7 @@ macro(feature rust_name default) endif() endmacro() +# WASMTIME_FEATURE_LIST feature(profiling ON) feature(wat ON) feature(cache ON) @@ -56,10 +57,8 @@ feature(gc ON) feature(async ON) feature(cranelift ON) feature(winch ON) -# ... if you add a line above this be sure to also change: -# -# crates/c-api/include/wasmtime/conf.h.in -# crates/c-api/artifact/Cargo.toml +# ... if you add a line above this be sure to change the other locations +# marked WASMTIME_FEATURE_LIST if(WASMTIME_FASTEST_RUNTIME) set(WASMTIME_BUILD_TYPE_FLAG "--profile=fastest-runtime") diff --git a/crates/c-api/Cargo.toml b/crates/c-api/Cargo.toml index 78fa559ed632..276b01d64df6 100644 --- a/crates/c-api/Cargo.toml +++ b/crates/c-api/Cargo.toml @@ -42,6 +42,7 @@ futures = { workspace = true, optional = true } cmake = "0.1" [features] +# WASMTIME_FEATURE_LIST async = ['wasmtime/async', 'futures'] profiling = ["wasmtime/profiling"] cache = ["wasmtime/cache"] @@ -56,6 +57,5 @@ threads = ["wasmtime/threads"] gc = ["wasmtime/gc"] cranelift = ['wasmtime/cranelift'] winch = ['wasmtime/winch'] -# ... if you add a line above this be sure to also change: -# -# crates/c-api/artifact/Cargo.toml +# ... if you add a line above this be sure to change the other locations +# marked WASMTIME_FEATURE_LIST diff --git a/crates/c-api/artifact/Cargo.toml b/crates/c-api/artifact/Cargo.toml index a64007cc225e..789789b43eb1 100644 --- a/crates/c-api/artifact/Cargo.toml +++ b/crates/c-api/artifact/Cargo.toml @@ -20,6 +20,7 @@ doctest = false wasmtime-c-api = { path = '..', package = 'wasmtime-c-api-impl' } [features] +# WASMTIME_FEATURE_LIST default = [ 'profiling', 'wat', @@ -34,10 +35,8 @@ default = [ 'gc', 'cranelift', 'winch', - # ... if you add a line above this be sure to also change: - # - # crates/c-api/CMakeLists.txt - # crates/c-api/Cargo.toml + # ... if you add a line above this be sure to change the other locations + # marked WASMTIME_FEATURE_LIST ] async = ['wasmtime-c-api/async'] profiling = ["wasmtime-c-api/profiling"] diff --git a/crates/c-api/build.rs b/crates/c-api/build.rs index 5ca3ac89a8e7..9ffec00d9d46 100644 --- a/crates/c-api/build.rs +++ b/crates/c-api/build.rs @@ -1,9 +1,40 @@ use cmake; use std::{env, path::PathBuf}; +// 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() { + println!("cargo:rerun-if-changed=CMakesLists.txt"); + println!("cargo:rerun-if-changed=include/wasmtime/conf.h.in"); let dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()); - let dst = cmake::Config::new(&dir).build_target("conf_h").build(); + let mut config = cmake::Config::new(&dir); + config + .define("WASMTIME_DISABLE_ALL_FEATURES", "ON") + .build_target("conf_h"); + for f in FEATURES { + if env::var_os(format!("CARGO_FEATURE_{}", f)).is_some() { + config.define(format!("WASMTIME_FEATURE_{}", f), "ON"); + } + } + let dst = config.build(); println!("cargo:conf-include={}/build/include", dst.display()); println!("cargo:include={}/include", dir.display()); diff --git a/crates/c-api/include/wasmtime/conf.h.in b/crates/c-api/include/wasmtime/conf.h.in index 009c00b9d289..c04cfca886ad 100644 --- a/crates/c-api/include/wasmtime/conf.h.in +++ b/crates/c-api/include/wasmtime/conf.h.in @@ -7,6 +7,7 @@ #ifndef WASMTIME_CONF_H #define WASMTIME_CONF_H +// WASMTIME_FEATURE_LIST #cmakedefine WASMTIME_FEATURE_PROFILING #cmakedefine WASMTIME_FEATURE_WAT #cmakedefine WASMTIME_FEATURE_CACHE @@ -22,6 +23,8 @@ #cmakedefine WASMTIME_FEATURE_ASYNC #cmakedefine WASMTIME_FEATURE_CRANELIFT #cmakedefine WASMTIME_FEATURE_WINCH +// ... if you add a line above this be sure to change the other locations +// marked WASMTIME_FEATURE_LIST #if defined(WASMTIME_FEATURE_CRANELIFT) || defined(WASMTIME_FEATURE_WINCH) #define WASMTIME_FEATURE_COMPILER From 59692fa33a667b8cf28d28e927ee0de5e996d5ba Mon Sep 17 00:00:00 2001 From: Ryan Patterson Date: Tue, 30 Jul 2024 08:42:10 +0600 Subject: [PATCH 03/16] Install all headers to same directory --- crates/c-api/CMakeLists.txt | 8 +++++--- crates/c-api/README.md | 1 - crates/c-api/build.rs | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/c-api/CMakeLists.txt b/crates/c-api/CMakeLists.txt index df5075281fa5..5575224644f1 100644 --- a/crates/c-api/CMakeLists.txt +++ b/crates/c-api/CMakeLists.txt @@ -145,15 +145,15 @@ target_include_directories(wasmtime INTERFACE ${CMAKE_BINARY_DIR}/include) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/include/wasmtime/conf.h.in ${WASMTIME_GENERATED_CONF_H}) -add_custom_target(conf_h - DEPENDS ${WASMTIME_GENERATED_CONF_H}) include(GNUInstallDirs) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + COMPONENT Headers FILES_MATCHING REGEX "\\.hh?$") install(FILES ${WASMTIME_GENERATED_CONF_H} - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wasmtime) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wasmtime + COMPONENT Headers) install(FILES ${WASMTIME_SHARED_FILES} ${WASMTIME_STATIC_FILES} DESTINATION ${CMAKE_INSTALL_LIBDIR}) @@ -172,3 +172,5 @@ add_custom_target(doc COMMAND doxygen ${DOXYGEN_CONF_OUT} DEPENDS ${WASMTIME_GENERATED_CONF_H} ${DOXYGEN_CONF_OUT} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) +add_custom_target(headers + COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --component Headers) diff --git a/crates/c-api/README.md b/crates/c-api/README.md index da2ce6a4a03f..7a858cab86e2 100644 --- a/crates/c-api/README.md +++ b/crates/c-api/README.md @@ -59,7 +59,6 @@ fn main() { // Wasm C API headers. cfg .include(std::env::var("DEP_WASMTIME_C_API_INCLUDE").unwrap()); - .include(std::env::var("DEP_WASMTIME_C_API_CONF_INCLUDE").unwrap()); // Compile your C code. cfg diff --git a/crates/c-api/build.rs b/crates/c-api/build.rs index 9ffec00d9d46..a784f90c40fc 100644 --- a/crates/c-api/build.rs +++ b/crates/c-api/build.rs @@ -28,7 +28,8 @@ fn main() { let mut config = cmake::Config::new(&dir); config .define("WASMTIME_DISABLE_ALL_FEATURES", "ON") - .build_target("conf_h"); + .always_configure(true) + .build_target("headers"); for f in FEATURES { if env::var_os(format!("CARGO_FEATURE_{}", f)).is_some() { config.define(format!("WASMTIME_FEATURE_{}", f), "ON"); @@ -36,6 +37,5 @@ fn main() { } let dst = config.build(); - println!("cargo:conf-include={}/build/include", dst.display()); - println!("cargo:include={}/include", dir.display()); + println!("cargo:include={}/include", dst.display()); } From 5fe2ccdc4babe8eee36428873861d529f1f5adb1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 30 Jul 2024 07:23:29 -0700 Subject: [PATCH 04/16] Add vets --- supply-chain/audits.toml | 12 ++++++++++++ supply-chain/imports.lock | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml index b6ab2e4418f7..4fc53f70c6a4 100644 --- a/supply-chain/audits.toml +++ b/supply-chain/audits.toml @@ -1240,6 +1240,12 @@ who = "Pat Hickey " criteria = "safe-to-deploy" version = "0.2.0" +[[audits.cmake]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +delta = "0.1.49 -> 0.1.50" +notes = "Only minor changes made" + [[audits.cobs]] who = "Alex Crichton " criteria = "safe-to-deploy" @@ -3648,6 +3654,12 @@ user-id = 6743 # Ed Page (epage) start = "2022-04-15" end = "2024-07-06" +[[trusted.cmake]] +criteria = "safe-to-deploy" +user-id = 1 # Alex Crichton (alexcrichton) +start = "2019-03-26" +end = "2025-07-30" + [[trusted.cpp_demangle]] criteria = "safe-to-deploy" user-id = 696 # Nick Fitzgerald (fitzgen) diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock index d5bd5c011cdf..eced87abd989 100644 --- a/supply-chain/imports.lock +++ b/supply-chain/imports.lock @@ -1602,6 +1602,12 @@ criteria = "safe-to-run" version = "0.3.0" aggregated-from = "https://chromium.googlesource.com/chromiumos/third_party/rust_crates/+/main/cargo-vet/audits.toml?format=TEXT" +[[audits.google.audits.cmake]] +who = "George Burgess IV " +criteria = "safe-to-deploy" +version = "0.1.49" +aggregated-from = "https://chromium.googlesource.com/chromiumos/third_party/rust_crates/+/main/cargo-vet/audits.toml?format=TEXT" + [[audits.google.audits.dirs-next]] who = "George Burgess IV " criteria = "safe-to-deploy" From 274df2d52a8568f99e608f59046b20a948a15dea Mon Sep 17 00:00:00 2001 From: Ryan Patterson Date: Wed, 31 Jul 2024 07:43:32 +0600 Subject: [PATCH 05/16] attempt to fix ci --- .github/workflows/main.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ada3daffbc6f..8d3130491459 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1053,6 +1053,13 @@ jobs: with: target: ${{ matrix.target }} + # Update binutils if MinGW due to https://github.com/rust-lang/rust/issues/112368 + - run: C:/msys64/usr/bin/pacman.exe -S --needed mingw-w64-x86_64-gcc --noconfirm + if: matrix.target == 'x86_64-pc-windows-gnu' + - shell: pwsh + run: echo "C:\msys64\mingw64\bin" >> $Env:GITHUB_PATH + if: matrix.target == 'x86_64-pc-windows-gnu' + - run: $CENTOS ./ci/build-release-artifacts.sh "${{ matrix.build }}" "${{ matrix.target }}" # Assemble release artifacts appropriate for this platform, then upload them From cacb0b70abc296cc38e5c914b893bbfdb75292fd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 31 Jul 2024 07:49:42 -0700 Subject: [PATCH 06/16] Run all tests on CI prtest:full From 837eb63bc71aa35cb50a51c7b8f36812ff5d1f74 Mon Sep 17 00:00:00 2001 From: Ryan Patterson Date: Thu, 1 Aug 2024 08:25:31 +0600 Subject: [PATCH 07/16] Set CARGO_BUILD_TARGET; add CMakeLists to package --- .github/workflows/main.yml | 17 ++++++++++------- crates/c-api/CMakeLists.txt | 3 +++ crates/c-api/Cargo.toml | 2 +- scripts/publish.rs | 2 ++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8d3130491459..c3350ec38e6e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1039,6 +1039,16 @@ jobs: - run: | rustup component add rust-src rustup target add ${{ matrix.target }} + # Update binutils if MinGW due to https://github.com/rust-lang/rust/issues/112368 + - run: C:/msys64/usr/bin/pacman.exe -S --needed mingw-w64-x86_64-gcc --noconfirm + if: matrix.target == 'x86_64-pc-windows-gnu' + - shell: pwsh + run: | + echo "C:\msys64\mingw64\bin" >> $Env:GITHUB_PATH + echo "CC=gcc" >> $Env:GITHUB_ENV + echo "CXX=g++" >> $Env:GITHUB_ENV + if: matrix.target == 'x86_64-pc-windows-gnu' + # On one builder produce the source tarball since there's no need to produce # it everywhere @@ -1053,13 +1063,6 @@ jobs: with: target: ${{ matrix.target }} - # Update binutils if MinGW due to https://github.com/rust-lang/rust/issues/112368 - - run: C:/msys64/usr/bin/pacman.exe -S --needed mingw-w64-x86_64-gcc --noconfirm - if: matrix.target == 'x86_64-pc-windows-gnu' - - shell: pwsh - run: echo "C:\msys64\mingw64\bin" >> $Env:GITHUB_PATH - if: matrix.target == 'x86_64-pc-windows-gnu' - - run: $CENTOS ./ci/build-release-artifacts.sh "${{ matrix.build }}" "${{ matrix.target }}" # Assemble release artifacts appropriate for this platform, then upload them diff --git a/crates/c-api/CMakeLists.txt b/crates/c-api/CMakeLists.txt index 5575224644f1..f61e4a3328b6 100644 --- a/crates/c-api/CMakeLists.txt +++ b/crates/c-api/CMakeLists.txt @@ -99,6 +99,9 @@ find_program(WASMTIME_CARGO_BINARY cargo) if(NOT WASMTIME_CARGO_BINARY) message(FATAL_ERROR [["cargo" was not found. Ensure "cargo" is in PATH. Aborting...]]) endif() +# Note: this line will *always* create ${CMAKE_CURRENT_SOURCE_DIR}/artifact +# during the configure stage of cmake, and there does not seem to be a way to +# disable this behavior. This prevents cargo package from verifying the package. ExternalProject_Add( wasmtime-crate DOWNLOAD_COMMAND "" diff --git a/crates/c-api/Cargo.toml b/crates/c-api/Cargo.toml index 276b01d64df6..6cfe559c60d4 100644 --- a/crates/c-api/Cargo.toml +++ b/crates/c-api/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/bytecodealliance/wasmtime" readme = "README.md" edition.workspace = true links = "wasmtime-c-api" -include = ["include", "src", "build.rs"] +include = ["include", "src", "build.rs", "CMakeLists.txt", "doxygen.conf.in"] [lints] workspace = true diff --git a/scripts/publish.rs b/scripts/publish.rs index b3fcf215413e..978a5fdb774c 100644 --- a/scripts/publish.rs +++ b/scripts/publish.rs @@ -522,6 +522,8 @@ fn verify(crates: &[Crate]) { .env("CARGO_TARGET_DIR", "./target"); if krate.name.contains("wasi-nn") { cmd.arg("--no-verify"); + } else if krate.name == "wasmtime-c-api-impl" { + cmd.arg("--no-verify"); } run_cmd(&mut cmd); run_cmd( From 83f681ab8440cd59dc28fa7143e888c848b36849 Mon Sep 17 00:00:00 2001 From: Ryan Patterson Date: Fri, 2 Aug 2024 06:17:55 +0600 Subject: [PATCH 08/16] Update comment on github action --- .github/workflows/main.yml | 2 +- Cargo.toml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c3350ec38e6e..fd3469e95872 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1039,7 +1039,7 @@ jobs: - run: | rustup component add rust-src rustup target add ${{ matrix.target }} - # Update binutils if MinGW due to https://github.com/rust-lang/rust/issues/112368 + # Without these two, cmake -G "MSYS Makefiles" will select MSVC as the compiler. - run: C:/msys64/usr/bin/pacman.exe -S --needed mingw-w64-x86_64-gcc --noconfirm if: matrix.target == 'x86_64-pc-windows-gnu' - shell: pwsh diff --git a/Cargo.toml b/Cargo.toml index d9059edc2736..a804dc431c26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -345,6 +345,9 @@ semver = { version = "1.0.17", default-features = false } # in configuring binary size and or exploring the binary size implications of # various features. Most features are enabled by default but most embeddings # likely won't need all features. +# +# When adding or removing a feature, make sure to kepe the C API in sync by +# modifying locations marked WASMTIME_FEATURE_LIST [features] default = [ # All subcommands are included by default. From a0fe133457ad5ecd0fac6943b7007c4bd24c2f4d Mon Sep 17 00:00:00 2001 From: Ryan Patterson Date: Fri, 2 Aug 2024 06:36:22 +0600 Subject: [PATCH 09/16] Attempt to fix android build --- .github/actions/android-ndk/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/android-ndk/action.yml b/.github/actions/android-ndk/action.yml index cbf88a14f891..4df8856aaa09 100644 --- a/.github/actions/android-ndk/action.yml +++ b/.github/actions/android-ndk/action.yml @@ -29,4 +29,6 @@ runs: echo CC_${cc_target}=$linker >> $GITHUB_ENV echo RANLIB_${cc_target}=$ndk_bin/llvm-ranlib >> $GITHUB_ENV echo AR_${cc_target}=$ndk_bin/llvm-ar >> $GITHUB_ENV + echo CMAKE_MAKE_PROGRAM=make >> $GITHUB_ENV + echo "$ndk_bin" >> $GITHUB_PATH shell: bash From 7a7ae91b0c74b872545fefe1f75e7f5bc1590bad Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 2 Aug 2024 07:10:24 -0700 Subject: [PATCH 10/16] Fix source dir modifications of c-api build --- crates/c-api/CMakeLists.txt | 4 ---- scripts/publish.rs | 2 -- 2 files changed, 6 deletions(-) diff --git a/crates/c-api/CMakeLists.txt b/crates/c-api/CMakeLists.txt index f61e4a3328b6..ce6000ea6568 100644 --- a/crates/c-api/CMakeLists.txt +++ b/crates/c-api/CMakeLists.txt @@ -99,9 +99,6 @@ find_program(WASMTIME_CARGO_BINARY cargo) if(NOT WASMTIME_CARGO_BINARY) message(FATAL_ERROR [["cargo" was not found. Ensure "cargo" is in PATH. Aborting...]]) endif() -# Note: this line will *always* create ${CMAKE_CURRENT_SOURCE_DIR}/artifact -# during the configure stage of cmake, and there does not seem to be a way to -# disable this behavior. This prevents cargo package from verifying the package. ExternalProject_Add( wasmtime-crate DOWNLOAD_COMMAND "" @@ -115,7 +112,6 @@ ExternalProject_Add( ${WASMTIME_FEATURES} ${WASMTIME_USER_CARGO_BUILD_OPTIONS} USES_TERMINAL_BUILD TRUE - BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/artifact BUILD_ALWAYS ${WASMTIME_ALWAYS_BUILD} BUILD_BYPRODUCTS ${WASMTIME_SHARED_FILES} ${WASMTIME_STATIC_FILES}) add_library(wasmtime INTERFACE) diff --git a/scripts/publish.rs b/scripts/publish.rs index 978a5fdb774c..b3fcf215413e 100644 --- a/scripts/publish.rs +++ b/scripts/publish.rs @@ -522,8 +522,6 @@ fn verify(crates: &[Crate]) { .env("CARGO_TARGET_DIR", "./target"); if krate.name.contains("wasi-nn") { cmd.arg("--no-verify"); - } else if krate.name == "wasmtime-c-api-impl" { - cmd.arg("--no-verify"); } run_cmd(&mut cmd); run_cmd( From 4a4ebc19fec47426333feb35aeecdc3f84b490fd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 2 Aug 2024 07:21:30 -0700 Subject: [PATCH 11/16] Re-add BINARY_DIR option --- crates/c-api/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/c-api/CMakeLists.txt b/crates/c-api/CMakeLists.txt index ce6000ea6568..a245f965faa7 100644 --- a/crates/c-api/CMakeLists.txt +++ b/crates/c-api/CMakeLists.txt @@ -112,6 +112,9 @@ ExternalProject_Add( ${WASMTIME_FEATURES} ${WASMTIME_USER_CARGO_BUILD_OPTIONS} USES_TERMINAL_BUILD TRUE + # Note that this is used as the cwd for the cargo invocation itself, build + # byproducts go in the `target` directory at the top-level. + BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR} BUILD_ALWAYS ${WASMTIME_ALWAYS_BUILD} BUILD_BYPRODUCTS ${WASMTIME_SHARED_FILES} ${WASMTIME_STATIC_FILES}) add_library(wasmtime INTERFACE) From 82502963ec7509e65036287a6d8aba97d262cee1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 2 Aug 2024 07:36:53 -0700 Subject: [PATCH 12/16] Fix build --- crates/c-api/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/c-api/CMakeLists.txt b/crates/c-api/CMakeLists.txt index a245f965faa7..10d70d5da43d 100644 --- a/crates/c-api/CMakeLists.txt +++ b/crates/c-api/CMakeLists.txt @@ -108,6 +108,7 @@ ExternalProject_Add( ${CMAKE_COMMAND} -E env ${CARGO_PROFILE_PANIC}=abort ${WASMTIME_CARGO_BINARY} build --target ${WASMTIME_TARGET} + --package wasmtime-c-api ${WASMTIME_BUILD_TYPE_FLAG} ${WASMTIME_FEATURES} ${WASMTIME_USER_CARGO_BUILD_OPTIONS} From 1c60a0cd631ca4c2eac8a01a0cc144eacdf07b6c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 2 Aug 2024 08:52:40 -0700 Subject: [PATCH 13/16] Move header installation to a cmake script Try to avoid dealing with cmake configuration/platforms/etc. --- .github/actions/android-ndk/action.yml | 2 - .github/workflows/main.yml | 10 ---- Cargo.lock | 10 ---- crates/c-api/CMakeLists.txt | 67 ++++-------------------- crates/c-api/Cargo.toml | 3 -- crates/c-api/build.rs | 32 ++++++----- crates/c-api/cmake/features.cmake | 45 ++++++++++++++++ crates/c-api/cmake/install-headers.cmake | 14 +++++ crates/c-api/doxygen.conf.in | 4 +- supply-chain/audits.toml | 12 ----- supply-chain/imports.lock | 6 --- 11 files changed, 88 insertions(+), 117 deletions(-) create mode 100644 crates/c-api/cmake/features.cmake create mode 100644 crates/c-api/cmake/install-headers.cmake diff --git a/.github/actions/android-ndk/action.yml b/.github/actions/android-ndk/action.yml index 4df8856aaa09..cbf88a14f891 100644 --- a/.github/actions/android-ndk/action.yml +++ b/.github/actions/android-ndk/action.yml @@ -29,6 +29,4 @@ runs: echo CC_${cc_target}=$linker >> $GITHUB_ENV echo RANLIB_${cc_target}=$ndk_bin/llvm-ranlib >> $GITHUB_ENV echo AR_${cc_target}=$ndk_bin/llvm-ar >> $GITHUB_ENV - echo CMAKE_MAKE_PROGRAM=make >> $GITHUB_ENV - echo "$ndk_bin" >> $GITHUB_PATH shell: bash diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fd3469e95872..ada3daffbc6f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1039,16 +1039,6 @@ jobs: - run: | rustup component add rust-src rustup target add ${{ matrix.target }} - # Without these two, cmake -G "MSYS Makefiles" will select MSVC as the compiler. - - run: C:/msys64/usr/bin/pacman.exe -S --needed mingw-w64-x86_64-gcc --noconfirm - if: matrix.target == 'x86_64-pc-windows-gnu' - - shell: pwsh - run: | - echo "C:\msys64\mingw64\bin" >> $Env:GITHUB_PATH - echo "CC=gcc" >> $Env:GITHUB_ENV - echo "CXX=g++" >> $Env:GITHUB_ENV - if: matrix.target == 'x86_64-pc-windows-gnu' - # On one builder produce the source tarball since there's no need to produce # it everywhere diff --git a/Cargo.lock b/Cargo.lock index b91fd27b895d..fd7e5727d4aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -455,15 +455,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" -[[package]] -name = "cmake" -version = "0.1.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" -dependencies = [ - "cc", -] - [[package]] name = "cobs" version = "0.2.3" @@ -3476,7 +3467,6 @@ version = "25.0.0" dependencies = [ "anyhow", "cap-std", - "cmake", "env_logger", "futures", "log", diff --git a/crates/c-api/CMakeLists.txt b/crates/c-api/CMakeLists.txt index 10d70d5da43d..1e6ba4a74da5 100644 --- a/crates/c-api/CMakeLists.txt +++ b/crates/c-api/CMakeLists.txt @@ -14,51 +14,7 @@ if(WASMTIME_TARGET STREQUAL "") set(WASMTIME_TARGET ${RUSTC_HOST_TARGET}) endif() -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 +include(cmake/features.cmake) if(WASMTIME_FASTEST_RUNTIME) set(WASMTIME_BUILD_TYPE_FLAG "--profile=fastest-runtime") @@ -142,21 +98,18 @@ endif() target_include_directories(wasmtime INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) -set(WASMTIME_GENERATED_CONF_H ${CMAKE_BINARY_DIR}/include/wasmtime/conf.h) target_include_directories(wasmtime INTERFACE ${CMAKE_BINARY_DIR}/include) -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/include/wasmtime/conf.h.in - ${WASMTIME_GENERATED_CONF_H}) +execute_process( + COMMAND + ${CMAKE_COMMAND} + -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/include + -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/install-headers.cmake + OUTPUT_QUIET + COMMAND_ERROR_IS_FATAL ANY) include(GNUInstallDirs) -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - COMPONENT Headers - FILES_MATCHING REGEX "\\.hh?$") -install(FILES ${WASMTIME_GENERATED_CONF_H} - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wasmtime - COMPONENT Headers) +install(SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/cmake/install-headers.cmake) install(FILES ${WASMTIME_SHARED_FILES} ${WASMTIME_STATIC_FILES} DESTINATION ${CMAKE_INSTALL_LIBDIR}) @@ -175,5 +128,3 @@ add_custom_target(doc COMMAND doxygen ${DOXYGEN_CONF_OUT} DEPENDS ${WASMTIME_GENERATED_CONF_H} ${DOXYGEN_CONF_OUT} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) -add_custom_target(headers - COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --component Headers) diff --git a/crates/c-api/Cargo.toml b/crates/c-api/Cargo.toml index 6cfe559c60d4..a8a9564c251a 100644 --- a/crates/c-api/Cargo.toml +++ b/crates/c-api/Cargo.toml @@ -38,9 +38,6 @@ wasmtime-wasi = { workspace = true, optional = true, features = ["preview1"] } # Optional dependencies for the `async` feature futures = { workspace = true, optional = true } -[build-dependencies] -cmake = "0.1" - [features] # WASMTIME_FEATURE_LIST async = ['wasmtime/async', 'futures'] diff --git a/crates/c-api/build.rs b/crates/c-api/build.rs index a784f90c40fc..6db41dec75cc 100644 --- a/crates/c-api/build.rs +++ b/crates/c-api/build.rs @@ -1,5 +1,5 @@ -use cmake; -use std::{env, path::PathBuf}; +use std::env; +use std::process::Command; // WASMTIME_FEATURE_LIST const FEATURES: &[&str] = &[ @@ -22,20 +22,24 @@ const FEATURES: &[&str] = &[ // marked WASMTIME_FEATURE_LIST fn main() { - println!("cargo:rerun-if-changed=CMakesLists.txt"); - println!("cargo:rerun-if-changed=include/wasmtime/conf.h.in"); - let dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()); - let mut config = cmake::Config::new(&dir); - config - .define("WASMTIME_DISABLE_ALL_FEATURES", "ON") - .always_configure(true) - .build_target("headers"); + 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() { - config.define(format!("WASMTIME_FEATURE_{}", f), "ON"); + if env::var_os(format!("CARGO_FEATURE_{f}")).is_some() { + cmake.arg(format!("-DWASMTIME_FEATURE_{f}=ON")); } } - let dst = config.build(); - println!("cargo:include={}/include", dst.display()); + 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"); } diff --git a/crates/c-api/cmake/features.cmake b/crates/c-api/cmake/features.cmake new file mode 100644 index 000000000000..44ae4b9b5ec3 --- /dev/null +++ b/crates/c-api/cmake/features.cmake @@ -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 diff --git a/crates/c-api/cmake/install-headers.cmake b/crates/c-api/cmake/install-headers.cmake new file mode 100644 index 000000000000..a4efd5d8d3e3 --- /dev/null +++ b/crates/c-api/cmake/install-headers.cmake @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.12) + +include(${CMAKE_CURRENT_LIST_DIR}/features.cmake) + +set(dst "${CMAKE_INSTALL_PREFIX}/include") +message(STATUS "dst: ${dst}") +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?$") diff --git a/crates/c-api/doxygen.conf.in b/crates/c-api/doxygen.conf.in index 1f6645dfda93..6ba0b993b710 100644 --- a/crates/c-api/doxygen.conf.in +++ b/crates/c-api/doxygen.conf.in @@ -864,7 +864,7 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = include @CMAKE_BINARY_DIR@/include +INPUT = @CMAKE_BINARY_DIR@/include # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses @@ -2162,7 +2162,7 @@ SEARCH_INCLUDES = YES # preprocessor. # This tag requires that the tag SEARCH_INCLUDES is set to YES. -INCLUDE_PATH = include @CMAKE_BINARY_DIR@/include +INCLUDE_PATH = @CMAKE_BINARY_DIR@/include # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml index 4fc53f70c6a4..b6ab2e4418f7 100644 --- a/supply-chain/audits.toml +++ b/supply-chain/audits.toml @@ -1240,12 +1240,6 @@ who = "Pat Hickey " criteria = "safe-to-deploy" version = "0.2.0" -[[audits.cmake]] -who = "Alex Crichton " -criteria = "safe-to-deploy" -delta = "0.1.49 -> 0.1.50" -notes = "Only minor changes made" - [[audits.cobs]] who = "Alex Crichton " criteria = "safe-to-deploy" @@ -3654,12 +3648,6 @@ user-id = 6743 # Ed Page (epage) start = "2022-04-15" end = "2024-07-06" -[[trusted.cmake]] -criteria = "safe-to-deploy" -user-id = 1 # Alex Crichton (alexcrichton) -start = "2019-03-26" -end = "2025-07-30" - [[trusted.cpp_demangle]] criteria = "safe-to-deploy" user-id = 696 # Nick Fitzgerald (fitzgen) diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock index eced87abd989..d5bd5c011cdf 100644 --- a/supply-chain/imports.lock +++ b/supply-chain/imports.lock @@ -1602,12 +1602,6 @@ criteria = "safe-to-run" version = "0.3.0" aggregated-from = "https://chromium.googlesource.com/chromiumos/third_party/rust_crates/+/main/cargo-vet/audits.toml?format=TEXT" -[[audits.google.audits.cmake]] -who = "George Burgess IV " -criteria = "safe-to-deploy" -version = "0.1.49" -aggregated-from = "https://chromium.googlesource.com/chromiumos/third_party/rust_crates/+/main/cargo-vet/audits.toml?format=TEXT" - [[audits.google.audits.dirs-next]] who = "George Burgess IV " criteria = "safe-to-deploy" From 6abfa1cc51304d226280daccba2e55e387f79be2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 2 Aug 2024 09:07:12 -0700 Subject: [PATCH 14/16] Tweak build of headers --- crates/c-api/CMakeLists.txt | 17 +++++++++-------- crates/c-api/include/wasmtime/async.h | 10 +++++----- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/crates/c-api/CMakeLists.txt b/crates/c-api/CMakeLists.txt index 1e6ba4a74da5..15dfd7061e2a 100644 --- a/crates/c-api/CMakeLists.txt +++ b/crates/c-api/CMakeLists.txt @@ -100,14 +100,6 @@ target_include_directories(wasmtime INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/includ target_include_directories(wasmtime INTERFACE ${CMAKE_BINARY_DIR}/include) -execute_process( - COMMAND - ${CMAKE_COMMAND} - -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/include - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/install-headers.cmake - OUTPUT_QUIET - COMMAND_ERROR_IS_FATAL ANY) - include(GNUInstallDirs) install(SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/cmake/install-headers.cmake) install(FILES ${WASMTIME_SHARED_FILES} ${WASMTIME_STATIC_FILES} @@ -128,3 +120,12 @@ add_custom_target(doc COMMAND doxygen ${DOXYGEN_CONF_OUT} DEPENDS ${WASMTIME_GENERATED_CONF_H} ${DOXYGEN_CONF_OUT} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) +add_dependencies(doc headers-to-doc) + +file(GLOB headers "include/*.h") +add_custom_target(headers-to-doc + COMMAND + ${CMAKE_COMMAND} + -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/include + -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/install-headers.cmake + DEPENDS ${headers}) diff --git a/crates/c-api/include/wasmtime/async.h b/crates/c-api/include/wasmtime/async.h index d2a8d125d56c..c0f6a14b4fd6 100644 --- a/crates/c-api/include/wasmtime/async.h +++ b/crates/c-api/include/wasmtime/async.h @@ -11,22 +11,22 @@ * are three mechanisms for yielding control from wasm to the caller: fuel, * epochs, and async host functions. * - * When WebAssembly is executed, a #wasmtime_call_future_t is returned. This + * When WebAssembly is executed, a `wasmtime_call_future_t` is returned. This * struct represents the state of the execution and each call to - * #wasmtime_call_future_poll will execute the WebAssembly code on a separate + * `wasmtime_call_future_poll` will execute the WebAssembly code on a separate * stack until the function returns or yields control back to the caller. * * It's expected these futures are pulled in a loop until completed, at which * point the future should be deleted. Functions that return a - * #wasmtime_call_future_t are special in that all parameters to that function + * `wasmtime_call_future_t` are special in that all parameters to that function * should not be modified in any way and must be kept alive until the future is * deleted. This includes concurrent calls for a single store - another function - * on a store should not be called while there is a #wasmtime_call_future_t + * on a store should not be called while there is a `wasmtime_call_future_t` * alive. * * As for asynchronous host calls - the reverse contract is upheld. Wasmtime * will keep all parameters to the function alive and unmodified until the - * #wasmtime_func_async_continuation_callback_t returns true. + * `wasmtime_func_async_continuation_callback_t` returns true. * */ From 4c760471473a6e717809aa57501af895766ee6f2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 2 Aug 2024 09:11:35 -0700 Subject: [PATCH 15/16] Install headers in build dir for examples --- crates/c-api/CMakeLists.txt | 4 ++-- crates/c-api/cmake/install-headers.cmake | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/c-api/CMakeLists.txt b/crates/c-api/CMakeLists.txt index 15dfd7061e2a..9b14f7167ec3 100644 --- a/crates/c-api/CMakeLists.txt +++ b/crates/c-api/CMakeLists.txt @@ -96,9 +96,9 @@ else() endif() endif() -target_include_directories(wasmtime INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) - target_include_directories(wasmtime INTERFACE ${CMAKE_BINARY_DIR}/include) +set(WASMTIME_HEADER_DST ${CMAKE_BINARY_DIR}/include) +include(cmake/install-headers.cmake) include(GNUInstallDirs) install(SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/cmake/install-headers.cmake) diff --git a/crates/c-api/cmake/install-headers.cmake b/crates/c-api/cmake/install-headers.cmake index a4efd5d8d3e3..2468cfa77768 100644 --- a/crates/c-api/cmake/install-headers.cmake +++ b/crates/c-api/cmake/install-headers.cmake @@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.12) include(${CMAKE_CURRENT_LIST_DIR}/features.cmake) -set(dst "${CMAKE_INSTALL_PREFIX}/include") -message(STATUS "dst: ${dst}") +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") From 27ab7be7071065d43e2c3a55e0e66c62fd2b0549 Mon Sep 17 00:00:00 2001 From: Ryan Patterson Date: Thu, 8 Aug 2024 07:35:54 +0600 Subject: [PATCH 16/16] Add cmake files to dist, fix header install dir --- crates/c-api/CMakeLists.txt | 2 +- crates/c-api/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/c-api/CMakeLists.txt b/crates/c-api/CMakeLists.txt index 9b14f7167ec3..09e8104a2710 100644 --- a/crates/c-api/CMakeLists.txt +++ b/crates/c-api/CMakeLists.txt @@ -126,6 +126,6 @@ file(GLOB headers "include/*.h") add_custom_target(headers-to-doc COMMAND ${CMAKE_COMMAND} - -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/include + -DWASMTIME_HEADER_DST=${CMAKE_BINARY_DIR}/include -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/install-headers.cmake DEPENDS ${headers}) diff --git a/crates/c-api/Cargo.toml b/crates/c-api/Cargo.toml index a8a9564c251a..ccf78db10b8a 100644 --- a/crates/c-api/Cargo.toml +++ b/crates/c-api/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/bytecodealliance/wasmtime" readme = "README.md" edition.workspace = true links = "wasmtime-c-api" -include = ["include", "src", "build.rs", "CMakeLists.txt", "doxygen.conf.in"] +include = ["include", "src", "build.rs", "CMakeLists.txt", "cmake", "doxygen.conf.in"] [lints] workspace = true