mirror of
https://github.com/pspdev/pspsdk.git
synced 2025-10-03 16:51:27 +00:00
Add psp-create-license-directory script
This commit is contained in:
@@ -21,3 +21,6 @@ psp_prxgen_SOURCES = psp-prxgen.c getopt_long.c
|
||||
psp_fixup_imports_SOURCES = psp-fixup-imports.c getopt_long.c sha1.c
|
||||
|
||||
noinst_HEADERS = elftypes.h getopt.h prxtypes.h sha1.h types.h
|
||||
|
||||
psp_create_license_directorydir = @PSPDEV_BINDIR@
|
||||
psp_create_license_directory_SCRIPTS = psp-create-license-directory
|
86
tools/psp-create-license-directory
Executable file
86
tools/psp-create-license-directory
Executable file
@@ -0,0 +1,86 @@
|
||||
#!/bin/bash
|
||||
|
||||
LICENSE_DIRECTORY="third-party-licenses"
|
||||
EXIT_CODE=0
|
||||
LIBRARIES=("pspsdk" "newlib" "pthread-embedded" $@)
|
||||
SCRIPT_NAME="$(basename "$0")"
|
||||
|
||||
usage ( ) {
|
||||
cat <<EOF
|
||||
${SCRIPT_NAME} [OPTION] [LIBRARY]...
|
||||
The ${SCRIPT_NAME} tool makes it easier to comply with licenses of used libraries.
|
||||
It adds the licenses to the ${LICENSE_DIRECTORY} directory.
|
||||
The licenses for pspsdk, newlib and pthread-embedded are always addded,
|
||||
since they will always be compiled into your project.
|
||||
|
||||
options:
|
||||
-h Print this message
|
||||
-l List installed libraries
|
||||
|
||||
example:
|
||||
If your project has included SDL2, SDL2_ttf and jsoncpp:
|
||||
|
||||
${SCRIPT_NAME} sdl2 sdl2-ttf jsoncpp
|
||||
|
||||
To get a list of installed libraries to get the name right use:
|
||||
|
||||
${SCRIPT_NAME} -l
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
get_dependencies ( ) {
|
||||
if [ "${1}" != "pspsdk" ] && [ "${1}" != "newlib" ] && [ "${1}" != "pthread-embedded" ]; then
|
||||
echo "$(psp-pacman -Qi ${1}|grep "^Depends On"|cut -d':' -f 2-|xargs echo)"
|
||||
fi
|
||||
}
|
||||
|
||||
copy_license_directory ( ) {
|
||||
if [ -d "${PSPDEV}/psp/share/licenses/${1}" ]; then
|
||||
if [ ! -d "${LICENSE_DIRECTORY}/${1}" ]; then
|
||||
echo "Adding license for ${1} to ${LICENSE_DIRECTORY}"
|
||||
fi
|
||||
cp -rf "${PSPDEV}/psp/share/licenses/${1}" "${LICENSE_DIRECTORY}/"
|
||||
for dependency in $(get_dependencies "${1}"); do
|
||||
if [ "${dependency}" == "None" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ ! -d "${LICENSE_DIRECTORY}/${dependency}" ]; then
|
||||
echo "Found dependency ${dependency} for ${1}"
|
||||
fi
|
||||
copy_license_directory "${dependency}"
|
||||
done
|
||||
else
|
||||
echo "Failed to find license for library ${1}"
|
||||
EXIT_CODE=2
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -z "${PSPDEV}" ]; then
|
||||
echo "The PSPDEV environment variable has not been set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while getopts "hl" OPTION; do
|
||||
case ${OPTION} in
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
l)
|
||||
psp-pacman -Qq
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "${OPTION} - Unrecongnized option"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
mkdir -p "${LICENSE_DIRECTORY}"
|
||||
for library in ${LIBRARIES[@]}; do
|
||||
copy_license_directory "${library}"
|
||||
done
|
||||
exit ${EXIT_CODE}
|
Reference in New Issue
Block a user