From 3005a82a8f6f9dd99c282f562d67701a0a3cfb09 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Wed, 22 Feb 2023 10:41:54 +0700 Subject: [PATCH] chore: update docs and non-standard readlink refs --- configure-repo.sh | 2 +- docs/build/macos.md | 10 ++-------- resources/build/build-utils.md | 14 ++++++-------- resources/build/build-utils.sh | 4 ++-- resources/builder.inc.sh | 4 ++-- resources/devbox/macos/keyman.macos.env.sh | 4 ++-- resources/git-hooks/commit-msg | 2 +- resources/git-hooks/prepare-commit-msg | 2 +- 8 files changed, 17 insertions(+), 25 deletions(-) diff --git a/configure-repo.sh b/configure-repo.sh index d729255b34..5e7feed94a 100755 --- a/configure-repo.sh +++ b/configure-repo.sh @@ -10,7 +10,7 @@ if [[ -n "$WINDIR" ]]; then # https://stackoverflow.com/a/39160850/1836776 SCRIPT_DIR=$(cmd //C cd) else - SCRIPT_DIR="$(dirname "$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")")" + SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" fi case $1 in diff --git a/docs/build/macos.md b/docs/build/macos.md index cb4a1bdedf..d8e4f61696 100644 --- a/docs/build/macos.md +++ b/docs/build/macos.md @@ -59,17 +59,11 @@ These dependencies are also listed below if you'd prefer to install manually. echo 'eval "$(pyenv init --path)"' >> ~/.bash_profile ``` - On M1 only (as greadlink is not on the path otherwise in XCode): - - ```shell - sudo ln -s /opt/homebrew/bin/greadlink /usr/local/bin/greadlink - ``` - - On Ventura, you will need to adjust your PATH so that coreutils’ `realpath` takes precedence over the BSD one: + On macOS, you will need to adjust your PATH so that coreutils’ `realpath` takes precedence over the BSD one: ```shell # Credit: brew info coreutils - PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" + PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH" ``` * Web: node.js, emscripten, openjdk 8 diff --git a/resources/build/build-utils.md b/resources/build/build-utils.md index 4332f4389c..3893fd1ea1 100644 --- a/resources/build/build-utils.md +++ b/resources/build/build-utils.md @@ -43,7 +43,7 @@ set -eu ## START STANDARD BUILD SCRIPT INCLUDE # adjust relative paths as necessary -THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")" +THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" . "$(dirname "$THIS_SCRIPT")//resources/build/build-utils.sh" ## END STANDARD BUILD SCRIPT INCLUDE @@ -78,14 +78,12 @@ We use `set -eu` throughout: ```bash ## START STANDARD BUILD SCRIPT INCLUDE # adjust relative paths as necessary -THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")" +THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" . "$(dirname "$THIS_SCRIPT")//resources/build/build-utils.sh" ## END STANDARD BUILD SCRIPT INCLUDE ``` -This somewhat unwieldy incantation handles all our build environments, with -`greadlink` necessary on macOS (again installed with homebrew) due to the -included macOS `readlink` struggling with canonicalization of symbolic links. +This somewhat unwieldy incantation handles all our build environments. The intent is to get a good solid consistent path for the script so that we can safely include the build script, no matter what `pwd` is when the script is run. @@ -172,10 +170,10 @@ a user or called by another script: will execute for all targets of the dependency script. If you are working on code within a dependency, you are currently expected to rebuild and test that dependency locally. - + A dependency is similar to, but not the same as, a child project. Child projects live in sub-folders of the parent project, whereas generally a - dependency will be in another folder altogether. + dependency will be in another folder altogether. Dependencies can be defined for all actions and targets, or may be limited to specific action and/or targets. @@ -379,7 +377,7 @@ builder_describe "Sample script" \ A dependency always starts with `@`. The path to the dependency will be relative to the build script folder if the path does not start with `/`. Otherwise, the path -to the dependency is interpreted relative to the root of the repository. It is an +to the dependency is interpreted relative to the root of the repository. It is an error to specify a dependency outside the repo root. Relative paths will be expanded to full paths, again, relative to the root of diff --git a/resources/build/build-utils.sh b/resources/build/build-utils.sh index c8c0fd3bd1..a8a2f4d974 100755 --- a/resources/build/build-utils.sh +++ b/resources/build/build-utils.sh @@ -22,7 +22,7 @@ # Here is how to include this script reliably, cross-platform: # ## START STANDARD BUILD SCRIPT INCLUDE # # adjust relative paths as necessary -# THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")" +# THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" # . "$(dirname "$THIS_SCRIPT")/../resources/build/build-utils.sh" # # END STANDARD BUILD SCRIPT INCLUDE # @@ -38,7 +38,7 @@ function findKeymanRoot() { # See https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself # None of the answers are 100% correct for cross-platform # On macOS, requires coreutils (`brew install coreutils`) - local SCRIPT=$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}") + local SCRIPT=$(readlink -f "${BASH_SOURCE[0]}") KEYMAN_ROOT=$(dirname $(dirname $(dirname "$SCRIPT"))) readonly KEYMAN_ROOT } diff --git a/resources/builder.inc.sh b/resources/builder.inc.sh index ab979bd040..3d4da2c5b6 100755 --- a/resources/builder.inc.sh +++ b/resources/builder.inc.sh @@ -30,7 +30,7 @@ function _builder_findRepoRoot() { # See https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself # None of the answers are 100% correct for cross-platform # On macOS, requires coreutils (`brew install coreutils`) - local SCRIPT=$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}") + local SCRIPT=$(readlink -f "${BASH_SOURCE[0]}") REPO_ROOT=$(dirname $(dirname "$SCRIPT")) readonly REPO_ROOT } @@ -44,7 +44,7 @@ function _builder_findRepoRoot() { # ```bash # ## START STANDARD BUILD SCRIPT INCLUDE # # adjust relative paths as necessary -# THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")" +# THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" # . "$(dirname "$THIS_SCRIPT")/resources/builder.inc.sh" # ## END STANDARD BUILD SCRIPT INCLUDE # ``` diff --git a/resources/devbox/macos/keyman.macos.env.sh b/resources/devbox/macos/keyman.macos.env.sh index 34acdfce0f..47895d575e 100755 --- a/resources/devbox/macos/keyman.macos.env.sh +++ b/resources/devbox/macos/keyman.macos.env.sh @@ -1,4 +1,4 @@ -source $HOME/.cargo/env +# source $HOME/.cargo/env #echo 'export PATH="/usr/local/opt/openjdk@8/bin:$PATH"' >> ~/.zshrc #echo 'export PATH="/usr/local/opt/openjdk@8/bin:$PATH"' >> ~/.bashrc export ANT_HOME=/usr/local/opt/ant @@ -15,7 +15,7 @@ export PATH=$ANDROID_HOME/tools/bin:$PATH export PATH=$ANDROID_HOME/platform-tools:$PATH export PATH=$ANDROID_HOME/build-tools/30.0.3:$PATH export PATH="/usr/local/opt/openjdk@8/bin:$PATH" - +export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH" export JAVA_HOME=/usr/local/opt/openjdk@8 # Python 2.7 diff --git a/resources/git-hooks/commit-msg b/resources/git-hooks/commit-msg index 187a7bbe22..139d7cdaf9 100755 --- a/resources/git-hooks/commit-msg +++ b/resources/git-hooks/commit-msg @@ -13,7 +13,7 @@ # # Get the directory where this script lives, i.e. resources/git-hooks -HOOK_DIRECTORY="$(dirname "$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")")" +HOOK_DIRECTORY="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" if [ -f $(dirname "${BASH_SOURCE[0]}")/commit-msg-defs ]; then # This script was run from a symlink and the repo in question has its own commit-msg-defs. diff --git a/resources/git-hooks/prepare-commit-msg b/resources/git-hooks/prepare-commit-msg index a43bb8206a..f6d3db9ca6 100755 --- a/resources/git-hooks/prepare-commit-msg +++ b/resources/git-hooks/prepare-commit-msg @@ -18,7 +18,7 @@ COMMIT_SOURCE=$2 SHA1=$3 # Get the directory where this script lives, i.e. resources/git-hooks -HOOK_DIRECTORY="$(dirname "$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")")" +HOOK_DIRECTORY="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" if [ -f $(dirname "${BASH_SOURCE[0]}")/commit-msg-defs ]; then # This script was run from a symlink and the repo in question has its own commit-msg-defs.