Skip to content

[TheOneric] Speedup license extraction #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- name: Build Binaries
run: |
docker run --rm -v "${PWD}":/code libass/jso:latest
docker run --rm --env LC_ALL=C.UTF-8 -v "${PWD}":/code libass/jso:latest

- name: Upload Nightly Build
uses: actions/upload-artifact@v2
Expand Down
33 changes: 3 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -195,36 +195,9 @@ dist/js/subtitles-octopus.js: dist/license/all src/subtitles-octopus.js
mkdir -p dist/js
awk '1 {print "// "$$0}' dist/license/all | cat - src/subtitles-octopus.js > $@

LIB_LICENSES := brotli expat freetype fribidi fontconfig harfbuzz libass
LIB_LICENSES_FINDOPT_brotli := -path ./research -prune -false -o ! -path ./js/decode.min.js
LIB_LICENSES_FINDOPT_expat := -path ./expat/fuzz -prune -false -o
LIB_LICENSES_FINDOPT_freetype := -path ./src/tools -prune -false -o
LIB_LICENSES_FINDOPT_fribidi := -path ./bin -prune -false -o
LIB_LICENSES_FINDOPT_harfbuzz := -path ./test -prune -false -o

$(addprefix dist/license/, $(LIB_LICENSES)): dist/license/%: .git/modules/lib/%/HEAD build/license_extract.sh build/license_defaults
@mkdir -p dist/license
(cd "lib/$*" && FINDOPTS="$(LIB_LICENSES_FINDOPT_$*)" \
../../build/license_extract.sh ../../build/license_defaults "$*" .) > $@

dist/license/subtitlesoctopus: .git/HEAD build/license_extract.sh
@mkdir -p dist/license
build/license_extract.sh build/license_defaults subtitlesoctopus src > dist/license/subtitlesoctopus

dist/license/all: dist/license/subtitlesoctopus $(addprefix dist/license/, $(LIB_LICENSES)) build/license_fullnotice build/license_lint.awk
@echo "# The following lists all copyright notices and licenses for the" > dist/license/all
@echo "# work contained in JavascriptSubtitlesOctopus per project." >> dist/license/all
@echo "" >> dist/license/all

@echo "Concatenate extracted license info..."
@$(foreach LIB_PROJ, subtitlesoctopus $(LIB_LICENSES), \
echo "# Project: $(LIB_PROJ)" >> dist/license/all && \
cat dist/license/$(LIB_PROJ) >> dist/license/all && \
) :

mv dist/license/all dist/license/all.tmp
build/license_lint.awk dist/license/all.tmp build/license_fullnotice
cat dist/license/all.tmp build/license_fullnotice > dist/license/all
dist/license/all:
@#FIXME: allow -j in toplevel Makefile and reintegrate licence extraction into this file
make -j "$$(nproc)" -f Makefile_licence all

dist/js/COPYRIGHT: dist/license/all
cp "$<" "$@"
Expand Down
37 changes: 37 additions & 0 deletions Makefile_licence
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# FIXME: temporarily split Makefile to parallelise licence info extraction
# once -j can be passed to the toplevel Makefile this should be moved
# back into the main Makefile

all: dist/license/all
.PHONY: all

LIB_LICENSES := brotli expat freetype fribidi fontconfig harfbuzz libass
LIB_LICENSES_FINDOPT_brotli := -path ./research -prune -false -o ! -path ./js/decode.min.js
LIB_LICENSES_FINDOPT_expat := -path ./expat/fuzz -prune -false -o
LIB_LICENSES_FINDOPT_freetype := -path ./src/tools -prune -false -o
LIB_LICENSES_FINDOPT_fribidi := -path ./bin -prune -false -o
LIB_LICENSES_FINDOPT_harfbuzz := -path ./test -prune -false -o

$(addprefix dist/license/, $(LIB_LICENSES)): dist/license/%: .git/modules/lib/%/HEAD build/license_extract.sh build/license_defaults
@mkdir -p dist/license
(cd "lib/$*" && FINDOPTS="$(LIB_LICENSES_FINDOPT_$*)" \
../../build/license_extract.sh ../../build/license_defaults "$*" .) > $@

dist/license/subtitlesoctopus: .git/HEAD build/license_extract.sh
@mkdir -p dist/license
build/license_extract.sh build/license_defaults subtitlesoctopus src > dist/license/subtitlesoctopus

dist/license/all: dist/license/subtitlesoctopus $(addprefix dist/license/, $(LIB_LICENSES)) build/license_fullnotice build/license_lint.awk
@echo "# The following lists all copyright notices and licenses for the" > dist/license/all
@echo "# work contained in JavascriptSubtitlesOctopus per project." >> dist/license/all
@echo "" >> dist/license/all

@echo "Concatenate extracted license info..."
@$(foreach LIB_PROJ, subtitlesoctopus $(LIB_LICENSES), \
echo "# Project: $(LIB_PROJ)" >> dist/license/all && \
cat dist/license/$(LIB_PROJ) >> dist/license/all && \
) :

mv dist/license/all dist/license/all.tmp
build/license_lint.awk dist/license/all.tmp build/license_fullnotice
cat dist/license/all.tmp build/license_fullnotice > dist/license/all
8 changes: 5 additions & 3 deletions build/license_extract.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# Copyright 2021 Oneric
# SPDX-License-Identifier: ISC
Expand Down Expand Up @@ -40,9 +40,11 @@ else
exit 2
fi

# Do not ignore licensecheck errors
set -o pipefail

find "$base_dir" $FINDOPTS -type f -regextype egrep -regex '.*\.(c|h|cpp|hpp|js)$' -exec \
licensecheck --machine --copyright --deb-fmt '{}' \; \
find "$base_dir" $FINDOPTS -type f -regextype egrep -regex '.*\.(c|h|cpp|hpp|js)$' -print0 \
| xargs -0 -P1 licensecheck --machine --copyright --deb-fmt --encoding UTF-8 \
| awk -F"$tabulator" -v base_dir="$base_dir" \
-v def_license="$def_license" -v def_copy="$def_copy" '
BEGIN {
Expand Down
2 changes: 1 addition & 1 deletion build/license_lint.awk
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fulltext && /^License: / {

END {
for (l in licenses) {
if(l == "public-domain")
if(l == "public-domain" || l == "Unlicense")
continue # No notice required
print "Missing full text for '"l"'!" | "cat>&2"
++errors
Expand Down
2 changes: 1 addition & 1 deletion run-buildah-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ if [ "$FAST" -eq 0 ] ; then
buildah rm "$CONTAINER" >/dev/null 2>&1 || :
buildah from --name "$CONTAINER" "$IMAGE":latest
fi
buildah run -t -v "${PWD}":/code "$CONTAINER" $cmd "$@"
buildah run -t --env LC_ALL=C.UTF-8 -v "${PWD}":/code "$CONTAINER" $cmd "$@"
4 changes: 2 additions & 2 deletions run-docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [ "$FAST" -eq 0 ] ; then
docker build -t "$IMAGE" .
fi
if [ "$#" -eq 0 ] ; then
docker run -it --rm -v "${PWD}":/code --name "$CONTAINER" "$IMAGE":latest
docker run -it --rm --env LC_ALL=C.UTF-8 -v "${PWD}":/code --name "$CONTAINER" "$IMAGE":latest
else
docker run -it --rm -v "${PWD}":/code --name "$CONTAINER" "$IMAGE":latest "$@"
docker run -it --rm --env LC_ALL=C.UTF-8 -v "${PWD}":/code --name "$CONTAINER" "$IMAGE":latest "$@"
fi