Skip to content

Commit 6564e38

Browse files
committed
Add script to for adding third party licenses to Windows build
1 parent 68ee386 commit 6564e38

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jobs:
5757
cmake --build .
5858
strip --strip-unneeded laserkombat.exe
5959
cp ../COPYING ./
60+
../platform/windows/create-license-directory.sh mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_ttf
6061
- name: Publish artifacts
6162
uses: actions/upload-artifact@v7
6263
with:
@@ -65,6 +66,7 @@ jobs:
6566
laserkombat/laserkombat.exe
6667
laserkombat/assets
6768
laserkombat/COPYING
69+
laserkombat/third-party-licenses
6870
6971
PSP:
7072
runs-on: ubuntu-latest
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
3+
LICENSE_DIRECTORY="third-party-licenses"
4+
EXIT_CODE=0
5+
LIBRARIES=($@)
6+
SCRIPT_NAME="$(basename "$0")"
7+
8+
usage ( ) {
9+
cat <<EOF
10+
${SCRIPT_NAME} [OPTION] [LIBRARY]...
11+
The ${SCRIPT_NAME} tool makes it easier to comply with licenses of used libraries.
12+
It adds the licenses to the ${LICENSE_DIRECTORY} directory.
13+
14+
options:
15+
-h Print this message
16+
-l List installed libraries
17+
18+
example:
19+
If your project has included SDL2, SDL2_ttf and jsoncpp:
20+
21+
${SCRIPT_NAME} sdl2 sdl2-ttf jsoncpp
22+
23+
To get a list of installed libraries to get the name right use:
24+
25+
${SCRIPT_NAME} -l
26+
27+
EOF
28+
}
29+
30+
get_dependencies ( ) {
31+
echo "$(pacman -Qi ${1}|grep "^Depends On"|cut -d':' -f 2-|xargs echo)"
32+
}
33+
34+
copy_license_directory ( ) {
35+
if [ -d "/mingw64/share/licenses/${1}" ]; then
36+
if [ ! -d "${LICENSE_DIRECTORY}/${1}" ]; then
37+
echo "Adding license for ${1} to ${LICENSE_DIRECTORY}"
38+
fi
39+
cp -rf "/mingw64/share/licenses//${1}" "${LICENSE_DIRECTORY}/"
40+
for dependency in $(get_dependencies "${1}"); do
41+
if [ "${dependency}" == "None" ]; then
42+
continue
43+
fi
44+
if [ ! -d "${LICENSE_DIRECTORY}/${dependency}" ]; then
45+
echo "Found dependency ${dependency} for ${1}"
46+
fi
47+
copy_license_directory "${dependency}"
48+
done
49+
else
50+
echo "Failed to find license for library ${1}"
51+
EXIT_CODE=2
52+
fi
53+
}
54+
55+
while getopts "hl" OPTION; do
56+
case ${OPTION} in
57+
h)
58+
usage
59+
exit 0
60+
;;
61+
l)
62+
psp-pacman -Qq
63+
exit 0
64+
;;
65+
*)
66+
echo "${OPTION} - Unrecongnized option"
67+
usage
68+
exit 1
69+
;;
70+
esac
71+
done
72+
73+
mkdir -p "${LICENSE_DIRECTORY}"
74+
for library in ${LIBRARIES[@]}; do
75+
copy_license_directory "${library}"
76+
done
77+
exit ${EXIT_CODE}

0 commit comments

Comments
 (0)