From 853973d49905ddebab64094a0bf8f7eba2511412 Mon Sep 17 00:00:00 2001 From: Dan Bornstein Date: Tue, 7 Nov 2023 10:22:02 -0800 Subject: [PATCH 1/3] Switch `find-module-dependencies` to use `opt-multi`. --- .../bashy-node/node-project/build-main-module | 26 +++++++------ .../node-project/find-module-dependencies | 37 +++++-------------- 2 files changed, 24 insertions(+), 39 deletions(-) diff --git a/scripts/lib/bashy-node/node-project/build-main-module b/scripts/lib/bashy-node/node-project/build-main-module index fe03897..2029948 100755 --- a/scripts/lib/bashy-node/node-project/build-main-module +++ b/scripts/lib/bashy-node/node-project/build-main-module @@ -28,10 +28,10 @@ define-usage --with-help $' files ended up in the built output. --modules-dir= Path to a directory containing all module sources to be used. - --modules-dirs= - JSON array of one or more paths to directories containing module sources. - If the same-named module exists in more than one modules directory, the - first one listed "wins." + --modules-dirs[]= ... + Paths to one or more module source directories, collectively containing + all module sources to be used. If there are same-named modules under more + than one of the given paths, the first-listed path\'s one "wins." --out= Directory where built output goes. Defaults to `out` directly under the main product directory. @@ -46,10 +46,9 @@ define-usage --with-help $' # Allow the build to be platform-specific? opt-toggle --var=platformSpecific allow-platform-specific-files -# Directory or directories containing all the modules. -modulesOpt='' -opt-value --call='{ modulesOpt="--modules-dir=$1" }' --filter='/./' modules-dir -opt-value --call='{ modulesOpt="--modules-dirs=$1" }' --filter='/^\[.*\]$/' modules-dirs +# Paths to all module directories. +opt-value --call='{ modulesDirs=("$1") }' --filter='/./' modules-dir +opt-multi --var=modulesDirs --filter='/./' modules-dirs require-exactly-one-arg-of modules-dir modules-dirs # Built output directory. @@ -71,8 +70,9 @@ process-args "$@" || exit "$?" # The main actions of this script. function build-project { local projectName="$1" - local modulesOpt="$2" - local destDir="$3" + local destDir="$2" + shift 2 + local modulesDirs=("$@") local destLibDir="${destDir}/lib" local mainModule="main-${projectName}" @@ -91,7 +91,9 @@ function build-project { local deps deps="$( - lib . find-module-dependencies "${modulesOpt}" "${mainModule}" + lib . find-module-dependencies \ + --modules-dirs[]="$(vals "${modulesDirs[@]}")" \ + "${mainModule}" )" \ || return "$?" @@ -372,7 +374,7 @@ if [[ ! -d ${outProjectDir} ]]; then || exit "$?" fi -build-project "${projectName}" "${modulesOpt}" "${outProjectDir}" \ +build-project "${projectName}" "${outProjectDir}" "${modulesDirs[@]}" \ || exit "$?" if (( !platformSpecific )); then diff --git a/scripts/lib/bashy-node/node-project/find-module-dependencies b/scripts/lib/bashy-node/node-project/find-module-dependencies index 57ea110..60c5c02 100755 --- a/scripts/lib/bashy-node/node-project/find-module-dependencies +++ b/scripts/lib/bashy-node/node-project/find-module-dependencies @@ -13,9 +13,9 @@ define-usage --with-help $' ${name} [ ...] [--] - Transitively finds all module dependencies from the one given, which must - be the name of a module defined under the indicated modules directory. - Prints out a JSON object with bindings as follows: + Transitively finds all module dependencies from the given , + which must be the name of a module defined under one of the indicated + modules directories. Prints out a JSON object with bindings as follows: * `main: string` -- The originally requested module. * `localDeps: [name, ...]` -- Local module dependencies. @@ -30,20 +30,15 @@ define-usage --with-help $' This tool is opinionated: The modules directories are taken to define submodules (in the Node sense) under the top-level name `@this`. - **Note:** Exactly one of the two `--modules-*` options must be specified. - - --modules-dir= - Path to a directory containing all module sources to be used. - --modules-dirs= - JSON array of one or more paths to directories containing module sources. - If the same-named module exists in more than one modules directory, the - first one listed "wins." + --modules-dirs= + --modules-dirs[]= ... + Paths to one or more module source directories, collectively containing + all module sources to be used. If there are same-named modules under more + than one of the given paths, the first-listed path\'s one "wins." ' -# Directory or directories containing all the modules. -opt-value --var=modulesDir --filter='/./' modules-dir -opt-value --var=modulesDirsJson --filter='/^\[.*\]$/' modules-dirs -require-exactly-one-arg-of modules-dir modules-dirs +# Paths to all module directories. +opt-multi --required --var=modulesDirs --filter='/./' modules-dirs # The module to start at. positional-arg --required --var=moduleName module-name @@ -55,18 +50,6 @@ process-args "$@" || exit "$?" # Main script # -modulesDirs=() -if [[ ${modulesDir} != '' ]]; then - if [[ ! (-d ${modulesDir} && -r ${modulesDir}) ]]; then - error-msg "Not a readable directory: ${modulesDir}" - exit 1 - fi - modulesDirs=("${modulesDir}") -else - jset-array --raw modulesDirs "${modulesDirsJson}" \ - || exit "$?" -fi - # Collect all of the modules referenced by this package, transitively including # all referenced local modules. The result is two lists, one of local modules # and one of regular (published via npm) dependencies. This uses a work queue From 2b15fcec39eca1f76fbeeb7c5a69da8b3091294d Mon Sep 17 00:00:00 2001 From: Dan Bornstein Date: Tue, 7 Nov 2023 10:23:13 -0800 Subject: [PATCH 2/3] Switch `build-main-module` completely to `opt-multi`. --- scripts/lib/bashy-node/node-project/build-main-module | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/lib/bashy-node/node-project/build-main-module b/scripts/lib/bashy-node/node-project/build-main-module index 2029948..52e988b 100755 --- a/scripts/lib/bashy-node/node-project/build-main-module +++ b/scripts/lib/bashy-node/node-project/build-main-module @@ -26,8 +26,7 @@ define-usage --with-help $' --allow-platform-specific-files If specified, the build does *not* check to see if any platform-specific files ended up in the built output. - --modules-dir= - Path to a directory containing all module sources to be used. + --modules-dirs= --modules-dirs[]= ... Paths to one or more module source directories, collectively containing all module sources to be used. If there are same-named modules under more @@ -47,9 +46,7 @@ define-usage --with-help $' opt-toggle --var=platformSpecific allow-platform-specific-files # Paths to all module directories. -opt-value --call='{ modulesDirs=("$1") }' --filter='/./' modules-dir -opt-multi --var=modulesDirs --filter='/./' modules-dirs -require-exactly-one-arg-of modules-dir modules-dirs +opt-multi --required --var=modulesDirs --filter='/./' modules-dirs # Built output directory. opt-value --var=outDir out From 34345f52851e776ba2f9ba12f5f328e8cb1853c5 Mon Sep 17 00:00:00 2001 From: Dan Bornstein Date: Tue, 7 Nov 2023 10:27:21 -0800 Subject: [PATCH 3/3] Changelog. --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b79de8..b6c0308 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,13 @@ versioning principles. Unstable releases do not. ### [Unreleased] +This is a stable-ish release. No further breaking changes are currently +contemplated for the 2.* release series. + Breaking changes: -* None. +* `bashy-node`: Reworked build options to use the newly-standardized multi-value + forms. Only _nominally_ breaking in that use of `bashy-node` at all is + pretty minimal. Other notable changes: * `bashy-basics`: New utility functions `env-clean`, `env-minimize`, and