[boost] fix emscripten build (#29481)

* Update CMakeLists.txt

* print lib prefix and suffix

* set extension to bc

* wip: wasm .bc copy workaround

* hack wasm32 boost libs copy

* rename bc to a

* remove status messages

* update port ver

* run addver cmd
This commit is contained in:
Leonid Pospelov 2023-02-08 06:07:34 +06:00 committed by GitHub
parent 6015f38db2
commit 1c48ec7f49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 3 deletions

View File

@ -44,6 +44,8 @@ elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "mips64")
list(APPEND B2_OPTIONS architecture=mips64) list(APPEND B2_OPTIONS architecture=mips64)
elseif("arm64" IN_LIST VCPKG_TARGET_ARCHITECTURE AND "x86_64" IN_LIST VCPKG_TARGET_ARCHITECTURE) elseif("arm64" IN_LIST VCPKG_TARGET_ARCHITECTURE AND "x86_64" IN_LIST VCPKG_TARGET_ARCHITECTURE)
list(APPEND B2_OPTIONS architecture=arm+x86) list(APPEND B2_OPTIONS architecture=arm+x86)
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "wasm32")
# do nothing
else() else()
list(APPEND B2_OPTIONS architecture=x86) list(APPEND B2_OPTIONS architecture=x86)
endif() endif()
@ -63,6 +65,8 @@ if(VCPKG_DETECTED_MSVC)
else() else()
math(EXPR USER_CONFIG_TOOLSET_VERSION "${VCPKG_DETECTED_MSVC_VERSION} / 10 - 50") math(EXPR USER_CONFIG_TOOLSET_VERSION "${VCPKG_DETECTED_MSVC_VERSION} / 10 - 50")
endif() endif()
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "wasm32")
set(USER_CONFIG_TOOLSET emscripten)
elseif(VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID MATCHES "Clang") elseif(VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(USER_CONFIG_TOOLSET clang) set(USER_CONFIG_TOOLSET clang)
else() else()

View File

@ -53,7 +53,10 @@ function(boost_modular_build)
endif() endif()
else() else()
set(BOOST_LIB_PREFIX lib) set(BOOST_LIB_PREFIX lib)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") if(VCPKG_TARGET_ARCHITECTURE STREQUAL "wasm32")
set(BOOST_LIB_RELEASE_SUFFIX .bc)
set(BOOST_LIB_DEBUG_SUFFIX .bc)
elseif(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
set(BOOST_LIB_RELEASE_SUFFIX .a) set(BOOST_LIB_RELEASE_SUFFIX .a)
set(BOOST_LIB_DEBUG_SUFFIX .a) set(BOOST_LIB_DEBUG_SUFFIX .a)
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Darwin") elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Darwin")
@ -144,6 +147,30 @@ function(boost_modular_build)
"${CURRENT_PACKAGES_DIR}/debug/bin/*.pyd" "${CURRENT_PACKAGES_DIR}/debug/bin/*.pyd"
) )
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "wasm32")
# install .bc files
file(GLOB WASM_LIBS_RELEASE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/boost/build/*/${BOOST_LIB_PREFIX}*${BOOST_LIB_RELEASE_SUFFIX}")
file(GLOB WASM_LIBS_DEBUG "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/boost/build/*/${BOOST_LIB_PREFIX}*${BOOST_LIB_DEBUG_SUFFIX}")
file(COPY ${WASM_LIBS_RELEASE} DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
file(COPY ${WASM_LIBS_DEBUG} DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
# rename .bc to .a
file(GLOB WASM_LIBS_RELEASE "${CURRENT_PACKAGES_DIR}/lib/*.bc")
file(GLOB WASM_LIBS_DEBUG "${CURRENT_PACKAGES_DIR}/debug/lib/*.bc")
foreach(LIB IN LISTS WASM_LIBS_RELEASE)
get_filename_component(OLD_FILENAME ${LIB} NAME)
get_filename_component(DIRECTORY_OF_LIB_FILE ${LIB} DIRECTORY)
string(REPLACE ".bc" ".a" NEW_FILENAME ${OLD_FILENAME})
file(RENAME ${LIB} ${DIRECTORY_OF_LIB_FILE}/${NEW_FILENAME})
endforeach()
foreach(LIB IN LISTS WASM_LIBS_DEBUG)
get_filename_component(OLD_FILENAME ${LIB} NAME)
get_filename_component(DIRECTORY_OF_LIB_FILE ${LIB} DIRECTORY)
string(REPLACE ".bc" ".a" NEW_FILENAME ${OLD_FILENAME})
file(RENAME ${LIB} ${DIRECTORY_OF_LIB_FILE}/${NEW_FILENAME})
endforeach()
endif()
file(GLOB INSTALLED_LIBS "${CURRENT_PACKAGES_DIR}/debug/lib/*.lib" "${CURRENT_PACKAGES_DIR}/lib/*.lib") file(GLOB INSTALLED_LIBS "${CURRENT_PACKAGES_DIR}/debug/lib/*.lib" "${CURRENT_PACKAGES_DIR}/lib/*.lib")
foreach(LIB IN LISTS INSTALLED_LIBS) foreach(LIB IN LISTS INSTALLED_LIBS)
get_filename_component(OLD_FILENAME ${LIB} NAME) get_filename_component(OLD_FILENAME ${LIB} NAME)

View File

@ -2,7 +2,7 @@
"$comment": "Automatically generated by scripts/boost/generate-ports.ps1", "$comment": "Automatically generated by scripts/boost/generate-ports.ps1",
"name": "boost-modular-build-helper", "name": "boost-modular-build-helper",
"version": "1.81.0", "version": "1.81.0",
"port-version": 1, "port-version": 2,
"description": "Internal vcpkg port used to build Boost libraries", "description": "Internal vcpkg port used to build Boost libraries",
"license": "MIT", "license": "MIT",
"dependencies": [ "dependencies": [

View File

@ -1,5 +1,10 @@
{ {
"versions": [ "versions": [
{
"git-tree": "99f9bc3d7c9ac2864942f3f8d80a3d8db4689794",
"version": "1.81.0",
"port-version": 2
},
{ {
"git-tree": "6e28e9a445dc3442e89761e500fbb8bb5e175c00", "git-tree": "6e28e9a445dc3442e89761e500fbb8bb5e175c00",
"version": "1.81.0", "version": "1.81.0",

View File

@ -894,7 +894,7 @@
}, },
"boost-modular-build-helper": { "boost-modular-build-helper": {
"baseline": "1.81.0", "baseline": "1.81.0",
"port-version": 1 "port-version": 2
}, },
"boost-move": { "boost-move": {
"baseline": "1.81.0", "baseline": "1.81.0",