From 5295129a7cb43ace66ccfc07c6b6dff899e13882 Mon Sep 17 00:00:00 2001 From: Taner Sener Date: Mon, 16 Aug 2021 00:18:40 +0300 Subject: [PATCH] copy license files into android archives, fixes #12 --- android.sh | 30 +++++++++++++++++++ .../src/main/res/raw/.gitignore | 1 + scripts/function-apple.sh | 14 --------- scripts/function.sh | 29 ++++++++++++++++-- 4 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 android/ffmpeg-kit-android-lib/src/main/res/raw/.gitignore diff --git a/android.sh b/android.sh index d2abaf8f..8245737b 100755 --- a/android.sh +++ b/android.sh @@ -265,6 +265,35 @@ if [[ -n ${ANDROID_ARCHITECTURES} ]]; then cd "${BASEDIR}"/android 1>>"${BASEDIR}"/build.log 2>&1 || exit 1 + # COPY LICENSES + LICENSE_BASEDIR="${BASEDIR}"/android/ffmpeg-kit-android-lib/src/main/res/raw + rm -f "${LICENSE_BASEDIR}"/*.txt 1>>"${BASEDIR}"/build.log 2>&1 || exit 1 + for library in {0..46}; do + if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then + ENABLED_LIBRARY=$(get_library_name ${library} | sed 's/-/_/g') + LICENSE_FILE="${LICENSE_BASEDIR}/license_${ENABLED_LIBRARY}.txt" + + RC=$(copy_external_library_license_file ${library} "${LICENSE_FILE}") + + if [[ ${RC} -ne 0 ]]; then + echo -e "DEBUG: Failed to copy the license file of ${ENABLED_LIBRARY}\n" 1>>"${BASEDIR}"/build.log 2>&1 + echo -e "failed\n\nSee build.log for details\n" + exit 1 + fi + + echo -e "DEBUG: Copied the license file of ${ENABLED_LIBRARY} successfully\n" 1>>"${BASEDIR}"/build.log 2>&1 + fi + done + + # COPY LIBRARY LICENSES + if [[ ${GPL_ENABLED} == "yes" ]]; then + cp "${BASEDIR}"/LICENSE.GPLv3 "${LICENSE_BASEDIR}"/license.txt 1>>"${BASEDIR}"/build.log 2>&1 + else + cp "${BASEDIR}"/LICENSE.LGPLv3 "${LICENSE_BASEDIR}"/license.txt 1>>"${BASEDIR}"/build.log 2>&1 + fi + + echo -e "DEBUG: Copied the ffmpeg-kit license successfully\n" 1>>"${BASEDIR}"/build.log 2>&1 + # BUILD NATIVE LIBRARY if [[ ${SKIP_ffmpeg_kit} -ne 1 ]]; then "${ANDROID_NDK_ROOT}"/ndk-build -B 1>>"${BASEDIR}"/build.log 2>&1 @@ -287,6 +316,7 @@ if [[ -n ${ANDROID_ARCHITECTURES} ]]; then echo -e -n "\nCreating Android archive under prebuilt: " # BUILD ANDROID ARCHIVE + rm -f "${BASEDIR}"/android/ffmpeg-kit-android-lib/build/outputs/aar/ffmpeg-kit-release.aar 1>>"${BASEDIR}"/build.log 2>&1 ./gradlew ffmpeg-kit-android-lib:clean ffmpeg-kit-android-lib:assembleRelease ffmpeg-kit-android-lib:testReleaseUnitTest 1>>"${BASEDIR}"/build.log 2>&1 if [ $? -ne 0 ]; then echo -e "failed\n" diff --git a/android/ffmpeg-kit-android-lib/src/main/res/raw/.gitignore b/android/ffmpeg-kit-android-lib/src/main/res/raw/.gitignore new file mode 100644 index 00000000..2211df63 --- /dev/null +++ b/android/ffmpeg-kit-android-lib/src/main/res/raw/.gitignore @@ -0,0 +1 @@ +*.txt diff --git a/scripts/function-apple.sh b/scripts/function-apple.sh index ecdf792b..97bc79ec 100755 --- a/scripts/function-apple.sh +++ b/scripts/function-apple.sh @@ -14,20 +14,6 @@ get_ffmpeg_kit_version() { fi } -# 1 - library index -# 2 - output path -copy_external_library_license() { - output_path_array=("$2") - for output_path in "${output_path_array[@]}"; do - $(cp $(get_external_library_license_path "$1") "${output_path}/LICENSE" 1>>"${BASEDIR}"/build.log 2>&1) - if [[ $? -ne 0 ]]; then - echo 1 - return - fi - done - echo 0 -} - get_external_library_version() { local library_version=$(grep Version "${BASEDIR}"/prebuilt/"$(get_build_directory)"/pkgconfig/"$1".pc 2>>"${BASEDIR}"/build.log | sed 's/Version://g;s/\ //g') diff --git a/scripts/function.sh b/scripts/function.sh index de2f1961..ae7c699e 100755 --- a/scripts/function.sh +++ b/scripts/function.sh @@ -1306,13 +1306,38 @@ get_external_library_license_path() { 26) echo "${BASEDIR}/src/$(get_library_name "$1")/COPYING.LGPL" ;; 28 | 35) echo "${BASEDIR}/src/$(get_library_name "$1")/LICENSE.md " ;; 30) echo "${BASEDIR}/src/$(get_library_name "$1")/COPYING.txt" ;; - 38 | 40) echo "${BASEDIR}/src/$(get_library_name "$1")/COPYRIGHT" ;; + 40) echo "${BASEDIR}/src/$(get_library_name "$1")/COPYRIGHT" ;; 43) echo "${BASEDIR}/src/$(get_library_name "$1")/leptonica-license.txt" ;; - 4 | 10 | 13 | 21 | 27 | 31 | 32 | 37) echo "${BASEDIR}/src/$(get_library_name "$1")/LICENSE" ;; + 4 | 10 | 13 | 21 | 27 | 31 | 32 | 37 | 46) echo "${BASEDIR}/src/$(get_library_name "$1")/LICENSE" ;; *) echo "${BASEDIR}/src/$(get_library_name "$1")/COPYING" ;; esac } +# 1 - library index +# 2 - output directory +copy_external_library_license() { + output_path_array=("$2") + for output_path in "${output_path_array[@]}"; do + $(copy_external_library_license_file "$1" "${output_path}/LICENSE") + if [[ $? -ne 0 ]]; then + echo 1 + return + fi + done + echo 0 +} + +# 1 - library index +# 2 - output path +copy_external_library_license_file() { + $(cp $(get_external_library_license_path "$1") "$2" 1>>"${BASEDIR}"/build.log 2>&1) + if [[ $? -ne 0 ]]; then + echo 1 + return + fi + echo 0 +} + get_cmake_build_directory() { echo "${FFMPEG_KIT_TMPDIR}/cmake/build/$(get_build_directory)/${LIB_NAME}" }