Skip to content

Commit

Permalink
Merge pull request #12243 from keymanapp/chore/developer/emscripten-3…
Browse files Browse the repository at this point in the history
….1.60-patch

chore(common): allow build agents to automatically select emsdk version, and enable support for 3.1.60+
  • Loading branch information
mcdurdin authored Aug 22, 2024
2 parents 6b06ef5 + b0bd95d commit 62babbb
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
7 changes: 7 additions & 0 deletions developer/src/kmcmplib/src/CompilerInterfacesWasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,16 @@ struct BindingType<std::vector<T, Allocator>> {
using ValBinding = BindingType<val>;
using WireType = ValBinding::WireType;

#if __EMSCRIPTEN_major__ == 3 && __EMSCRIPTEN_minor__ == 1 && __EMSCRIPTEN_tiny__ >= 60
// emscripten-core/emscripten#21692
static WireType toWireType(const std::vector<T, Allocator> &vec, rvp::default_tag) {
return ValBinding::toWireType(val::array(vec), rvp::default_tag{});
}
#else
static WireType toWireType(const std::vector<T, Allocator> &vec) {
return ValBinding::toWireType(val::array(vec));
}
#endif

static std::vector<T, Allocator> fromWireType(WireType value) {
return vecFromJSArray<T>(ValBinding::fromWireType(value));
Expand Down
3 changes: 1 addition & 2 deletions resources/build/minimum-versions.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ KEYMAN_MIN_TARGET_VERSION_CHROME=95.0 # Final version that runs on Andro
# Dependency versions
KEYMAN_MIN_VERSION_NODE_MAJOR=20 # node version source of truth is /package.json:/engines/node
KEYMAN_MIN_VERSION_NPM=10.5.1 # 10.5.0 has bug, discussed in #10350
KEYMAN_MIN_VERSION_EMSCRIPTEN=3.1.44 # Warning: 3.1.45 is bad (#9529); newer versions work
KEYMAN_MAX_VERSION_EMSCRIPTEN=3.1.58 # See #9529
KEYMAN_MIN_VERSION_EMSCRIPTEN=3.1.58 # Use KEYMAN_USE_EMSDK to automatically update to this version
KEYMAN_MIN_VERSION_VISUAL_STUDIO=2019
KEYMAN_MIN_VERSION_MESON=1.0.0

Expand Down
36 changes: 36 additions & 0 deletions resources/locate_emscripten.inc.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# shellcheck shell=bash
# no hashbang for .inc.sh

. "$KEYMAN_ROOT/resources/build/minimum-versions.inc.sh"

#
# We don't want to rely on emcc being on the path, because Emscripten puts far
# too many things onto the path (in particular for us, node).
Expand Down Expand Up @@ -34,4 +36,38 @@ locate_emscripten() {
fi
[[ -f ${EMSCRIPTEN_BASE}/${EMCC_EXECUTABLE} && ! -x ${EMSCRIPTEN_BASE}/${EMCC_EXECUTABLE} ]] && builder_die "locate_emscripten: Variable EMSCRIPTEN_BASE ($EMSCRIPTEN_BASE) contains ${EMCC_EXECUTABLE} but it is not executable"
[[ -x ${EMSCRIPTEN_BASE}/${EMCC_EXECUTABLE} ]] || builder_die "locate_emscripten: Variable EMSCRIPTEN_BASE ($EMSCRIPTEN_BASE) does not point to ${EMCC_EXECUTABLE}'s folder"

verify_emscripten_version
}

# Ensure that we use correct version of emsdk on build agents.
# For developers, define KEYMAN_USE_SDK to do this on your
# build machine.
verify_emscripten_version() {
if [[ "$VERSION_ENVIRONMENT" != local || ! -z "${KEYMAN_USE_EMSDK+x}" ]]; then
_select_emscripten_version_with_emsdk
fi
}

# Use emsdk to select the appropriate version of Emscripten
# according to minimum-versions.inc.sh
_select_emscripten_version_with_emsdk() {
if [[ -z "${EMSCRIPTEN_BASE+x}" ]]; then
builder_die "Variable EMSCRIPTEN_BASE must be set"
fi

if [[ -z "${KEYMAN_MIN_VERSION_EMSCRIPTEN+x}" ]]; then
builder_die "Variable KEYMAN_MIN_VERSION_EMSCRIPTEN must be set"
fi

pushd "${EMSCRIPTEN_BASE}/../.." > /dev/null
if [[ ! -f emsdk ]]; then
builder_die "emsdk[.bat] should be in $(pwd)"
fi

export EMSDK_KEEP_DOWNLOADS=1
git pull
./emsdk install "$KEYMAN_MIN_VERSION_EMSCRIPTEN"
./emsdk activate "$KEYMAN_MIN_VERSION_EMSCRIPTEN"
popd > /dev/null
}

0 comments on commit 62babbb

Please sign in to comment.