Skip to content

Commit

Permalink
tools: add multiple locations support in license builder
Browse files Browse the repository at this point in the history
  • Loading branch information
legendecas committed Jul 12, 2021
1 parent 4de6f20 commit 639c3d5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 16 additions & 3 deletions tools/license-builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <library> <location> <license text>
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"

Expand Down Expand Up @@ -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)"
Expand Down

0 comments on commit 639c3d5

Please sign in to comment.