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 diff --git a/scripts/lib/bashy-node/node-project/build-main-module b/scripts/lib/bashy-node/node-project/build-main-module index fe03897..52e988b 100755 --- a/scripts/lib/bashy-node/node-project/build-main-module +++ b/scripts/lib/bashy-node/node-project/build-main-module @@ -26,12 +26,11 @@ 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= - 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." --out= Directory where built output goes. Defaults to `out` directly under the main product directory. @@ -46,11 +45,8 @@ 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 -require-exactly-one-arg-of modules-dir modules-dirs +# Paths to all module directories. +opt-multi --required --var=modulesDirs --filter='/./' modules-dirs # Built output directory. opt-value --var=outDir out @@ -71,8 +67,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 +88,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 +371,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