mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
js: explicitly tell Emscripten which browsers to target
Emscripten has settings indicating which browser versions it should build code for. These are now by default slightly newer than I'd been targeting with my hand-written JavaScript. They also don't include Firefox 48, which KaiOS 2.5 is based on. This commit adds CMake variables to set the minimum versions that we pass to Emscripten. They default to the earliest versions with WebAssembly support, except that Firefox 48 is also supported. I think the main consequence of this change is to stop Emscripten using sign-extension and mutable-globals in WebAssembly, which it's done by default since version 3.1.26.
This commit is contained in:
@ -6,6 +6,20 @@ set(CMAKE_EXECUTABLE_SUFFIX ".js")
|
|||||||
set(WASM ON
|
set(WASM ON
|
||||||
CACHE BOOL "Compile to WebAssembly rather than plain JavaScript")
|
CACHE BOOL "Compile to WebAssembly rather than plain JavaScript")
|
||||||
|
|
||||||
|
# The minimal versions here are the ones that Puzzles' own JavaScript
|
||||||
|
# is written for. For most browsers, that's the earliest version with
|
||||||
|
# WebAssembly support according to https://caniuse.com/wasm. For
|
||||||
|
# Firefox we go back to Firefox 48 because that's what KaiOS 2.5 is
|
||||||
|
# based on.
|
||||||
|
set(MIN_FIREFOX_VERSION 48 CACHE STRING
|
||||||
|
"Oldest major version of Firefox to target")
|
||||||
|
set(MIN_SAFARI_VERSION 110000 CACHE STRING
|
||||||
|
"Oldest version of desktop Safari to target (XXYYZZ for version XX.YY.ZZ)")
|
||||||
|
set(MIN_EDGE_VERSION 16 CACHE STRING
|
||||||
|
"Oldest version of (non-Chromium-based) Edge to target")
|
||||||
|
set(MIN_CHROME_VERSION 57 CACHE STRING
|
||||||
|
"Oldest version of Chrome to target")
|
||||||
|
|
||||||
find_program(HALIBUT halibut)
|
find_program(HALIBUT halibut)
|
||||||
if(NOT HALIBUT)
|
if(NOT HALIBUT)
|
||||||
message(WARNING "HTML documentation cannot be built (did not find halibut)")
|
message(WARNING "HTML documentation cannot be built (did not find halibut)")
|
||||||
@ -44,6 +58,11 @@ set(CMAKE_C_LINK_FLAGS "\
|
|||||||
-s ENVIRONMENT=web \
|
-s ENVIRONMENT=web \
|
||||||
-s EXPORTED_FUNCTIONS='[${emcc_export_string}]' \
|
-s EXPORTED_FUNCTIONS='[${emcc_export_string}]' \
|
||||||
-s EXPORTED_RUNTIME_METHODS='[cwrap]' \
|
-s EXPORTED_RUNTIME_METHODS='[cwrap]' \
|
||||||
|
-s MIN_FIREFOX_VERSION=${MIN_FIREFOX_VERSION} \
|
||||||
|
-s MIN_SAFARI_VERSION=${MIN_SAFARI_VERSION} \
|
||||||
|
-s MIN_EDGE_VERSION=${MIN_EDGE_VERSION} \
|
||||||
|
-s MIN_CHROME_VERSION=${MIN_CHROME_VERSION} \
|
||||||
|
-s MIN_NODE_VERSION=0x7FFFFFFF \
|
||||||
-s STRICT_JS=1")
|
-s STRICT_JS=1")
|
||||||
if(WASM)
|
if(WASM)
|
||||||
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -s WASM=1")
|
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -s WASM=1")
|
||||||
|
Reference in New Issue
Block a user