From a6257ac262f441a97869b7ec40ddc4bcce19570d Mon Sep 17 00:00:00 2001 From: Mohammed Alyousef Date: Wed, 3 Jun 2020 02:07:41 +0300 Subject: [PATCH] [vcpkg] add x86-wasm.cmake to community triplets (#11323) * add x86-wasm.cmake to community triplets The EMSDK enviroment variable is normally defined when first installing Emscripten. * Rename x86-wasm.cmake to wasm32-emscripten.cmake * Update wasm32-emscripten.cmake * Update wasm32-emscripten.cmake * Add wasm32 and wasm64 arch to docs * Create wasm64-emscripten.cmake * remove wasm64 * Delete wasm64-emscripten.cmake * Add wasm32 to list of identifiers * add emscripten VCPKG_CMAKE_SYSTEM_NAME support * add path check to EMSDK cmake toolchain --- .gitignore | 1 + docs/maintainers/control-files.md | 2 ++ docs/users/triplets.md | 3 ++- toolsrc/src/vcpkg/logicexpression.cpp | 6 ++++++ triplets/community/wasm32-emscripten.cmake | 15 +++++++++++++++ 5 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 triplets/community/wasm32-emscripten.cmake diff --git a/.gitignore b/.gitignore index 4f8ebfec665..65b0ddb81b0 100644 --- a/.gitignore +++ b/.gitignore @@ -313,6 +313,7 @@ __pycache__/ !triplets/community/arm-ios.cmake !triplets/community/x64-ios.cmake !triplets/community/x86-ios.cmake +!triplets/community/wasm32-emscripten.cmake !triplets/arm-uwp.cmake !triplets/x64-uwp.cmake !triplets/x64-windows.cmake diff --git a/docs/maintainers/control-files.md b/docs/maintainers/control-files.md index 87468e6af88..ea44c2b8ad9 100644 --- a/docs/maintainers/control-files.md +++ b/docs/maintainers/control-files.md @@ -138,6 +138,8 @@ The predefined expressions are computed from standard triplet settings: - `osx` - `VCPKG_CMAKE_SYSTEM_NAME` == `"Darwin"` - `android` - `VCPKG_CMAKE_SYSTEM_NAME` == `"Android"` - `static` - `VCPKG_LIBRARY_LINKAGE` == `"static"` +- `wasm32` - `VCPKG_TARGET_ARCHITECTURE` == `"wasm32"` +- `emscripten` - `VCPKG_CMAKE_SYSTEM_NAME` == `"Emscripten"` These predefined expressions can be overridden in the triplet file via the [`VCPKG_DEP_INFO_OVERRIDE_VARS`](../users/triplets.md) option. diff --git a/docs/users/triplets.md b/docs/users/triplets.md index aafae0920e9..9aa500d7611 100644 --- a/docs/users/triplets.md +++ b/docs/users/triplets.md @@ -29,7 +29,7 @@ Community Triplets are enabled by default, when using a community triplet a mess ### VCPKG_TARGET_ARCHITECTURE Specifies the target machine architecture. -Valid options are `x86`, `x64`, `arm`, and `arm64`. +Valid options are `x86`, `x64`, `arm`, `arm64` and `wasm32`. ### VCPKG_CRT_LINKAGE Specifies the desired CRT linkage (for MSVC). @@ -49,6 +49,7 @@ Valid options include any CMake system name, such as: - `WindowsStore` (Universal Windows Platform) - `Darwin` (Mac OSX) - `Linux` (Linux) +- `Emscripten` (WebAssembly) ### VCPKG_CMAKE_SYSTEM_VERSION Specifies the target platform system version. diff --git a/toolsrc/src/vcpkg/logicexpression.cpp b/toolsrc/src/vcpkg/logicexpression.cpp index 06d949e0685..5f3a25e8e90 100644 --- a/toolsrc/src/vcpkg/logicexpression.cpp +++ b/toolsrc/src/vcpkg/logicexpression.cpp @@ -25,6 +25,8 @@ namespace vcpkg osx, uwp, android, + emscripten, + wasm32, static_link, }; @@ -113,6 +115,8 @@ namespace vcpkg {"osx", Identifier::osx}, {"uwp", Identifier::uwp}, {"android", Identifier::android}, + {"emscripten", Identifier::emscripten}, + {"wasm32", Identifier::wasm32}, {"static", Identifier::static_link}, }; @@ -165,6 +169,8 @@ namespace vcpkg case Identifier::osx: return true_if_exists_and_equal("VCPKG_CMAKE_SYSTEM_NAME", "Darwin"); case Identifier::uwp: return true_if_exists_and_equal("VCPKG_CMAKE_SYSTEM_NAME", "WindowsStore"); case Identifier::android: return true_if_exists_and_equal("VCPKG_CMAKE_SYSTEM_NAME", "Android"); + case Identifier::emscripten: return true_if_exists_and_equal("VCPKG_CMAKE_SYSTEM_NAME", "Emscripten"); + case Identifier::wasm32: return true_if_exists_and_equal("VCPKG_TARGET_ARCHITECTURE", "wasm32"); case Identifier::static_link: return true_if_exists_and_equal("VCPKG_LIBRARY_LINKAGE", "static"); } diff --git a/triplets/community/wasm32-emscripten.cmake b/triplets/community/wasm32-emscripten.cmake new file mode 100644 index 00000000000..2394e12270c --- /dev/null +++ b/triplets/community/wasm32-emscripten.cmake @@ -0,0 +1,15 @@ +set(VCPKG_ENV_PASSTHROUGH EMSDK PATH) + +if(NOT DEFINED ENV{EMSDK}) + message(FATAL_ERROR "The EMSDK environment variable must be defined") +endif() + +if(NOT EXISTS $ENV{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake) + message(FATAL_ERROR "Emscripten.cmake toolchain file not found") +endif() + +set(VCPKG_TARGET_ARCHITECTURE wasm32) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_CMAKE_SYSTEM_NAME Emscripten) +set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE $ENV{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake)