Skip to content
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

Add psp-create-license-directory script #256

Merged
merged 1 commit into from
Dec 24, 2024
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
3 changes: 3 additions & 0 deletions m4/pspdev.m4
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ AC_DEFUN([AC_PSPDEV_PATH],
pspdev_includedir="$pspdev/psp/include"
pspdev_libdir="$pspdev/psp/lib"
pspdev_sharedir="$pspdev/psp/share"
pspdev_bindir="$pspdev/bin"
PSPDEV_INCLUDEDIR="$pspdev_includedir"
PSPDEV_LIBDIR="$pspdev_libdir"
PSPDEV_SHAREDIR="$pspdev_sharedir"
PSPDEV_BINDIR="$pspdev_bindir"
AC_SUBST(PSPDEV_INCLUDEDIR)
AC_SUBST(PSPDEV_LIBDIR)
AC_SUBST(PSPDEV_SHAREDIR)
AC_SUBST(PSPDEV_BINDIR)
])

dnl Check for a tool prefixed with "psp-".
Expand Down
3 changes: 3 additions & 0 deletions tools/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 86 additions & 0 deletions tools/psp-create-license-directory
Original file line number Diff line number Diff line change
@@ -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}
Loading