From b1ff300919f3f3f34ef6b31826e725165c34f776 Mon Sep 17 00:00:00 2001 From: Olivier Chafik Date: Mon, 31 Oct 2022 20:42:47 +0000 Subject: [PATCH] Support building only specific images & recipes for faster local dev --- README.md | 18 ++++++++++++++++++ bin/build.sh | 31 +++++++++++++++++++------------ bin/prepare-images.sh | 8 +++++++- 3 files changed, 44 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index c70c7dd..9632cfa 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,24 @@ This places "v16.4.0" into `~/var/build_queue` which will be read on the next in The same process can be used to queue `rc` or `test` builds. +## Local development + +Build all platforms: + +```sh +mkdir -p build +bin/prepare-images.sh && \ + workdir=$PWD/build bin/build.sh v18.12.0 +``` + +Or just (re)build, say, x86: + +```sh +mkdir -p build +bin/prepare-images.sh fetch-source x86 && \ + workdir=$PWD/build bin/build.sh v18.12.0 x86 +``` + ## Team unofficial-builds is maintained by: diff --git a/bin/build.sh b/bin/build.sh index 2328dac..8c3d5e0 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -7,17 +7,7 @@ __dirname="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" workdir=${workdir:-"$__dirname"/../..} image_tag_pfx=unofficial-build-recipe- -# all of our build recipes, new recipes just go into this list, -recipes=" \ - headers \ - x86 \ - musl \ - armv6l \ - armv6l-pre16 \ - x64-pointer-compression \ - x64-usdt \ - riscv64 \ -" + ccachedir=$(realpath "${workdir}/.ccache") stagingdir=$(realpath "${workdir}/staging") distdir=$(realpath "${workdir}/download") @@ -29,10 +19,27 @@ if [[ "X${1}" = "X" ]]; then fi fullversion="$1" +shift 1 . ${__dirname}/_decode_version.sh decode "$fullversion" # see _decode_version for all of the magic variables now set and available for use +if [[ $# -gt 0 ]]; then + recipes=( "$@" ) +else + # all of our build recipes, new recipes just go into this list, + recipes=( + headers + x86 + musl + armv6l + pre16 + compression + usdt + riscv64 + ) +fi + # Point RELEASE_URLBASE to the Unofficial Builds server unofficial_release_urlbase="https://unofficial-builds.nodejs.org/download/${disttype}/" @@ -65,7 +72,7 @@ docker run --rm \ > ${thislogdir}/fetch-source.log 2>&1 # Build all other recipes -for recipe in $recipes; do +for recipe in "${recipes[@]}" ; do # each recipe has 3 variable components: # - individiaul ~/.ccache directory # - a ~/node.tar.xz file that fetch-source has downloaded diff --git a/bin/prepare-images.sh b/bin/prepare-images.sh index b38d68f..b428498 100755 --- a/bin/prepare-images.sh +++ b/bin/prepare-images.sh @@ -5,7 +5,13 @@ __dirname="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" image_tag_pfx=unofficial-build-recipe- -for recipe in $(ls ${__dirname}/../recipes/); do +if [[ $# -gt 0 ]]; then + recipes=( "$@" ) +else + recipes=( $(ls ${__dirname}/../recipes/) ) +fi + +for recipe in "${recipes[@]}" ; do docker build ${__dirname}/../recipes/${recipe}/ -t ${image_tag_pfx}${recipe} --build-arg UID=1000 --build-arg GID=1000 done