Skip to content

Commit 9939ef9

Browse files
committed
maint(developer): allow to build locally on Linux and macOS
This adds a `configure` build step that will install any missing dependencies required to build on Linux and macoS. macOS was added based on `resources/devbox/macos/macos.sh` but is untested. Test-bot: skip
1 parent 797af43 commit 9939ef9

File tree

8 files changed

+131
-74
lines changed

8 files changed

+131
-74
lines changed

resources/teamcity/README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ docker run -v $(pwd):/Develop -it ubuntu:24.04 /bin/bash
2020
Inside of the container, run
2121

2222
```bash
23-
apt update && apt install sudo
23+
apt update && apt install -y sudo
2424
export DOCKER_RUNNING=1
2525
echo "ubuntu ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
2626
su ubuntu
@@ -32,10 +32,3 @@ and then run the build, e.g.
3232
cd /Develop
3333
resources/teamcity/keyman-linux-test.sh configure,build,test
3434
```
35-
36-
NOTE: by default this will run the build as `root` in the container,
37-
so you will end up with files owned by `root` in your tree.
38-
Either create a user with the same user id as your local user in the
39-
container, or use one of the images created by `resources/docker-images`
40-
(though you won't be able to test if all the dependencies get installed
41-
if using the docker-images containers).

resources/teamcity/developer/keyman-developer-test-linux.sh renamed to resources/teamcity/developer/keyman-developer-test-linux-macos.sh

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Distributed under the MIT License. See LICENSE.md file in the project
44
# root for full license information.
55
#
6-
# TC build script for Keyman Developer on Linux
6+
# TC build script for Keyman Developer on Linux and macOS
77

88
# shellcheck disable=SC2164
99
# shellcheck disable=SC1091
@@ -14,11 +14,18 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
1414
. "${THIS_SCRIPT%/*}/../../../resources/build/builder.inc.sh"
1515
## END STANDARD BUILD SCRIPT INCLUDE
1616

17+
# shellcheck disable=SC2154
18+
. "${KEYMAN_ROOT}/resources/teamcity/includes/tc-actions.inc.sh"
19+
. "${KEYMAN_ROOT}/resources/teamcity/includes/tc-helpers.inc.sh"
20+
. "${KEYMAN_ROOT}/resources/teamcity/includes/tc-linux.inc.sh"
21+
. "${KEYMAN_ROOT}/resources/teamcity/includes/tc-macos.inc.sh"
22+
1723
################################ Main script ################################
1824

1925
builder_describe \
20-
"Build Keyman Developer on Linux" \
26+
"Build Keyman Developer on Linux and macOS" \
2127
"all run all actions" \
28+
"configure install dependencies" \
2229
"build build"
2330

2431
builder_parse "$@"
@@ -28,13 +35,23 @@ cd "${KEYMAN_ROOT}/developer/src"
2835
function build_developer_action() {
2936
builder_echo start "build developer" "Building Keyman Developer"
3037

31-
./build.sh configure build test
38+
"${KEYMAN_ROOT}/developer/src/build.sh" configure build test
3239

3340
builder_echo end "build developer" success "Finished building Keyman Developer"
3441
}
3542

3643
if builder_has_action all; then
44+
developer_install_dependencies_action
45+
46+
set_variables_for_nvm
47+
set_variables_for_emscripten
48+
3749
build_developer_action
3850
else
51+
builder_run_action configure developer_install_dependencies_action
52+
53+
set_variables_for_nvm
54+
set_variables_for_emscripten
55+
3956
builder_run_action build build_developer_action
4057
fi

resources/teamcity/developer/keyman-developer-test-macos.sh

Lines changed: 0 additions & 40 deletions
This file was deleted.

resources/teamcity/includes/tc-actions.inc.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ linux_additional_test_dependencies_action() {
2424
fi
2525

2626
# shellcheck disable=SC2086
27-
check_and_install_packages ${TOINSTALL}
27+
linux_check_and_install_packages ${TOINSTALL}
2828

2929
if ! is_os_version_or_higher 24.04; then
3030
builder_heading "Installing python3-coverage from pip"
@@ -83,3 +83,17 @@ web_test_action() {
8383
builder_echo end web_test success "Finished running tests for native KeymanWeb"
8484
}
8585

86+
developer_install_dependencies_action() {
87+
builder_echo start "install dependencies" "Installing dependencies"
88+
89+
if is_ubuntu; then
90+
linux_check_and_install_packages devscripts jq meson
91+
elif is_macos; then
92+
macos_install_packages bash jq python3 meson ninja coreutils pyenv
93+
fi
94+
95+
install_nvm
96+
install_emscripten
97+
98+
builder_echo end "install dependencies" success "Finished installing dependencies"
99+
}

resources/teamcity/includes/tc-helpers.inc.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,39 @@ is_macos() {
2727
return 1
2828
fi
2929
}
30+
31+
install_nvm() {
32+
if is_ubuntu; then
33+
linux_install_nvm
34+
elif is_macos; then
35+
macos_install_packages nvm
36+
fi
37+
}
38+
39+
# Set the environment variables required to use node/nvm and set the
40+
# `KEYMAN_USE_NVM` variable so that the build can automatically install
41+
# the required node version.
42+
set_variables_for_nvm() {
43+
# nvm.sh uses some variables that might not be initialized, so we
44+
# disable the "unbound variable" check temporarily
45+
set -u
46+
export NVM_DIR="${HOME}/.nvm"
47+
# shellcheck disable=SC1091
48+
. "${NVM_DIR}/nvm.sh"
49+
set +u
50+
export KEYMAN_USE_NVM=1
51+
PATH=${HOME}/.keyman/node:${PATH}
52+
}
53+
54+
install_emscripten() {
55+
if is_ubuntu; then
56+
linux_install_emscripten
57+
elif is_macos; then
58+
macos_install_packages emscripten
59+
fi
60+
}
61+
62+
set_variables_for_emscripten() {
63+
export EMSCRIPTEN_BASE="${EMSCRIPTEN_BASE:-${HOME}/emsdk/upstream/emscripten}"
64+
export KEYMAN_USE_EMSDK=1
65+
}

resources/teamcity/includes/tc-linux.inc.sh

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ is_package_installed() {
2323
# Check if the specified packages are installed and install them if not.
2424
# Parameters:
2525
# $* - List of package names to check and install (e.g., "lcov jq")
26-
check_and_install_packages() {
27-
local PACKAGES=$*
28-
local TOINSTALL=""
29-
26+
linux_check_and_install_packages() {
3027
if ! is_ubuntu; then
3128
return 0
3229
fi
3330

31+
builder_echo start "check and install packages" "Checking and installing packages"
32+
local PACKAGES=$*
33+
local TOINSTALL=""
34+
3435
for p in ${PACKAGES}
3536
do
3637
if ! is_package_installed "${p}"; then
@@ -43,21 +44,7 @@ check_and_install_packages() {
4344
# shellcheck disable=SC2086
4445
sudo DEBIAN_FRONTEND="noninteractive" apt-get install -qy ${TOINSTALL}
4546
fi
46-
}
47-
48-
# Set the environment variables required to use node/nvm and set the
49-
# `KEYMAN_USE_NVM` variable so that the build can automatically install
50-
# the required node version.
51-
set_variables_for_nvm() {
52-
# nvm.sh uses some variables that might not be initialized, so we
53-
# disable the "unbound variable" check temporarily
54-
set -u
55-
export NVM_DIR="${HOME}/.nvm"
56-
# shellcheck disable=SC1091
57-
. "${NVM_DIR}/nvm.sh"
58-
set +u
59-
export KEYMAN_USE_NVM=1
60-
PATH=${HOME}/.keyman/node:${PATH}
47+
builder_echo end "check and install packages" success "Finished checking and installing packages"
6148
}
6249

6350
# Install nvm if it is not already installed and install the latest LTS
@@ -78,11 +65,34 @@ linux_install_nvm() {
7865
builder_echo end install_nvm success "Finished checking and installing nvm"
7966
}
8067

68+
linux_install_emscripten() {
69+
builder_echo start "install emscripten" "Checking and installing emscripten"
70+
if { [[ ! -z "${EMSCRIPTEN_BASE:-}" ]] && [[ -f "${EMSCRIPTEN_BASE}/emcc" ]] } ||
71+
[[ -f "${HOME}/emsdk/upstream/emscripten/emcc" ]]; then
72+
builder_echo "Emscripten is already installed at ${EMSCRIPTEN_BAS:-${HOME}/emsdk/upstream/emscripten}"
73+
else
74+
# shellcheck disable=SC2154
75+
. "${KEYMAN_ROOT}/resources/build/minimum-versions.inc.sh"
76+
77+
builder_echo "Installing emscripten version ${KEYMAN_MIN_VERSION_EMSCRIPTEN}"
78+
export EMSDK_KEEP_DOWNLOADS=1
79+
# shellcheck disable=SC2164
80+
cd "${HOME}"
81+
git clone https://github.com/emscripten-core/emsdk.git
82+
# shellcheck disable=SC2164
83+
cd emsdk
84+
./emsdk install "${KEYMAN_MIN_VERSION_EMSCRIPTEN}"
85+
./emsdk activate "${KEYMAN_MIN_VERSION_EMSCRIPTEN}"
86+
fi
87+
set_variables_for_emscripten
88+
builder_echo end "install emscripten" success "Finished checking and installing emscripten"
89+
}
90+
8191
# Install additional dependencies required for running integration tests.
8292
linux_install_dependencies_for_tests() {
8393
builder_echo start install_dependencies_for_tests "Installing dependencies for tests"
8494

85-
check_and_install_packages xvfb xserver-xephyr metacity mutter dbus-x11 weston xwayland
95+
linux_check_and_install_packages xvfb xserver-xephyr metacity mutter dbus-x11 weston xwayland
8696

8797
builder_echo end install_dependencies_for_tests success "Finished installing dependencies for tests"
8898
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
macos_install_packages() {
4+
if ! is_macos; then
5+
return 0
6+
fi
7+
8+
builder_echo start "install packages" "Installing packages on macOS: $*"
9+
10+
if ! command -v brew &> /dev/null; then
11+
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
12+
# Unfortunately Homebrew gets installed in different directories
13+
# depending on the architecture. This uses the paths that `install.sh`
14+
# has.
15+
if [[ "$(uname -m)" == "arm64" ]]; then
16+
# On ARM macOS Homebrew gets installed to /opt/homebrew
17+
HOMEBREW_PREFIX="/opt/homebrew"
18+
else
19+
# On Intel macOS Homebrew gets installed to /usr/local
20+
HOMEBREW_PREFIX="/usr/local"
21+
fi
22+
eval "$(${HOMEBREW_PREFIX}/bin/brew shellenv)"
23+
fi
24+
brew install "$@"
25+
26+
builder_echo end "install packages" success "Finished installing packages on macOS"
27+
}

resources/teamcity/web/keyman-web-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function install_dependencies_action() {
3737
builder_echo start "install dependencies" "Install dependencies"
3838

3939
# shellcheck disable=SC2086
40-
check_and_install_packages devscripts jq
40+
linux_check_and_install_packages devscripts jq
4141

4242
# TODO: we can we do something similar for Windows and macOS?
4343
linux_install_nvm
@@ -52,7 +52,7 @@ function install_playwright_dependencies() {
5252
fi
5353

5454
# shellcheck disable=SC2086
55-
check_and_install_packages ibevent-2.1-7t64 libxslt1.1 libwoff1 libvpx9 libgstreamer-plugins-bad1.0-0 libwebpdemux2 libharfbuzz-icu0 libenchant-2-2 libsecret-1-0 libhyphen0 libmanette-0.2-0 libflite1 gstreamer1.0-libav
55+
linux_check_and_install_packages ibevent-2.1-7t64 libxslt1.1 libwoff1 libvpx9 libgstreamer-plugins-bad1.0-0 libwebpdemux2 libharfbuzz-icu0 libenchant-2-2 libsecret-1-0 libhyphen0 libmanette-0.2-0 libflite1 gstreamer1.0-libav
5656
}
5757

5858
function check_build_size_action() {

0 commit comments

Comments
 (0)