From 639c3d56040bf8a871437678aee5ecb1f5e1155e Mon Sep 17 00:00:00 2001 From: legendecas Date: Mon, 12 Jul 2021 08:55:29 +0800 Subject: [PATCH] tools: add multiple locations support in license builder --- LICENSE | 2 +- tools/license-builder.sh | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/LICENSE b/LICENSE index 18392b1d6a1a5fa..d06b2660d7a6210 100644 --- a/LICENSE +++ b/LICENSE @@ -1251,7 +1251,7 @@ The externally maintained libraries used by Node.js are: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -- gtest, located at src/gtest and test/cctest/gtest, is licensed as follows: +- gtest, located at src/gtest, test/cctest/gtest, is licensed as follows: """ Copyright 2008, Google Inc. All rights reserved. diff --git a/tools/license-builder.sh b/tools/license-builder.sh index 56f2840c0466461..8264ed4648c4acc 100755 --- a/tools/license-builder.sh +++ b/tools/license-builder.sh @@ -8,14 +8,27 @@ licensehead="$(sed '/^- /,$d' "${licensefile}")" tmplicense="${rootdir}/~LICENSE.$$" echo "$licensehead" > "$tmplicense" +join_by() { + local d=${1-} f=${2-} + if shift 2; then + printf %s "$f" "${@/#/$d}" + fi +} + # addlicense addlicense() { + argv=("$@") + location_count=$(expr $# - 2) + locations=("${argv[@]:1:location_count}") + location_str=$(join_by ", " ${locations[@]}) + + license=("${argv[@]: -1:1}") echo " -- ${1}, located at ${2}, is licensed as follows: +- ${1}, located at ${location_str}, is licensed as follows: \"\"\" -$(echo "$3" | sed -e 's/^/ /' -e 's/^ $//' -e 's/ *$//' | sed -e '/./,$!d' | sed -e '/^$/N;/^\n$/D') +$(echo "$license" | sed -e 's/^/ /' -e 's/^ $//' -e 's/ *$//' | sed -e '/./,$!d' | sed -e '/^$/N;/^\n$/D') \"\"\"\ " >> "$tmplicense" @@ -83,7 +96,7 @@ addlicense "cpplint.py" "tools/cpplint.py" \ "$(sed -e '/^$/,$d' -e 's/^#$//' -e 's/^# //' "${rootdir}"/tools/cpplint.py | tail -n +3)" addlicense "ESLint" "tools/node_modules/eslint" "$(cat "${rootdir}"/tools/node_modules/eslint/LICENSE)" addlicense "Babel" "tools/node_modules/@babel" "$(cat "${rootdir}"/tools/node_modules/@babel/core/LICENSE)" -addlicense "gtest" "test/cctest/gtest" "$(cat "${rootdir}"/test/cctest/gtest/LICENSE)" +addlicense "gtest" "src/gtest" "test/cctest/gtest" "$(cat "${rootdir}"/test/cctest/gtest/LICENSE)" # nghttp2 addlicense "nghttp2" "deps/nghttp2" "$(cat "${rootdir}"/deps/nghttp2/COPYING)"