From 1d8483e713824bfffd7a9e29f01f450ca306f196 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 15 Nov 2023 13:37:09 +0900 Subject: [PATCH] tools: recognize GN files in dep_updaters PR-URL: https://github.com/nodejs/node/pull/50693 Reviewed-By: Marco Ippolito Reviewed-By: Yagiz Nizipli Reviewed-By: Darshan Sen Reviewed-By: Joyee Cheung Reviewed-By: Tierney Cyren Reviewed-By: Michael Dawson --- tools/dep_updaters/update-ada.sh | 4 +-- tools/dep_updaters/update-brotli.sh | 5 +++- tools/dep_updaters/update-c-ares.sh | 3 +- tools/dep_updaters/update-libuv.sh | 4 +-- tools/dep_updaters/update-llhttp.sh | 5 ++++ tools/dep_updaters/update-nghttp2.sh | 3 ++ tools/dep_updaters/update-postject.sh | 42 ++++++++++++++++++--------- tools/dep_updaters/update-simdutf.sh | 4 +-- tools/dep_updaters/update-uvwasi.sh | 6 +++- 9 files changed, 53 insertions(+), 23 deletions(-) diff --git a/tools/dep_updaters/update-ada.sh b/tools/dep_updaters/update-ada.sh index a6fa2464728b97..9f4f779b6ae02b 100755 --- a/tools/dep_updaters/update-ada.sh +++ b/tools/dep_updaters/update-ada.sh @@ -54,8 +54,8 @@ rm "$ADA_ZIP" curl -sL -o "$ADA_LICENSE" "https://raw.githubusercontent.com/ada-url/ada/HEAD/LICENSE-MIT" -echo "Replacing existing ada (except GYP build files)" -mv "$DEPS_DIR/ada/"*.gyp "$DEPS_DIR/ada/README.md" "$WORKSPACE/" +echo "Replacing existing ada (except GYP and GN build files)" +mv "$DEPS_DIR/ada/"*.gyp "$DEPS_DIR/ada/"*.gn "$DEPS_DIR/ada/"*.gni "$DEPS_DIR/ada/README.md" "$WORKSPACE/" rm -rf "$DEPS_DIR/ada" mv "$WORKSPACE" "$DEPS_DIR/ada" diff --git a/tools/dep_updaters/update-brotli.sh b/tools/dep_updaters/update-brotli.sh index c7e8979d178526..90b65ed31a284b 100755 --- a/tools/dep_updaters/update-brotli.sh +++ b/tools/dep_updaters/update-brotli.sh @@ -60,12 +60,15 @@ mv "brotli-$NEW_VERSION" "brotli" echo "Copying existing gyp file" cp "$DEPS_DIR/brotli/brotli.gyp" "$WORKSPACE/brotli" +echo "Copying existing GN files" +cp "$DEPS_DIR/brotli/"*.gn "$DEPS_DIR/brotli/"*.gni "$WORKSPACE/brotli" + echo "Deleting existing brotli" rm -rf "$DEPS_DIR/brotli" mkdir "$DEPS_DIR/brotli" echo "Update c and LICENSE" -mv "$WORKSPACE/brotli/c" "$WORKSPACE/brotli/LICENSE" "$WORKSPACE/brotli/brotli.gyp" "$DEPS_DIR/brotli" +mv "$WORKSPACE/brotli/"*.gn "$WORKSPACE/brotli/"*.gni "$WORKSPACE/brotli/c" "$WORKSPACE/brotli/LICENSE" "$WORKSPACE/brotli/brotli.gyp" "$DEPS_DIR/brotli" # Update the version number on maintaining-dependencies.md # and print the new version as the last line of the script as we need diff --git a/tools/dep_updaters/update-c-ares.sh b/tools/dep_updaters/update-c-ares.sh index 4a679105405c2d..5081a74545dbf2 100755 --- a/tools/dep_updaters/update-c-ares.sh +++ b/tools/dep_updaters/update-c-ares.sh @@ -56,10 +56,11 @@ mv "c-ares-$NEW_VERSION" cares echo "Removing tests" rm -rf "$WORKSPACE/cares/test" -echo "Copying existing .gitignore, config and gyp files" +echo "Copying existing .gitignore, config, gyp and gn files" cp -R "$DEPS_DIR/cares/config" "$WORKSPACE/cares" cp "$DEPS_DIR/cares/.gitignore" "$WORKSPACE/cares" cp "$DEPS_DIR/cares/cares.gyp" "$WORKSPACE/cares" +cp "$DEPS_DIR/cares/"*.gn "$DEPS_DIR/cares/"*.gni "$WORKSPACE/cares" echo "Replacing existing c-ares" rm -rf "$DEPS_DIR/cares" diff --git a/tools/dep_updaters/update-libuv.sh b/tools/dep_updaters/update-libuv.sh index 83c285ecaa2000..c2524ddbf0dd66 100755 --- a/tools/dep_updaters/update-libuv.sh +++ b/tools/dep_updaters/update-libuv.sh @@ -59,8 +59,8 @@ gzip -dc "$LIBUV_TARBALL" | tar xf - rm "$LIBUV_TARBALL" mv libuv-libuv-* uv -echo "Replacing existing libuv (except GYP build files)" -mv "$DEPS_DIR/uv/"*.gyp "$DEPS_DIR/uv/"*.gypi "$WORKSPACE/uv/" +echo "Replacing existing libuv (except GYP and GN build files)" +mv "$DEPS_DIR/uv/"*.gyp "$DEPS_DIR/uv/"*.gypi "$DEPS_DIR/uv/"*.gn "$DEPS_DIR/uv/"*.gni "$WORKSPACE/uv/" rm -rf "$DEPS_DIR/uv" mv "$WORKSPACE/uv" "$DEPS_DIR/" diff --git a/tools/dep_updaters/update-llhttp.sh b/tools/dep_updaters/update-llhttp.sh index c9462748775287..739819e1a45b69 100755 --- a/tools/dep_updaters/update-llhttp.sh +++ b/tools/dep_updaters/update-llhttp.sh @@ -45,6 +45,9 @@ trap cleanup INT TERM EXIT cd "$WORKSPACE" +echo "Replacing existing llhttp (except GYP and GN build files)" +mv "$DEPS_DIR/llhttp/"*.gn "$DEPS_DIR/llhttp/"*.gni "$WORKSPACE/" + if echo "$NEW_VERSION" | grep -qs "/" ; then # Download a release REPO="git@github.com:$NEW_VERSION.git" BRANCH=$2 @@ -74,6 +77,8 @@ else cp -a "llhttp-release-v$NEW_VERSION" "$DEPS_DIR/llhttp" fi +mv "$WORKSPACE/"*.gn "$WORKSPACE/"*.gni "$DEPS_DIR/llhttp" + # Update the version number on maintaining-dependencies.md # and print the new version as the last line of the script as we need # to add it to $GITHUB_ENV variable diff --git a/tools/dep_updaters/update-nghttp2.sh b/tools/dep_updaters/update-nghttp2.sh index 4c375c979691f6..ccb36caae13d4d 100755 --- a/tools/dep_updaters/update-nghttp2.sh +++ b/tools/dep_updaters/update-nghttp2.sh @@ -73,6 +73,9 @@ cp "$DEPS_DIR/nghttp2/lib/includes/config.h" "$WORKSPACE/nghttp2/lib/includes" echo "Copying existing gyp files" cp "$DEPS_DIR/nghttp2/nghttp2.gyp" "$WORKSPACE/nghttp2" +echo "Copying existing GN files" +cp "$DEPS_DIR/nghttp2/"*.gn "$DEPS_DIR/nghttp2/"*.gni "$WORKSPACE/nghttp2" + echo "Replacing existing nghttp2" rm -rf "$DEPS_DIR/nghttp2" mv "$WORKSPACE/nghttp2" "$DEPS_DIR/" diff --git a/tools/dep_updaters/update-postject.sh b/tools/dep_updaters/update-postject.sh index 55c0de21a7f1b1..671bcd5a3a9ef6 100755 --- a/tools/dep_updaters/update-postject.sh +++ b/tools/dep_updaters/update-postject.sh @@ -7,13 +7,14 @@ set -ex -ROOT=$(cd "$(dirname "$0")/../.." && pwd) -[ -z "$NODE" ] && NODE="$ROOT/out/Release/node" +BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd) +DEPS_DIR="$BASE_DIR/deps" +[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node" [ -x "$NODE" ] || NODE=$(command -v node) -NPM="$ROOT/deps/npm/bin/npm-cli.js" +NPM="$BASE_DIR/deps/npm/bin/npm-cli.js" # shellcheck disable=SC1091 -. "$ROOT/tools/dep_updaters/utils.sh" +. "$BASE_DIR/tools/dep_updaters/utils.sh" NEW_VERSION=$("$NODE" "$NPM" view postject dist-tags.latest) CURRENT_VERSION=$("$NODE" -p "require('./test/fixtures/postject-copy/node_modules/postject/package.json').version") @@ -21,21 +22,34 @@ CURRENT_VERSION=$("$NODE" -p "require('./test/fixtures/postject-copy/node_module # This function exit with 0 if new version and current version are the same compare_dependency_version "postject" "$NEW_VERSION" "$CURRENT_VERSION" -cd "$( dirname "$0" )/../.." || exit -rm -rf test/fixtures/postject-copy -mkdir test/fixtures/postject-copy -cd test/fixtures/postject-copy || exit +echo "Making temporary workspace..." + +WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp') + +cleanup () { + EXIT_CODE=$? + [ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE" + exit $EXIT_CODE +} + +trap cleanup INT TERM EXIT + +cd "$WORKSPACE" + +echo "Installing postject npm package..." "$NODE" "$NPM" init --yes "$NODE" "$NPM" install --no-bin-links --ignore-scripts "postject@$NEW_VERSION" -# TODO(RaisinTen): Replace following with $WORKSPACE -cd ../../.. -rm -rf deps/postject -mkdir deps/postject -cp test/fixtures/postject-copy/node_modules/postject/LICENSE deps/postject -cp test/fixtures/postject-copy/node_modules/postject/dist/postject-api.h deps/postject +echo "Replacing existing postject (except GN build files)" + +mv "$DEPS_DIR/postject/"*.gn "$DEPS_DIR/postject/"*.gni "$WORKSPACE/" +rm -rf "$DEPS_DIR/postject" +mkdir "$DEPS_DIR/postject" +mv "$WORKSPACE/"*.gn "$WORKSPACE/"*.gni "$DEPS_DIR/postject" +mv "$WORKSPACE/node_modules/postject/LICENSE" "$DEPS_DIR/postject" +mv "$WORKSPACE/node_modules/postject/dist/postject-api.h" "$DEPS_DIR/postject" # Update the version number on maintaining-dependencies.md # and print the new version as the last line of the script as we need diff --git a/tools/dep_updaters/update-simdutf.sh b/tools/dep_updaters/update-simdutf.sh index ce22798006e546..bb4ea276548ed1 100755 --- a/tools/dep_updaters/update-simdutf.sh +++ b/tools/dep_updaters/update-simdutf.sh @@ -54,8 +54,8 @@ rm ./*_demo.cpp curl -sL -o "$SIMDUTF_LICENSE" "https://raw.githubusercontent.com/simdutf/simdutf/HEAD/LICENSE-MIT" -echo "Replacing existing simdutf (except GYP build files)" -mv "$DEPS_DIR/simdutf/"*.gyp "$DEPS_DIR/simdutf/README.md" "$WORKSPACE/" +echo "Replacing existing simdutf (except GYP and GN build files)" +mv "$DEPS_DIR/simdutf/"*.gyp "$DEPS_DIR/simdutf/"*.gn "$DEPS_DIR/simdutf/"*.gni "$DEPS_DIR/simdutf/README.md" "$WORKSPACE/" rm -rf "$DEPS_DIR/simdutf" mv "$WORKSPACE" "$DEPS_DIR/simdutf" diff --git a/tools/dep_updaters/update-uvwasi.sh b/tools/dep_updaters/update-uvwasi.sh index c36a7377bf44bc..8b4070cb336565 100755 --- a/tools/dep_updaters/update-uvwasi.sh +++ b/tools/dep_updaters/update-uvwasi.sh @@ -54,13 +54,17 @@ log_and_verify_sha256sum "uvwasi" "$UVWASI_ZIP.zip" echo "Moving existing GYP build file" mv "$DEPS_DIR/uvwasi/"*.gyp "$WORKSPACE/" + +echo "Moving existing GN build file" +mv "$DEPS_DIR/uvwasi/"*.gn "$DEPS_DIR/uvwasi/"*.gni "$WORKSPACE/" + rm -rf "$DEPS_DIR/uvwasi/" echo "Unzipping..." unzip "$UVWASI_ZIP.zip" -d "$DEPS_DIR/uvwasi/" rm "$UVWASI_ZIP.zip" -mv "$WORKSPACE/"*.gyp "$DEPS_DIR/uvwasi/" +mv "$WORKSPACE/"*.gyp "$WORKSPACE/"*.gn "$WORKSPACE/"*.gni "$DEPS_DIR/uvwasi/" cd "$DEPS_DIR/uvwasi/" echo "Copying new files to deps folder"