Skip to content

Commit

Permalink
More installation in cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed May 17, 2024
1 parent 82322a2 commit 273ac83
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
6 changes: 3 additions & 3 deletions ci/build-release-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ if [[ "$build" = *-min ]]; then
flags="$build_std $build_std_features --no-default-features --features disable-logging"
cmake_flags="-DWASMTIME_DISABLE_ALL_FEATURES=ON"
cmake_flags="$cmake_flags -DWASMTIME_FEATURE_DISABLE_LOGGING=ON"
cmake_flags="$cmake_flags -DWASMTIME_TARGET=$target"
cmake_flags="$cmake_flags -DWASMTIME_USER_CARGO_BUILD_OPTIONS:LIST=$build_std;$build_std_features"
else
# For release builds the CLI is built a bit more feature-ful than the Cargo
# defaults to provide artifacts that can do as much as possible.
bin_flags="--features all-arch,component-model"
fi

cargo build --release $flags --target $target -p wasmtime-cli $bin_flags --features run
#cargo build --release $flags --target $target -p wasmtime-cli $bin_flags --features run

cmake \
-S crates/c-api \
-B target/c-api-build \
$cmake_flags \
-DWASMTIME_TARGET=$target \
-DCMAKE_INSTALL_PREFIX=target/c-api-install
cmake --build target/c-api-build --target install
cmake --build target/c-api-build --target install -v
21 changes: 6 additions & 15 deletions ci/build-tarballs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,24 @@ mkdir tmp/$api_pkgname/include
mkdir tmp/$bin_pkgname
cp LICENSE README.md tmp/$api_pkgname
cp LICENSE README.md tmp/$bin_pkgname
cp -r $api_install/include tmp/$api_pkgname

# For *-min builds rename artifacts with a `-min` suffix to avoid eventual
# clashes with the normal builds when the tarballs are unioned together.
if [[ $build == *-min ]]; then
min="-min"
cp -r $api_install/include tmp/$api_pkgname/min
cp -r $api_install/lib tmp/$api_pkgname/min
else
cp -r $api_install/include tmp/$api_pkgname
cp -r $api_install/lib tmp/$api_pkgname
fi


fmt=tar

case $build in
x86_64-windows*)
cp target/$target/release/wasmtime.exe tmp/$bin_pkgname/wasmtime$min.exe
cp $api_install/wasmtime.dll tmp/$api_pkgname/lib/wasmtime$min.dll
cp $api_install/wasmtime.lib tmp/$api_pkgname/lib/wasmtime$min.lib
cp $api_install/wasmtime.dll.lib tmp/$api_pkgname/lib/wasmtime$min.dll.lib
fmt=zip

if [ "$min" = "" ]; then
Expand All @@ -70,26 +72,15 @@ case $build in

x86_64-mingw*)
cp target/$target/release/wasmtime.exe tmp/$bin_pkgname/wasmtime$min.exe
cp $api_install/wasmtime.dll tmp/$api_pkgname/lib/wasmtime$min.dll
cp $api_install/libwasmtime.a tmp/$api_pkgname/lib/libwasmtime$min.a
cp $api_install/libwasmtime.dll.a tmp/$api_pkgname/lib/libwasmtime$min.dll.a
fmt=zip
;;

*-macos*)
# Postprocess the macOS dylib a bit to have a more reasonable `LC_ID_DYLIB`
# directive than the default one that comes out of the linker when typically
# doing `cargo build`. For more info see #984
install_name_tool -id "@rpath/libwasmtime$min.dylib" target/$target/release/libwasmtime.dylib
cp target/$target/release/wasmtime tmp/$bin_pkgname/wasmtime$min
cp $api_install/libwasmtime.a tmp/$api_pkgname/lib/libwasmtime$min.a
cp $api_install/libwasmtime.dylib tmp/$api_pkgname/lib/libwasmtime$min.dylib
;;

*)
cp target/$target/release/wasmtime tmp/$bin_pkgname/wasmtime$min
cp $api_install/libwasmtime.a tmp/$api_pkgname/lib/libwasmtime$min.a
cp $api_install/libwasmtime.so tmp/$api_pkgname/lib/libwasmtime$min.so
;;
esac

Expand Down
15 changes: 13 additions & 2 deletions crates/c-api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ ExternalProject_Add(
${WASMTIME_USER_CARGO_BUILD_OPTIONS}
USES_TERMINAL_BUILD TRUE
BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/artifact
BUILD_ALWAYS ${WASMTIME_ALWAYS_BUILD}
BUILD_BYPRODUCTS ${WASMTIME_BUILD_PRODUCT})
BUILD_ALWAYS ${WASMTIME_ALWAYS_BUILD}
BUILD_BYPRODUCTS ${WASMTIME_SHARED_FILES} ${WASMTIME_STATIC_FILES})
add_library(wasmtime INTERFACE)
add_dependencies(wasmtime wasmtime-crate)

Expand Down Expand Up @@ -158,6 +158,17 @@ install(FILES ${WASMTIME_GENERATED_CONF_H}
install(FILES ${WASMTIME_SHARED_FILES} ${WASMTIME_STATIC_FILES}
DESTINATION ${CMAKE_INSTALL_LIBDIR})

if(WASMTIME_TARGET MATCHES "darwin")
# Postprocess the macOS dylib a bit to have a more reasonable `LC_ID_DYLIB`
# directive than the default one that comes out of the linker when typically
# doing `cargo build`. For more info see #984
# add_custom_target(set_dylib_rpath
# install_name_tool -id "@rpath/libwasmtime.dylib" ${WASMTIME_SHARED_FILES}
# DEPENDS wasmtime-crate)
set(INSTALLED_LIB ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libwasmtime.dylib)
install(CODE "execute_process(COMMAND install_name_tool -id \"@rpath/libwasmtime.dylib\" ${INSTALLED_LIB})")
endif()

set(DOXYGEN_CONF_IN ${CMAKE_CURRENT_SOURCE_DIR}/doxygen.conf.in)
set(DOXYGEN_CONF_OUT ${CMAKE_BINARY_DIR}/doxygen.conf)
configure_file(${DOXYGEN_CONF_IN} ${DOXYGEN_CONF_OUT})
Expand Down

0 comments on commit 273ac83

Please sign in to comment.