maint: update macOS env setup + documentation

Fixes: #13177

We now need to install sdkmanager through a different Homebrew package /
"cask".  This does get us `sdkmanager`, but it has a new default location
for its Android SDK, while our builds still refer to the old location
under the home directory.  The build script thus needs a bit of tweaking
to force `sdkmanager` to operate based on the location we've previously
referred to.

Additionally, macOS machines typically default to the zsh terminal these
days, so the old profile auto-config doesn't work.  This adds and
documents example profile script that can be used to configure a macOS
dev machine's terminal environment.
This commit is contained in:
Joshua Horton 2025-05-19 12:29:23 +07:00
parent 437b2019e0
commit dfad7a4e25
3 changed files with 44 additions and 11 deletions

36
docs/build/macos.md vendored
View file

@ -50,10 +50,38 @@ The remaining dependencies can be installed via script:
This script will also update your environment to the values in:
`resources/devbox/macos/keyman.macos.env.sh`
It will also add these environment settings to your `~/.bashrc`.
These dependencies are also listed below if you'd prefer to install manually.
### Example shell profile script
`keyman.macos.env.sh` may be `source`d within your `~/.bashrc` / `~/.zprofile` in
order to regularly apply its path settings to the terminal during local development.
For a `.zprofile`...
```zsh
# Adds homebrew-managed dependencies to $PATH
eval "$(/opt/homebrew/bin/brew shellenv)"
# Replace right-hand side with the path to your local copy of the repo
export KEYMAN_ROOT=~/keymanapp/keyman
# May be called to apply build-path settings, such as those allowing
# direct call of npm scripts without `npm run`.
set_keyman_standard_build_path() {
PATH="${KEYMAN_ROOT}/node_modules/.bin:$PATH"
}
# builder-script tab autocompletion
autoload -Uz compinit && compinit
autoload bashcompinit
bashcompinit
source "${KEYMAN_ROOT}/resources/builder_completion.sh"
# environment variable initialization
source "${KEYMAN_ROOT}/resources/devbox/macos/keyman.macos.env.sh"
```
## Shared Dependencies
* HomeBrew, Bash 5.0+, jq, Python 2.7, Python 3, Meson, Ninja, coreutils, Pandoc
@ -155,10 +183,10 @@ brew install carthage cocoapods
## Keyman for Android Dependencies
* openjdk 11, Android SDK, Android Studio, Ant, Gradle, Maven
* openjdk 21, Android SDK, Android Studio, Ant, Gradle, Maven
```shell
brew install openjdk@11 android-sdk android-studio ant gradle maven
brew install openjdk@21 android-sdk android-studio ant gradle maven
# update path
source ../resources/devbox/macos/keyman.macos.env.sh
# optionally install sdk images

View file

@ -20,8 +20,8 @@ if [ -z "$HOMEBREW_PREFIX" ]; then
fi
export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH"
export PATH="$HOMEBREW_PREFIX/opt/java11/bin:$PATH"
export JAVA_HOME="$HOMEBREW_PREFIX/opt/java11"
export PATH="$HOMEBREW_PREFIX/opt/openjdk@21/bin:$PATH"
export JAVA_HOME="$HOMEBREW_PREFIX/opt/openjdk@21"
# Python 2.7
eval "$(pyenv init --path)"

View file

@ -148,7 +148,7 @@ BREW_ALL="bash jq python3 meson ninja coreutils pyenv"
BREW_WEB="node emscripten"
BREW_IOS="swiftlint carthage"
BREW_MACOS="carthage cocoapods"
BREW_ANDROID="openjdk@8 android-sdk android-studio ant gradle maven"
BREW_ANDROID="openjdk@21 android-commandlinetools android-studio ant gradle maven"
# Turn on verbosity
set -x
@ -169,16 +169,21 @@ pyenv global 2.7.18
source "$THIS_DIR/keyman.macos.env.sh"
$REQUIRE_ANDROID && (
mkdir -p .android && touch ~/.android/repositories.cfg
mkdir -p ~/.android && touch ~/.android/repositories.cfg
SDK_ROOT=~/.android
# installed via android-commandlinetools
which sdkmanager || (
echo "Please run Android Studio to install the Android SDK tools."
read -p "Press ENTER to continue after installation"
PATH="$HOME/Library/Android/sdk/tools/bin:$PATH"
)
sdkmanager "system-images;android-30;google_apis_playstore;x86_64"
sdkmanager --update
sdkmanager --licenses
# android-commandlinetools default sdk_root location is elsewhere, as
# documented by https://formulae.brew.sh/cask/android-commandlinetools
sdkmanager --sdk_root=$SDK_ROOT "system-images;android-30;google_apis_playstore;x86_64"
sdkmanager --sdk_root=$SDK_ROOT --update
sdkmanager --sdk_root=$SDK_ROOT --licenses
)
# For now, we won't run this step automatically