Skip to content

Commit 68f1094

Browse files
authored
Merge pull request #256 from pspdev/add-create-license-directory-script
Add psp-create-license-directory script
2 parents 560b950 + 691f858 commit 68f1094

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

m4/pspdev.m4

+3
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ AC_DEFUN([AC_PSPDEV_PATH],
2929
pspdev_includedir="$pspdev/psp/include"
3030
pspdev_libdir="$pspdev/psp/lib"
3131
pspdev_sharedir="$pspdev/psp/share"
32+
pspdev_bindir="$pspdev/bin"
3233
PSPDEV_INCLUDEDIR="$pspdev_includedir"
3334
PSPDEV_LIBDIR="$pspdev_libdir"
3435
PSPDEV_SHAREDIR="$pspdev_sharedir"
36+
PSPDEV_BINDIR="$pspdev_bindir"
3537
AC_SUBST(PSPDEV_INCLUDEDIR)
3638
AC_SUBST(PSPDEV_LIBDIR)
3739
AC_SUBST(PSPDEV_SHAREDIR)
40+
AC_SUBST(PSPDEV_BINDIR)
3841
])
3942

4043
dnl Check for a tool prefixed with "psp-".

tools/Makefile.am

+3
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ psp_prxgen_SOURCES = psp-prxgen.c getopt_long.c
2121
psp_fixup_imports_SOURCES = psp-fixup-imports.c getopt_long.c sha1.c
2222

2323
noinst_HEADERS = elftypes.h getopt.h prxtypes.h sha1.h types.h
24+
25+
psp_create_license_directorydir = @PSPDEV_BINDIR@
26+
psp_create_license_directory_SCRIPTS = psp-create-license-directory

tools/psp-create-license-directory

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/bin/bash
2+
3+
LICENSE_DIRECTORY="third-party-licenses"
4+
EXIT_CODE=0
5+
LIBRARIES=("pspsdk" "newlib" "pthread-embedded" $@)
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+
The licenses for pspsdk, newlib and pthread-embedded are always addded,
14+
since they will always be compiled into your project.
15+
16+
options:
17+
-h Print this message
18+
-l List installed libraries
19+
20+
example:
21+
If your project has included SDL2, SDL2_ttf and jsoncpp:
22+
23+
${SCRIPT_NAME} sdl2 sdl2-ttf jsoncpp
24+
25+
To get a list of installed libraries to get the name right use:
26+
27+
${SCRIPT_NAME} -l
28+
29+
EOF
30+
}
31+
32+
get_dependencies ( ) {
33+
if [ "${1}" != "pspsdk" ] && [ "${1}" != "newlib" ] && [ "${1}" != "pthread-embedded" ]; then
34+
echo "$(psp-pacman -Qi ${1}|grep "^Depends On"|cut -d':' -f 2-|xargs echo)"
35+
fi
36+
}
37+
38+
copy_license_directory ( ) {
39+
if [ -d "${PSPDEV}/psp/share/licenses/${1}" ]; then
40+
if [ ! -d "${LICENSE_DIRECTORY}/${1}" ]; then
41+
echo "Adding license for ${1} to ${LICENSE_DIRECTORY}"
42+
fi
43+
cp -rf "${PSPDEV}/psp/share/licenses/${1}" "${LICENSE_DIRECTORY}/"
44+
for dependency in $(get_dependencies "${1}"); do
45+
if [ "${dependency}" == "None" ]; then
46+
continue
47+
fi
48+
if [ ! -d "${LICENSE_DIRECTORY}/${dependency}" ]; then
49+
echo "Found dependency ${dependency} for ${1}"
50+
fi
51+
copy_license_directory "${dependency}"
52+
done
53+
else
54+
echo "Failed to find license for library ${1}"
55+
EXIT_CODE=2
56+
fi
57+
}
58+
59+
if [ -z "${PSPDEV}" ]; then
60+
echo "The PSPDEV environment variable has not been set"
61+
exit 1
62+
fi
63+
64+
while getopts "hl" OPTION; do
65+
case ${OPTION} in
66+
h)
67+
usage
68+
exit 0
69+
;;
70+
l)
71+
psp-pacman -Qq
72+
exit 0
73+
;;
74+
*)
75+
echo "${OPTION} - Unrecongnized option"
76+
usage
77+
exit 1
78+
;;
79+
esac
80+
done
81+
82+
mkdir -p "${LICENSE_DIRECTORY}"
83+
for library in ${LIBRARIES[@]}; do
84+
copy_license_directory "${library}"
85+
done
86+
exit ${EXIT_CODE}

0 commit comments

Comments
 (0)