From 7381bbd2f454ea30655dd22fe092bbf8949b5f2f Mon Sep 17 00:00:00 2001 From: birros Date: Tue, 25 Jul 2023 03:07:12 +0200 Subject: [PATCH] build: Makefile first iteration --- .tool-versions | 1 + Makefile | 681 ++++++++++++++++++ README.md | 52 +- downloads/.gitignore | 2 - pkg/tool-versions/tool-versions.go | 1 + scripts/archives/build.sh | 12 +- scripts/extract/build.sh | 12 +- scripts/ffmpeg/build.sh | 11 +- scripts/frameworks/build.sh | 11 +- scripts/frameworks/ios/create_frameworks.sh | 11 +- scripts/frameworks/macos/create_frameworks.sh | 11 +- scripts/freetype/build.sh | 7 +- scripts/fribidi/build.sh | 7 +- scripts/harfbuzz/build.sh | 7 +- scripts/libass/build.sh | 11 +- scripts/libressl/build.sh | 13 +- scripts/libs-arch/build.sh | 33 + .../ios/fix_iossimulator_arm64.sh | 3 + scripts/{libs => libs-arch}/relink_dylibs.sh | 8 +- scripts/libs/build-arch.sh | 13 + scripts/libs/build-universal.sh | 31 +- scripts/libs/build.sh | 30 +- scripts/links/build.sh | 9 +- scripts/links/status.sh | 6 - scripts/mpv/build.sh | 7 +- scripts/pkg-config/build.sh | 11 +- scripts/uchardet/build.sh | 21 +- scripts/xcframeworks/build-generic.sh | 14 + scripts/xcframeworks/build-ios.sh | 35 + scripts/xcframeworks/build.sh | 10 + .../xcframeworks/ios/create_xcframeworks.sh | 13 - .../xcframeworks/macos/create_xcframeworks.sh | 11 - 32 files changed, 960 insertions(+), 145 deletions(-) create mode 100644 Makefile delete mode 100644 downloads/.gitignore create mode 100644 scripts/libs-arch/build.sh rename scripts/{libs => libs-arch}/ios/fix_iossimulator_arm64.sh (86%) rename scripts/{libs => libs-arch}/relink_dylibs.sh (89%) create mode 100644 scripts/libs/build-arch.sh delete mode 100644 scripts/links/status.sh create mode 100755 scripts/xcframeworks/build-generic.sh create mode 100755 scripts/xcframeworks/build-ios.sh create mode 100644 scripts/xcframeworks/build.sh delete mode 100755 scripts/xcframeworks/ios/create_xcframeworks.sh delete mode 100755 scripts/xcframeworks/macos/create_xcframeworks.sh diff --git a/.tool-versions b/.tool-versions index e7af890..f9ca9ad 100644 --- a/.tool-versions +++ b/.tool-versions @@ -2,6 +2,7 @@ clang 14.0.3 cmake 3.26.4 golang 1.20.5 macos 13.4.1 +make 3.81 meson 1.1.1 ninja 1.11.1 task 3.27.1 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6b6fdc6 --- /dev/null +++ b/Makefile @@ -0,0 +1,681 @@ +# Enable secondary expansions, needed for var substitution in rules's deps +.SECONDEXPANSION: + +# Create any number of jobs, but keep the load average below ncpu +MAKEFLAGS += "-j -l $(shell sysctl -n hw.ncpu) " + +HOST_OS = macos +ifeq ($(shell uname -m), x86_64) + HOST_ARCH = amd64 +else ifeq ($(shell uname -m), aarch64) + HOST_ARCH = arm64 +else + $(error "Invalid host arch: Your host arch must be amd64 or arm64") +endif + +VERSION ?= develop +PROJECT_DIR ?= ${PWD} +BUILD_DIR = build +INTERMEDIATE_DIR = ${BUILD_DIR}/intermediate +TMP_DIR = ${PROJECT_DIR}/${BUILD_DIR}/tmp +OUTPUT_DIR = ${BUILD_DIR}/output +DOWNLOADS_DIR = ${INTERMEDIATE_DIR}/downloads +LINKS_DIR = ${INTERMEDIATE_DIR}/links +PKGCONFIG_DIR = ${INTERMEDIATE_DIR}/pkg-config_${HOST_OS}-${HOST_ARCH} +SANDBOX_PATH = /bin:/usr/bin:${PROJECT_DIR}/${LINKS_DIR}/bin:${PROJECT_DIR}/${PKGCONFIG_DIR}/bin + +# chars +NULL = +SPACE = $(NULL) # DONT REMOVE THIS COMMENT!!! +COLON = : + +all: \ + build/output/libmpv-libs_${VERSION}_ios-arm64-audio.tar.gz \ + build/output/libmpv-libs_${VERSION}_ios-arm64-video.tar.gz \ + build/output/libmpv-libs_${VERSION}_iossimulator-universal-audio.tar.gz \ + build/output/libmpv-libs_${VERSION}_iossimulator-universal-video.tar.gz \ + build/output/libmpv-libs_${VERSION}_macos-universal-audio.tar.gz \ + build/output/libmpv-libs_${VERSION}_macos-universal-video.tar.gz \ + build/output/libmpv-xcframeworks_${VERSION}_ios-universal-audio.tar.gz \ + build/output/libmpv-xcframeworks_${VERSION}_ios-universal-video.tar.gz \ + build/output/libmpv-xcframeworks_${VERSION}_macos-universal-audio.tar.gz \ + build/output/libmpv-xcframeworks_${VERSION}_macos-universal-video.tar.gz + +${DOWNLOADS_DIR}: \ + downloads.lock + + @echo "\033[32mRULE\033[0m $@" + + mkdir -p ${INTERMEDIATE_DIR} + + $(eval TARGET_DIR=$@) + $(eval TARGET_NAME=$(notdir ${TARGET_DIR})) + $(eval TARGET_TMP_DIR=${TMP_DIR}/${TARGET_NAME}) + $(eval TARGET_OUTPUT_DIR=${TARGET_TMP_DIR}/output) + + rm -rf ${TARGET_TMP_DIR} ${TARGET_DIR} + mkdir -p ${TARGET_OUTPUT_DIR} + + go run cmd/downloads/main.go downloads.lock ${TARGET_OUTPUT_DIR} + + mv ${TARGET_OUTPUT_DIR} ${TARGET_DIR} + rm -rf ${TARGET_TMP_DIR} + +${LINKS_DIR}: + @echo "\033[32mRULE\033[0m $@" + + mkdir -p ${INTERMEDIATE_DIR} + + $(eval TARGET_DIR=$@) + $(eval TARGET_PATTERN=$*) + $(eval TARGET_NAME=$(notdir ${TARGET_DIR})) + $(eval TARGET_TMP_DIR=${TMP_DIR}/${TARGET_NAME}) + $(eval TARGET_OUTPUT_DIR=${PROJECT_DIR}/${TARGET_DIR}) + + rm -rf ${TARGET_DIR} + + env \ + BINARIES="meson ninja cmake" \ + OUTPUT_DIR=${TARGET_OUTPUT_DIR} \ + sh ${PROJECT_DIR}/scripts/links/build.sh + +# pkg-config_- +${INTERMEDIATE_DIR}/pkg-config_%: \ + ${DOWNLOADS_DIR} \ + ${LINKS_DIR} + + @echo "\033[32mRULE\033[0m $@" + + $(eval TARGET_DIR=$@) + $(eval TARGET_PATTERN=$*) + $(eval TARGET_NAME=$(notdir ${TARGET_DIR})) + $(eval TARGET_PKGNAME=$(firstword $(subst _${TARGET_PATTERN}, ,${TARGET_NAME}))) + $(eval TARGET_TMP_DIR=${TMP_DIR}/${TARGET_NAME}) + $(eval TARGET_SRC_DIR=${TARGET_TMP_DIR}/src/${TARGET_PKGNAME}) + $(eval TARGET_OUTPUT_DIR=${PROJECT_DIR}/${TARGET_DIR}) + + $(eval ARCHIVE_FILE=$(firstword $(wildcard ${DOWNLOADS_DIR}/${TARGET_PKGNAME}-*.tar.*))) + + $(eval TARGET_OS=$(word 1, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_ARCH=$(word 2, $(subst -, ,${TARGET_PATTERN}))) + + rm -rf ${TARGET_TMP_DIR} ${TARGET_DIR} + mkdir -p ${TARGET_TMP_DIR} + + env -i \ + PATH=${SANDBOX_PATH} \ + ARCHIVE_FILE=${ARCHIVE_FILE} \ + TARGET_DIR=${TARGET_SRC_DIR} \ + sh ${PROJECT_DIR}/scripts/extract/build.sh + + env -i \ + PATH=${SANDBOX_PATH} \ + PROJECT_DIR=${PROJECT_DIR} \ + OS=${TARGET_OS} \ + ARCH=${TARGET_ARCH} \ + SRC_DIR=${TARGET_SRC_DIR} \ + OUTPUT_DIR=${TARGET_OUTPUT_DIR} \ + sh ${PROJECT_DIR}/scripts/${TARGET_PKGNAME}/build.sh + + rm -rf ${TARGET_TMP_DIR} + +# libressl_- +${INTERMEDIATE_DIR}/libressl_%: \ + ${DOWNLOADS_DIR} \ + ${PKGCONFIG_DIR} + + @echo "\033[32mRULE\033[0m $@" + + $(eval TARGET_DIR=$@) + $(eval TARGET_PATTERN=$*) + $(eval TARGET_NAME=$(notdir ${TARGET_DIR})) + $(eval TARGET_PKGNAME=$(firstword $(subst _${TARGET_PATTERN}, ,${TARGET_NAME}))) + $(eval TARGET_TMP_DIR=${TMP_DIR}/${TARGET_NAME}) + $(eval TARGET_SRC_DIR=${TARGET_TMP_DIR}/src/${TARGET_PKGNAME}) + $(eval TARGET_OUTPUT_DIR=${PROJECT_DIR}/${TARGET_DIR}) + + $(eval ARCHIVE_FILE=$(firstword $(wildcard ${DOWNLOADS_DIR}/${TARGET_PKGNAME}-*.tar.*))) + + $(eval TARGET_OS=$(word 1, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_ARCH=$(word 2, $(subst -, ,${TARGET_PATTERN}))) + + rm -rf ${TARGET_TMP_DIR} ${TARGET_DIR} + mkdir -p ${TARGET_TMP_DIR} + + env -i \ + PATH=${SANDBOX_PATH} \ + ARCHIVE_FILE=${ARCHIVE_FILE} \ + TARGET_DIR=${TARGET_SRC_DIR} \ + sh ${PROJECT_DIR}/scripts/extract/build.sh + + env -i \ + PATH=${SANDBOX_PATH} \ + PROJECT_DIR=${PROJECT_DIR} \ + OS=${TARGET_OS} \ + ARCH=${TARGET_ARCH} \ + SRC_DIR=${TARGET_SRC_DIR} \ + OUTPUT_DIR=${TARGET_OUTPUT_DIR} \ + sh ${PROJECT_DIR}/scripts/${TARGET_PKGNAME}/build.sh + + rm -rf ${TARGET_TMP_DIR} + +# ffmpeg_-- +${INTERMEDIATE_DIR}/ffmpeg_%: \ + ${DOWNLOADS_DIR} \ + ${PKGCONFIG_DIR} \ + ${INTERMEDIATE_DIR}/libressl_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) + + @echo "\033[32mRULE\033[0m $@" + + $(eval TARGET_DIR=$@) + $(eval TARGET_PATTERN=$*) + $(eval TARGET_NAME=$(notdir ${TARGET_DIR})) + $(eval TARGET_PKGNAME=$(firstword $(subst _${TARGET_PATTERN}, ,${TARGET_NAME}))) + $(eval TARGET_TMP_DIR=${TMP_DIR}/${TARGET_NAME}) + $(eval TARGET_SRC_DIR=${TARGET_TMP_DIR}/src/${TARGET_PKGNAME}) + $(eval TARGET_OUTPUT_DIR=${PROJECT_DIR}/${TARGET_DIR}) + + $(eval ARCHIVE_FILE=$(firstword $(wildcard ${DOWNLOADS_DIR}/${TARGET_PKGNAME}-*.tar.*))) + + $(eval TARGET_OS=$(word 1, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_ARCH=$(word 2, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_VARIANT=$(word 3, $(subst -, ,${TARGET_PATTERN}))) + + $(eval PKG_CONFIG_PATH=${PROJECT_DIR}/${INTERMEDIATE_DIR}/libressl_${TARGET_OS}-${TARGET_ARCH}/lib/pkgconfig) + + rm -rf ${TARGET_TMP_DIR} ${TARGET_DIR} + mkdir -p ${TARGET_TMP_DIR} + + env -i \ + PATH=${SANDBOX_PATH} \ + ARCHIVE_FILE=${ARCHIVE_FILE} \ + TARGET_DIR=${TARGET_SRC_DIR} \ + sh ${PROJECT_DIR}/scripts/extract/build.sh + + env -i \ + PATH=${SANDBOX_PATH} \ + PROJECT_DIR=${PROJECT_DIR} \ + PKG_CONFIG_PATH=${PKG_CONFIG_PATH} \ + OS=${TARGET_OS} \ + ARCH=${TARGET_ARCH} \ + VARIANT=${TARGET_VARIANT} \ + SRC_DIR=${TARGET_SRC_DIR} \ + OUTPUT_DIR=${TARGET_OUTPUT_DIR} \ + sh ${PROJECT_DIR}/scripts/${TARGET_PKGNAME}/build.sh + + rm -rf ${TARGET_TMP_DIR} + +# harfbuzz_- +${INTERMEDIATE_DIR}/harfbuzz_%: \ + ${DOWNLOADS_DIR} \ + ${PKGCONFIG_DIR} + + @echo "\033[32mRULE\033[0m $@" + + $(eval TARGET_DIR=$@) + $(eval TARGET_PATTERN=$*) + $(eval TARGET_NAME=$(notdir ${TARGET_DIR})) + $(eval TARGET_PKGNAME=$(firstword $(subst _${TARGET_PATTERN}, ,${TARGET_NAME}))) + $(eval TARGET_TMP_DIR=${TMP_DIR}/${TARGET_NAME}) + $(eval TARGET_SRC_DIR=${TARGET_TMP_DIR}/src/${TARGET_PKGNAME}) + $(eval TARGET_OUTPUT_DIR=${PROJECT_DIR}/${TARGET_DIR}) + + $(eval ARCHIVE_FILE=$(firstword $(wildcard ${DOWNLOADS_DIR}/${TARGET_PKGNAME}-*.tar.*))) + + $(eval TARGET_OS=$(word 1, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_ARCH=$(word 2, $(subst -, ,${TARGET_PATTERN}))) + + rm -rf ${TARGET_TMP_DIR} ${TARGET_DIR} + mkdir -p ${TARGET_TMP_DIR} + + env -i \ + PATH=${SANDBOX_PATH} \ + ARCHIVE_FILE=${ARCHIVE_FILE} \ + TARGET_DIR=${TARGET_SRC_DIR} \ + sh ${PROJECT_DIR}/scripts/extract/build.sh + + env -i \ + PATH=${SANDBOX_PATH} \ + PROJECT_DIR=${PROJECT_DIR} \ + OS=${TARGET_OS} \ + ARCH=${TARGET_ARCH} \ + SRC_DIR=${TARGET_SRC_DIR} \ + OUTPUT_DIR=${TARGET_OUTPUT_DIR} \ + sh ${PROJECT_DIR}/scripts/${TARGET_PKGNAME}/build.sh + + rm -rf ${TARGET_TMP_DIR} + +# fribidi_- +${INTERMEDIATE_DIR}/fribidi_%: \ + ${DOWNLOADS_DIR} \ + ${PKGCONFIG_DIR} + + @echo "\033[32mRULE\033[0m $@" + + $(eval TARGET_DIR=$@) + $(eval TARGET_PATTERN=$*) + $(eval TARGET_NAME=$(notdir ${TARGET_DIR})) + $(eval TARGET_PKGNAME=$(firstword $(subst _${TARGET_PATTERN}, ,${TARGET_NAME}))) + $(eval TARGET_TMP_DIR=${TMP_DIR}/${TARGET_NAME}) + $(eval TARGET_SRC_DIR=${TARGET_TMP_DIR}/src/${TARGET_PKGNAME}) + $(eval TARGET_OUTPUT_DIR=${PROJECT_DIR}/${TARGET_DIR}) + + $(eval ARCHIVE_FILE=$(firstword $(wildcard ${DOWNLOADS_DIR}/${TARGET_PKGNAME}-*.tar.*))) + + $(eval TARGET_OS=$(word 1, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_ARCH=$(word 2, $(subst -, ,${TARGET_PATTERN}))) + + rm -rf ${TARGET_TMP_DIR} ${TARGET_DIR} + mkdir -p ${TARGET_TMP_DIR} + + env -i \ + PATH=${SANDBOX_PATH} \ + ARCHIVE_FILE=${ARCHIVE_FILE} \ + TARGET_DIR=${TARGET_SRC_DIR} \ + sh ${PROJECT_DIR}/scripts/extract/build.sh + + env -i \ + PATH=${SANDBOX_PATH} \ + PROJECT_DIR=${PROJECT_DIR} \ + OS=${TARGET_OS} \ + ARCH=${TARGET_ARCH} \ + SRC_DIR=${TARGET_SRC_DIR} \ + OUTPUT_DIR=${TARGET_OUTPUT_DIR} \ + sh ${PROJECT_DIR}/scripts/${TARGET_PKGNAME}/build.sh + + rm -rf ${TARGET_TMP_DIR} + +# freetype_- +${INTERMEDIATE_DIR}/freetype_%: \ + ${DOWNLOADS_DIR} \ + ${PKGCONFIG_DIR} \ + ${INTERMEDIATE_DIR}/harfbuzz_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) + + @echo "\033[32mRULE\033[0m $@" + + $(eval TARGET_DIR=$@) + $(eval TARGET_PATTERN=$*) + $(eval TARGET_NAME=$(notdir ${TARGET_DIR})) + $(eval TARGET_PKGNAME=$(firstword $(subst _${TARGET_PATTERN}, ,${TARGET_NAME}))) + $(eval TARGET_TMP_DIR=${TMP_DIR}/${TARGET_NAME}) + $(eval TARGET_SRC_DIR=${TARGET_TMP_DIR}/src/${TARGET_PKGNAME}) + $(eval TARGET_OUTPUT_DIR=${PROJECT_DIR}/${TARGET_DIR}) + + $(eval ARCHIVE_FILE=$(firstword $(wildcard ${DOWNLOADS_DIR}/${TARGET_PKGNAME}-*.tar.*))) + + $(eval TARGET_OS=$(word 1, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_ARCH=$(word 2, $(subst -, ,${TARGET_PATTERN}))) + + $(eval PKG_CONFIG_PATH=${PROJECT_DIR}/${INTERMEDIATE_DIR}/harfbuzz_${TARGET_OS}-${TARGET_ARCH}/lib/pkgconfig) + + rm -rf ${TARGET_TMP_DIR} ${TARGET_DIR} + mkdir -p ${TARGET_TMP_DIR} + + env -i \ + PATH=${SANDBOX_PATH} \ + ARCHIVE_FILE=${ARCHIVE_FILE} \ + TARGET_DIR=${TARGET_SRC_DIR} \ + sh ${PROJECT_DIR}/scripts/extract/build.sh + + env -i \ + PATH=${SANDBOX_PATH} \ + PROJECT_DIR=${PROJECT_DIR} \ + PKG_CONFIG_PATH=${PKG_CONFIG_PATH} \ + OS=${TARGET_OS} \ + ARCH=${TARGET_ARCH} \ + SRC_DIR=${TARGET_SRC_DIR} \ + OUTPUT_DIR=${TARGET_OUTPUT_DIR} \ + sh ${PROJECT_DIR}/scripts/${TARGET_PKGNAME}/build.sh + + rm -rf ${TARGET_TMP_DIR} + +# libass_- +${INTERMEDIATE_DIR}/libass_%: \ + ${DOWNLOADS_DIR} \ + ${PKGCONFIG_DIR} \ + ${INTERMEDIATE_DIR}/harfbuzz_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \ + ${INTERMEDIATE_DIR}/fribidi_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \ + ${INTERMEDIATE_DIR}/freetype_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) + + @echo "\033[32mRULE\033[0m $@" + + $(eval TARGET_DIR=$@) + $(eval TARGET_PATTERN=$*) + $(eval TARGET_NAME=$(notdir ${TARGET_DIR})) + $(eval TARGET_PKGNAME=$(firstword $(subst _${TARGET_PATTERN}, ,${TARGET_NAME}))) + $(eval TARGET_TMP_DIR=${TMP_DIR}/${TARGET_NAME}) + $(eval TARGET_SRC_DIR=${TARGET_TMP_DIR}/src/${TARGET_PKGNAME}) + $(eval TARGET_OUTPUT_DIR=${PROJECT_DIR}/${TARGET_DIR}) + + $(eval ARCHIVE_FILE=$(firstword $(wildcard ${DOWNLOADS_DIR}/${TARGET_PKGNAME}-*.tar.*))) + + $(eval TARGET_OS=$(word 1, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_ARCH=$(word 2, $(subst -, ,${TARGET_PATTERN}))) + + $(eval PKG_CONFIG_PATH=$(subst : ,:,\ + ${PROJECT_DIR}/${INTERMEDIATE_DIR}/harfbuzz_${TARGET_OS}-${TARGET_ARCH}/lib/pkgconfig:\ + ${PROJECT_DIR}/${INTERMEDIATE_DIR}/fribidi_${TARGET_OS}-${TARGET_ARCH}/lib/pkgconfig:\ + ${PROJECT_DIR}/${INTERMEDIATE_DIR}/freetype_${TARGET_OS}-${TARGET_ARCH}/lib/pkgconfig)) + + rm -rf ${TARGET_TMP_DIR} ${TARGET_DIR} + mkdir -p ${TARGET_TMP_DIR} + + env -i \ + PATH=${SANDBOX_PATH} \ + ARCHIVE_FILE=${ARCHIVE_FILE} \ + TARGET_DIR=${TARGET_SRC_DIR} \ + sh ${PROJECT_DIR}/scripts/extract/build.sh + + env -i \ + PATH=${SANDBOX_PATH} \ + PROJECT_DIR=${PROJECT_DIR} \ + PKG_CONFIG_PATH=${PKG_CONFIG_PATH} \ + OS=${TARGET_OS} \ + ARCH=${TARGET_ARCH} \ + SRC_DIR=${TARGET_SRC_DIR} \ + OUTPUT_DIR=${TARGET_OUTPUT_DIR} \ + sh ${PROJECT_DIR}/scripts/${TARGET_PKGNAME}/build.sh + + rm -rf ${TARGET_TMP_DIR} + +# uchardet_- +${INTERMEDIATE_DIR}/uchardet_%: \ + ${DOWNLOADS_DIR} \ + ${PKGCONFIG_DIR} + + @echo "\033[32mRULE\033[0m $@" + + $(eval TARGET_DIR=$@) + $(eval TARGET_PATTERN=$*) + $(eval TARGET_NAME=$(notdir ${TARGET_DIR})) + $(eval TARGET_PKGNAME=$(firstword $(subst _${TARGET_PATTERN}, ,${TARGET_NAME}))) + $(eval TARGET_TMP_DIR=${TMP_DIR}/${TARGET_NAME}) + $(eval TARGET_SRC_DIR=${TARGET_TMP_DIR}/src/${TARGET_PKGNAME}) + $(eval TARGET_OUTPUT_DIR=${PROJECT_DIR}/${TARGET_DIR}) + + $(eval ARCHIVE_FILE=$(firstword $(wildcard ${DOWNLOADS_DIR}/${TARGET_PKGNAME}-*.tar.*))) + + $(eval TARGET_OS=$(word 1, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_ARCH=$(word 2, $(subst -, ,${TARGET_PATTERN}))) + + rm -rf ${TARGET_TMP_DIR} ${TARGET_DIR} + mkdir -p ${TARGET_TMP_DIR} + + env -i \ + PATH=${SANDBOX_PATH} \ + ARCHIVE_FILE=${ARCHIVE_FILE} \ + TARGET_DIR=${TARGET_SRC_DIR}/subprojects/${TARGET_PKGNAME} \ + sh ${PROJECT_DIR}/scripts/extract/build.sh + + env -i \ + PATH=${SANDBOX_PATH} \ + PROJECT_DIR=${PROJECT_DIR} \ + PKG_CONFIG_PATH=${PKG_CONFIG_PATH} \ + OS=${TARGET_OS} \ + ARCH=${TARGET_ARCH} \ + SRC_DIR=${TARGET_SRC_DIR} \ + OUTPUT_DIR=${TARGET_OUTPUT_DIR} \ + sh ${PROJECT_DIR}/scripts/${TARGET_PKGNAME}/build.sh + + rm -rf ${TARGET_TMP_DIR} + +# mpv_-- +${INTERMEDIATE_DIR}/mpv_%: \ + ${DOWNLOADS_DIR} \ + ${PKGCONFIG_DIR} \ + ${INTERMEDIATE_DIR}/ffmpeg_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*))-$$(word 3,$$(subst -, ,$$*)) \ + $$(if $$(filter video, $$(word 3,$$(subst -, ,$$*))), \ + ${INTERMEDIATE_DIR}/uchardet_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \ + ${INTERMEDIATE_DIR}/libass_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \ + ${INTERMEDIATE_DIR}/harfbuzz_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \ + ${INTERMEDIATE_DIR}/fribidi_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \ + ${INTERMEDIATE_DIR}/freetype_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \ + ) + + @echo "\033[32mRULE\033[0m $@" + + $(eval TARGET_DIR=$@) + $(eval TARGET_PATTERN=$*) + $(eval TARGET_DEPS=$+) + $(eval TARGET_NAME=$(notdir ${TARGET_DIR})) + $(eval TARGET_PKGNAME=$(firstword $(subst _${TARGET_PATTERN}, ,${TARGET_NAME}))) + $(eval TARGET_TMP_DIR=${TMP_DIR}/${TARGET_NAME}) + $(eval TARGET_SRC_DIR=${TARGET_TMP_DIR}/src/${TARGET_PKGNAME}) + $(eval TARGET_OUTPUT_DIR=${PROJECT_DIR}/${TARGET_DIR}) + + $(eval ARCHIVE_FILE=$(firstword $(wildcard ${DOWNLOADS_DIR}/${TARGET_PKGNAME}-*.tar.*))) + + $(eval TARGET_OS=$(word 1, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_ARCH=$(word 2, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_VARIANT=$(word 3, $(subst -, ,${TARGET_PATTERN}))) + + $(eval TARGET_PKGS_DEPS=$(foreach DEP,${TARGET_DEPS}, \ + $(if $(findstring downloads,${DEP}),, \ + $(if $(findstring pkg-config,${DEP}),, \ + ${DEP})))) + $(eval PKG_CONFIG_PATH_LIST=$(foreach DEP,${TARGET_PKGS_DEPS},${PROJECT_DIR}/${DEP}/lib/pkgconfig)) + $(eval PKG_CONFIG_PATH=$(subst ${SPACE},${COLON},${PKG_CONFIG_PATH_LIST})) + + rm -rf ${TARGET_TMP_DIR} ${TARGET_DIR} + mkdir -p ${TARGET_TMP_DIR} + + env -i \ + PATH=${SANDBOX_PATH} \ + ARCHIVE_FILE=${ARCHIVE_FILE} \ + TARGET_DIR=${TARGET_SRC_DIR} \ + sh ${PROJECT_DIR}/scripts/extract/build.sh + + env -i \ + PATH=${SANDBOX_PATH} \ + PROJECT_DIR=${PROJECT_DIR} \ + PKG_CONFIG_PATH=${PKG_CONFIG_PATH} \ + OS=${TARGET_OS} \ + ARCH=${TARGET_ARCH} \ + VARIANT=${TARGET_VARIANT} \ + SRC_DIR=${TARGET_SRC_DIR} \ + OUTPUT_DIR=${TARGET_OUTPUT_DIR} \ + sh ${PROJECT_DIR}/scripts/${TARGET_PKGNAME}/build.sh + + rm -rf ${TARGET_TMP_DIR} + +# libs-arch_-- +${INTERMEDIATE_DIR}/libs-arch_%: \ + ${INTERMEDIATE_DIR}/mpv_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*))-$$(word 3,$$(subst -, ,$$*)) \ + ${INTERMEDIATE_DIR}/ffmpeg_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*))-$$(word 3,$$(subst -, ,$$*)) \ + ${INTERMEDIATE_DIR}/libressl_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \ + $$(if $$(filter video, $$(word 3,$$(subst -, ,$$*))), \ + ${INTERMEDIATE_DIR}/uchardet_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \ + ${INTERMEDIATE_DIR}/libass_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \ + ${INTERMEDIATE_DIR}/harfbuzz_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \ + ${INTERMEDIATE_DIR}/fribidi_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \ + ${INTERMEDIATE_DIR}/freetype_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \ + ) + + @echo "\033[32mRULE\033[0m $@" + + $(eval TARGET_DIR=$@) + $(eval TARGET_PATTERN=$*) + $(eval TARGET_DEPS=$+) + $(eval TARGET_NAME=$(notdir ${TARGET_DIR})) + $(eval TARGET_PKGNAME=$(firstword $(subst _${TARGET_PATTERN}, ,${TARGET_NAME}))) + $(eval TARGET_TMP_DIR=${TMP_DIR}/${TARGET_NAME}) + $(eval TARGET_SRC_DIR=${TARGET_TMP_DIR}/src/${TARGET_PKGNAME}) + $(eval TARGET_OUTPUT_DIR=${TARGET_TMP_DIR}/output) + + $(eval TARGET_OS=$(word 1, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_ARCH=$(word 2, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_VARIANT=$(word 3, $(subst -, ,${TARGET_PATTERN}))) + + $(eval TARGET_ABS_DEPS=$(foreach DEP,${TARGET_DEPS},${PROJECT_DIR}/${DEP})) + + rm -rf ${TARGET_TMP_DIR} ${TARGET_DIR} + mkdir -p ${TARGET_OUTPUT_DIR} + + env -i \ + PATH=${SANDBOX_PATH} \ + PROJECT_DIR=${PROJECT_DIR} \ + PKG_CONFIG_PATH=${PKG_CONFIG_PATH} \ + OS=${TARGET_OS} \ + ARCH=${TARGET_ARCH} \ + VARIANT=${TARGET_VARIANT} \ + DEPS="${TARGET_ABS_DEPS}" \ + OUTPUT_DIR=${TARGET_OUTPUT_DIR} \ + sh ${PROJECT_DIR}/scripts/${TARGET_PKGNAME}/build.sh + + mv ${TARGET_OUTPUT_DIR} ${TARGET_DIR} + rm -rf ${TARGET_TMP_DIR} + +# libs_-- +${INTERMEDIATE_DIR}/libs_%: \ + $$(if $$(filter universal, $$(word 2,$$(subst -, ,$$*))), \ + ${INTERMEDIATE_DIR}/libs-arch_$$(word 1,$$(subst -, ,$$*))-arm64-$$(word 3,$$(subst -, ,$$*)) \ + ${INTERMEDIATE_DIR}/libs-arch_$$(word 1,$$(subst -, ,$$*))-amd64-$$(word 3,$$(subst -, ,$$*)) \ + , \ + ${INTERMEDIATE_DIR}/libs-arch_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*))-$$(word 3,$$(subst -, ,$$*)) \ + ) + + @echo "\033[32mRULE\033[0m $@" + + $(eval TARGET_DIR=$@) + $(eval TARGET_PATTERN=$*) + $(eval TARGET_DEPS=$+) + $(eval TARGET_NAME=$(notdir ${TARGET_DIR})) + $(eval TARGET_PKGNAME=$(firstword $(subst _${TARGET_PATTERN}, ,${TARGET_NAME}))) + $(eval TARGET_TMP_DIR=${TMP_DIR}/${TARGET_NAME}) + $(eval TARGET_SRC_DIR=${TARGET_TMP_DIR}/src/${TARGET_PKGNAME}) + $(eval TARGET_OUTPUT_DIR=${TARGET_TMP_DIR}/output) + + $(eval TARGET_OS=$(word 1, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_ARCH=$(word 2, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_VARIANT=$(word 3, $(subst -, ,${TARGET_PATTERN}))) + + $(eval TARGET_ABS_DEPS=$(foreach DEP,${TARGET_DEPS},${PROJECT_DIR}/${DEP})) + + rm -rf ${TARGET_TMP_DIR} ${TARGET_DIR} + mkdir -p ${TARGET_OUTPUT_DIR} + + env -i \ + PATH=${SANDBOX_PATH} \ + PROJECT_DIR=${PROJECT_DIR} \ + PKG_CONFIG_PATH=${PKG_CONFIG_PATH} \ + OS=${TARGET_OS} \ + ARCH=${TARGET_ARCH} \ + VARIANT=${TARGET_VARIANT} \ + DEPS="${TARGET_ABS_DEPS}" \ + OUTPUT_DIR=${TARGET_OUTPUT_DIR} \ + sh ${PROJECT_DIR}/scripts/${TARGET_PKGNAME}/build.sh + + mv ${TARGET_OUTPUT_DIR} ${TARGET_DIR} + rm -rf ${TARGET_TMP_DIR} + +# frameworks_-- +${INTERMEDIATE_DIR}/frameworks_%: \ + ${INTERMEDIATE_DIR}/libs_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*))-$$(word 3,$$(subst -, ,$$*)) + + @echo "\033[32mRULE\033[0m $@" + + $(eval TARGET_DIR=$@) + $(eval TARGET_PATTERN=$*) + $(eval TARGET_DEPS=$+) + $(eval TARGET_NAME=$(notdir ${TARGET_DIR})) + $(eval TARGET_PKGNAME=$(firstword $(subst _${TARGET_PATTERN}, ,${TARGET_NAME}))) + $(eval TARGET_TMP_DIR=${TMP_DIR}/${TARGET_NAME}) + $(eval TARGET_SRC_DIR=${TARGET_TMP_DIR}/src/${TARGET_PKGNAME}) + $(eval TARGET_OUTPUT_DIR=${TARGET_TMP_DIR}/output) + + $(eval TARGET_OS=$(word 1, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_ARCH=$(word 2, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_VARIANT=$(word 3, $(subst -, ,${TARGET_PATTERN}))) + + $(eval TARGET_ABS_DEPS=$(foreach DEP,${TARGET_DEPS},${PROJECT_DIR}/${DEP})) + + rm -rf ${TARGET_TMP_DIR} ${TARGET_DIR} + mkdir -p ${TARGET_OUTPUT_DIR} + + env -i \ + PATH=${SANDBOX_PATH} \ + PROJECT_DIR=${PROJECT_DIR} \ + PKG_CONFIG_PATH=${PKG_CONFIG_PATH} \ + OS=${TARGET_OS} \ + ARCH=${TARGET_ARCH} \ + VARIANT=${TARGET_VARIANT} \ + DEPS="${TARGET_ABS_DEPS}" \ + OUTPUT_DIR=${TARGET_OUTPUT_DIR} \ + sh ${PROJECT_DIR}/scripts/${TARGET_PKGNAME}/build.sh + + mv ${TARGET_OUTPUT_DIR} ${TARGET_DIR} + rm -rf ${TARGET_TMP_DIR} + +# xcframeworks_-- +${INTERMEDIATE_DIR}/xcframeworks_%: \ + $$(if $$(filter ios, $$(word 1,$$(subst -, ,$$*))), \ + ${INTERMEDIATE_DIR}/frameworks_ios-arm64-$$(word 3,$$(subst -, ,$$*)) \ + ${INTERMEDIATE_DIR}/frameworks_iossimulator-$$(word 2,$$(subst -, ,$$*))-$$(word 3,$$(subst -, ,$$*)) \ + , \ + ${INTERMEDIATE_DIR}/frameworks_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*))-$$(word 3,$$(subst -, ,$$*)) \ + ) + + @echo "\033[32mRULE\033[0m $@" + + $(eval TARGET_DIR=$@) + $(eval TARGET_PATTERN=$*) + $(eval TARGET_DEPS=$+) + $(eval TARGET_NAME=$(notdir ${TARGET_DIR})) + $(eval TARGET_PKGNAME=$(firstword $(subst _${TARGET_PATTERN}, ,${TARGET_NAME}))) + $(eval TARGET_TMP_DIR=${TMP_DIR}/${TARGET_NAME}) + $(eval TARGET_SRC_DIR=${TARGET_TMP_DIR}/src/${TARGET_PKGNAME}) + $(eval TARGET_OUTPUT_DIR=${TARGET_TMP_DIR}/output) + + $(eval TARGET_OS=$(word 1, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_ARCH=$(word 2, $(subst -, ,${TARGET_PATTERN}))) + $(eval TARGET_VARIANT=$(word 3, $(subst -, ,${TARGET_PATTERN}))) + + $(eval TARGET_ABS_DEPS=$(foreach DEP,${TARGET_DEPS},${PROJECT_DIR}/${DEP})) + + rm -rf ${TARGET_TMP_DIR} ${TARGET_DIR} + mkdir -p ${TARGET_OUTPUT_DIR} + + env -i \ + PATH=${SANDBOX_PATH} \ + PROJECT_DIR=${PROJECT_DIR} \ + PKG_CONFIG_PATH=${PKG_CONFIG_PATH} \ + OS=${TARGET_OS} \ + ARCH=${TARGET_ARCH} \ + VARIANT=${TARGET_VARIANT} \ + DEPS="${TARGET_ABS_DEPS}" \ + OUTPUT_DIR=${TARGET_OUTPUT_DIR} \ + sh ${PROJECT_DIR}/scripts/${TARGET_PKGNAME}/build.sh + + mv ${TARGET_OUTPUT_DIR} ${TARGET_DIR} + rm -rf ${TARGET_TMP_DIR} + +# libmpv-__--.tar.gz +${OUTPUT_DIR}/libmpv-%.tar.gz: \ + ${INTERMEDIATE_DIR}/$$(word 1,$$(subst _, ,$$*))_$$(word 3,$$(subst _, ,$$*)) + + @echo "\033[32mRULE\033[0m $@" + + $(eval TARGET_FILE=$@) + $(eval TARGET_DEPS=$+) + $(eval TARGET_FILENAME=$(notdir ${TARGET_FILE})) + $(eval TARGET_NAME=$(basename $(basename ${TARGET_FILENAME}))) + $(eval TARGET_PKGNAME=archives) + $(eval TARGET_TMP_DIR=${TMP_DIR}/${TARGET_NAME}) + $(eval TARGET_SRC_DIR=${TARGET_TMP_DIR}) + $(eval TARGET_OUTPUT_FILE=${TARGET_TMP_DIR}/${TARGET_FILENAME}) + + $(eval TARGET_ABS_DEPS=$(foreach DEP,${TARGET_DEPS},${PROJECT_DIR}/${DEP})) + + rm -rf ${TARGET_TMP_DIR} ${TARGET_FILE} + mkdir -p ${OUTPUT_DIR} ${TARGET_SRC_DIR} + + env -i \ + PATH=${SANDBOX_PATH} \ + PROJECT_DIR=${PROJECT_DIR} \ + SRC_DIR=${TARGET_SRC_DIR} \ + DEPS="${TARGET_ABS_DEPS}" \ + OUTPUT_FILE=${TARGET_OUTPUT_FILE} \ + sh ${PROJECT_DIR}/scripts/${TARGET_PKGNAME}/build.sh + + mv ${TARGET_OUTPUT_FILE} ${TARGET_FILE} + rm -rf ${TARGET_TMP_DIR} diff --git a/README.md b/README.md index ccab42c..fdee40e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# libmpv Build +# libmpv build Provides builds of [libmpv](https://github.com/mpv-player/mpv) for macOS & iOS, -usable by [media_kit](https://github.com/alexmercerind/media_kit), compatible +used by [media_kit](https://github.com/alexmercerind/media_kit), compatible with commercial use. Heavily inspired by [Homebrew](https://github.com/Homebrew/brew) and @@ -10,15 +10,15 @@ Heavily inspired by [Homebrew](https://github.com/Homebrew/brew) and ## Usage ```shell -$ brew install cmake golang go-task meson ninja -$ VERSION=v0.0.1 task +$ brew install cmake golang meson ninja +$ VERSION=v0.0.1 make $ ls build/video/macos/universal/libs libass.9.dylib libavcodec.59.dylib libavfilter.8.dylib ... $ ls build/video/macos/universal/archives/libs -libmpv-libs-video-v0.0.1-macos-universal.tar.gz +libmpv-libs-video-default-v0.0.1-macos-universal.tar.gz ``` ## Dependencies @@ -66,7 +66,7 @@ E -.-> F - **[uchardet](https://www.freedesktop.org/wiki/Software/uchardet/) (optional)**: A C++ port of the Universal Character Encoding Detector (used by Mozilla Firefox and Thunderbird) for detecting the encoding of input text -## Commercial Use +## Commercial use | Dependency | Licence | Commercial use | | ---------- | ------------------------------------------------------ | :------------: | @@ -137,7 +137,22 @@ future: We use `meson` as much as possible in order to simplify cross-compilation, at the cost of some heaviness regarding legacy packages. -## Project Layout +## Naming convention + +``` +libmpv------.tar.gz +``` + +| Component | Notes | Value | +| --------- | ---------------------------- | ----------------------- | +| format | Output format of built files | libs, xcframeworks | +| variant | Usage context | audio, video | +| config | Number of available features | default, full | +| version | Semantic version | v0.0.1, … | +| os | Operating system | ios, macos | +| arch | Architecture | arm64, amd64, universal | + +## Project layout ``` . @@ -146,7 +161,7 @@ the cost of some heaviness regarding legacy packages. ├── pkg # golang packages ├── downloads # dependencies archives files ├── downloads.lock # lock file of dependencies archives -├── Taskfile.yaml # main build script +├── Makefile # main build script ├── scripts # build scripts ├── cross-files # cross build files used by meson ├── build @@ -172,6 +187,19 @@ the cost of some heaviness regarding legacy packages. └── ... ``` +TODO: + +``` +build + intermediate + foobar # pkgname / variant / arch … (eg: ffmpeg-audio-full-macos-arm64) + chroot + src + output + output + libmpv-*.tar.gz +``` + ## How the libass optional patch was created As the dependency of mpv on libass is deeply embedded in the code, the simplest @@ -183,14 +211,6 @@ solution was to: 4. Remove the calls to `ass_library_init`, called by `mp_ass_init`, in `sub/osd_libass.c` and `sub/sd_ass.c` -## TODO - -- [ ] **libressl**: mutualise the build between audio and video variants, - currently built twice -- [ ] **ffmpeg**: improve variant configuration scripts, like what is done for - **mpv** -- [ ] looking for a better build automation tool than Taskfile (if it exists) - ## Resources - https://github.com/stps/mpv-ios-scripts diff --git a/downloads/.gitignore b/downloads/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/downloads/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/pkg/tool-versions/tool-versions.go b/pkg/tool-versions/tool-versions.go index 5618135..4655e65 100644 --- a/pkg/tool-versions/tool-versions.go +++ b/pkg/tool-versions/tool-versions.go @@ -28,6 +28,7 @@ var toolVersionsCMDs = map[string]string{ "cmake": "cmake --version | head -n1 | cut -d ' ' -f 3", "golang": "go version | cut -d ' ' -f 3 | sed 's/go//g'", "macos": "sw_vers -productVersion", + "make": "make --version | head -n1 | cut -d ' ' -f 3", "meson": "meson --version", "ninja": "ninja --version", "task": "task --version | cut -d ' ' -f 3 | sed 's/v//g'", diff --git a/scripts/archives/build.sh b/scripts/archives/build.sh index d2bbc3a..c01a960 100644 --- a/scripts/archives/build.sh +++ b/scripts/archives/build.sh @@ -1,11 +1,11 @@ #!/bin/sh -rm -rf "${ARCHIVES_DIR}" -mkdir -p "${ARCHIVES_DIR}" +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error -NAME=libmpv-${TYPE}-${VARIANT}-${VERSION}-${OS}-${ARCH} +cd ${SRC_DIR} -cp -R "${FILES_DIR}" "${ARCHIVES_DIR}"/$NAME +NAME=$(basename ${OUTPUT_FILE} .tar.gz) -cd "${ARCHIVES_DIR}" -tar -czvf $NAME.tar.gz $NAME +cp -R ${DEPS} ${NAME} +tar -czvf ${NAME}.tar.gz ${NAME} diff --git a/scripts/extract/build.sh b/scripts/extract/build.sh index a16eea4..3223b69 100644 --- a/scripts/extract/build.sh +++ b/scripts/extract/build.sh @@ -1,10 +1,10 @@ #!/bin/sh +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + mkdir -p ${TARGET_DIR} -find downloads -type f -name "${PKG_NAME}-*.tar.*" -exec \ - tar \ - -xvf {} \ +tar \ + -xvf ${ARCHIVE_FILE} \ --strip-components 1 \ - -C ${TARGET_DIR} \ - \ - \; 2>&1 + -C ${TARGET_DIR} diff --git a/scripts/ffmpeg/build.sh b/scripts/ffmpeg/build.sh index 0f5d71a..8bbba1d 100644 --- a/scripts/ffmpeg/build.sh +++ b/scripts/ffmpeg/build.sh @@ -1,6 +1,9 @@ #!/bin/sh -cd ${SOURCES_DIR}/ffmpeg +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + +cd ${SRC_DIR} patch -p1 <${PROJECT_DIR}/patches/ffmpeg-fix-ios-hdr-texture.patch @@ -12,10 +15,10 @@ fi meson setup build \ --cross-file ${PROJECT_DIR}/cross-files/${OS}-${ARCH}.ini \ - --prefix="${PREFIX}" + --prefix="${OUTPUT_DIR}" meson compile -C build ffmpeg # manual install to preserve symlinks (meson install -C build) -mkdir -p "${PREFIX}" -cp -R build/dist"${PREFIX}"/* "${PREFIX}"/ +mkdir -p "${OUTPUT_DIR}" +cp -R build/dist"${OUTPUT_DIR}"/* "${OUTPUT_DIR}"/ diff --git a/scripts/frameworks/build.sh b/scripts/frameworks/build.sh index 1beb95f..284c6dd 100644 --- a/scripts/frameworks/build.sh +++ b/scripts/frameworks/build.sh @@ -1,11 +1,10 @@ #!/bin/sh +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + if [ "${OS}" == "macos" ]; then - sh "${PROJECT_DIR}/scripts/frameworks/macos/create_frameworks.sh" \ - "${LIBS_DIR}" \ - "${FRAMEWORKS_DIR}" + sh ${PROJECT_DIR}/scripts/frameworks/macos/create_frameworks.sh elif [ "${OS}" == "ios" ] || [ "${OS}" == "iossimulator" ]; then - sh "${PROJECT_DIR}/scripts/frameworks/ios/create_frameworks.sh" \ - "${LIBS_DIR}" \ - "${FRAMEWORKS_DIR}" + sh ${PROJECT_DIR}/scripts/frameworks/ios/create_frameworks.sh fi diff --git a/scripts/frameworks/ios/create_frameworks.sh b/scripts/frameworks/ios/create_frameworks.sh index be536ad..e709a13 100755 --- a/scripts/frameworks/ios/create_frameworks.sh +++ b/scripts/frameworks/ios/create_frameworks.sh @@ -1,11 +1,11 @@ #!/bin/bash -# see: MobileVLCKit cocoapods +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error -LIBS_DIR="$1" -FRAMEWORKS_DIR="$2" +# see: MobileVLCKit cocoapods -find "${LIBS_DIR}" -name "*.dylib" -type f | while read DYLIB; do +find ${DEPS} -name "*.dylib" -type f | while read DYLIB; do echo "${DYLIB}" # create framework name: libavcodec.59.dylib -> Avcodec @@ -13,7 +13,7 @@ find "${LIBS_DIR}" -name "*.dylib" -type f | while read DYLIB; do FRAMEWORK_NAME="$(tr '[:lower:]' '[:upper:]' <<<${FRAMEWORK_NAME:0:1})${FRAMEWORK_NAME:1}" # framework dir - FRAMEWORK_DIR="${FRAMEWORKS_DIR}/${FRAMEWORK_NAME}.framework" + FRAMEWORK_DIR="${OUTPUT_DIR}/${FRAMEWORK_NAME}.framework" # determine archs ARCHS=$(lipo -archs "${DYLIB}") @@ -33,6 +33,7 @@ find "${LIBS_DIR}" -name "*.dylib" -type f | while read DYLIB; do fi # if $MIN_OS_VERSION is null or greater than $ARCH_MIN_OS_VERSION replace it + MIN_OS_VERSION= if [ -z "${MIN_OS_VERSION}" ] || (($(bc -l <<<"${MIN_OS_VERSION} > ${ARCH_MIN_OS_VERSION}"))); then MIN_OS_VERSION=${ARCH_MIN_OS_VERSION} fi diff --git a/scripts/frameworks/macos/create_frameworks.sh b/scripts/frameworks/macos/create_frameworks.sh index 911e470..a323f13 100755 --- a/scripts/frameworks/macos/create_frameworks.sh +++ b/scripts/frameworks/macos/create_frameworks.sh @@ -1,12 +1,12 @@ #!/bin/bash +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + # see: VLCKit cocoapods # see: https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html -LIBS_DIR="$1" -FRAMEWORKS_DIR="$2" - -find "${LIBS_DIR}" -name "*.dylib" -type f | while read DYLIB; do +find ${DEPS} -name "*.dylib" -type f | while read DYLIB; do echo "${DYLIB}" # create framework name: libavcodec.59.dylib -> Avcodec @@ -14,7 +14,7 @@ find "${LIBS_DIR}" -name "*.dylib" -type f | while read DYLIB; do FRAMEWORK_NAME="$(tr '[:lower:]' '[:upper:]' <<<${FRAMEWORK_NAME:0:1})${FRAMEWORK_NAME:1}" # framework dir - FRAMEWORK_DIR="${FRAMEWORKS_DIR}/${FRAMEWORK_NAME}.framework" + FRAMEWORK_DIR="${OUTPUT_DIR}/${FRAMEWORK_NAME}.framework" # determine archs ARCHS=$(lipo -archs "${DYLIB}") @@ -34,6 +34,7 @@ find "${LIBS_DIR}" -name "*.dylib" -type f | while read DYLIB; do fi # if $MIN_OS_VERSION is null or greater than $ARCH_MIN_OS_VERSION replace it + MIN_OS_VERSION= if [ -z "${MIN_OS_VERSION}" ] || (($(bc -l <<<"${MIN_OS_VERSION} > ${ARCH_MIN_OS_VERSION}"))); then MIN_OS_VERSION=${ARCH_MIN_OS_VERSION} fi diff --git a/scripts/freetype/build.sh b/scripts/freetype/build.sh index 6d29032..dcd4d53 100644 --- a/scripts/freetype/build.sh +++ b/scripts/freetype/build.sh @@ -1,9 +1,12 @@ #!/bin/sh -cd ${SOURCES_DIR}/freetype +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + +cd ${SRC_DIR} meson setup build \ --cross-file ${PROJECT_DIR}/cross-files/${OS}-${ARCH}.ini \ - --prefix="${PREFIX}" \ + --prefix="${OUTPUT_DIR}" \ -Dbrotli=disabled \ -Dbzip2=disabled \ -Dharfbuzz=enabled \ diff --git a/scripts/fribidi/build.sh b/scripts/fribidi/build.sh index 8558ca5..1dae4c4 100644 --- a/scripts/fribidi/build.sh +++ b/scripts/fribidi/build.sh @@ -1,9 +1,12 @@ #!/bin/sh -cd ${SOURCES_DIR}/fribidi +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + +cd ${SRC_DIR} meson setup build \ --cross-file ${PROJECT_DIR}/cross-files/${OS}-${ARCH}.ini \ - --prefix="${PREFIX}" \ + --prefix="${OUTPUT_DIR}" \ -Ddeprecated=false \ -Ddocs=false \ -Dbin=false \ diff --git a/scripts/harfbuzz/build.sh b/scripts/harfbuzz/build.sh index 6ef0b9c..0898230 100644 --- a/scripts/harfbuzz/build.sh +++ b/scripts/harfbuzz/build.sh @@ -1,9 +1,12 @@ #!/bin/sh -cd ${SOURCES_DIR}/harfbuzz +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + +cd ${SRC_DIR} meson setup build \ --cross-file ${PROJECT_DIR}/cross-files/${OS}-${ARCH}.ini \ - --prefix="${PREFIX}" \ + --prefix="${OUTPUT_DIR}" \ -Dglib=disabled \ -Dgobject=disabled \ -Dcairo=disabled \ diff --git a/scripts/libass/build.sh b/scripts/libass/build.sh index e3b99a3..b19120d 100644 --- a/scripts/libass/build.sh +++ b/scripts/libass/build.sh @@ -1,14 +1,17 @@ #!/bin/sh -cd ${SOURCES_DIR}/libass +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + +cd ${SRC_DIR} cp ${PROJECT_DIR}/scripts/libass/meson.build ./meson.build meson setup build \ --cross-file ${PROJECT_DIR}/cross-files/${OS}-${ARCH}.ini \ - --prefix="${PREFIX}" + --prefix="${OUTPUT_DIR}" meson compile -C build libass # manual install to preserve symlinks (meson install -C build) -mkdir -p "${PREFIX}" -cp -R build/dist"${PREFIX}"/* "${PREFIX}"/ +mkdir -p "${OUTPUT_DIR}" +cp -R build/dist"${OUTPUT_DIR}"/* "${OUTPUT_DIR}"/ diff --git a/scripts/libressl/build.sh b/scripts/libressl/build.sh index fcf6034..0e6341c 100644 --- a/scripts/libressl/build.sh +++ b/scripts/libressl/build.sh @@ -1,17 +1,20 @@ #!/bin/sh -cd ${SOURCES_DIR}/libressl +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + +cd ${SRC_DIR} cp ${PROJECT_DIR}/scripts/libressl/meson.build ./meson.build meson setup build \ --cross-file ${PROJECT_DIR}/cross-files/${OS}-${ARCH}.ini \ - --prefix="${PREFIX}" + --prefix="${OUTPUT_DIR}" meson compile -C build libressl # fix file permissions -chmod 755 build/dist"${PREFIX}"/lib/* +chmod 755 build/dist"${OUTPUT_DIR}"/lib/* # manual install to preserve symlinks (meson install -C build) -mkdir -p "${PREFIX}" -cp -R build/dist"${PREFIX}"/* "${PREFIX}"/ +mkdir -p "${OUTPUT_DIR}" +cp -R build/dist"${OUTPUT_DIR}"/* "${OUTPUT_DIR}"/ diff --git a/scripts/libs-arch/build.sh b/scripts/libs-arch/build.sh new file mode 100644 index 0000000..e734c8c --- /dev/null +++ b/scripts/libs-arch/build.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + +# copy dylibs except '*-subset.*.dylib' +for DEP in ${DEPS}; do + find ${DEP}/lib \ + -type f -name '*.dylib' \ + ! -name '*-subset.*.dylib' \ + -exec \ + cp "{}" "${OUTPUT_DIR}" \ + \; +done + +# libfoo.100.99.88.dylib -> libfoo.100.dylib +find ${OUTPUT_DIR} -type f -name '*.dylib' -exec \ + sh -c 'mv "{}" $(echo "{}" | sed -r "s|([0-9]+)(\.[0-9]+)*|\1|g")' \ + \; + +# rename libmpv file +mv ${OUTPUT_DIR}/libmpv.*.dylib ${OUTPUT_DIR}/libmpv.dylib +install_name_tool -id @rpath/libmpv.dylib ${OUTPUT_DIR}/libmpv.dylib + +# fix deps paths +${PROJECT_DIR}/scripts/libs-arch/relink_dylibs.sh ${PROJECT_DIR} @rpath ${OUTPUT_DIR} + +# remove signatures +codesign --remove ${OUTPUT_DIR}/*.dylib + +if [ "${OS}" == "iossimulator" ] && [ "${ARCH}" == "arm64" ]; then + sh ${PROJECT_DIR}/scripts/libs-arch/ios/fix_iossimulator_arm64.sh ${OUTPUT_DIR} +fi diff --git a/scripts/libs/ios/fix_iossimulator_arm64.sh b/scripts/libs-arch/ios/fix_iossimulator_arm64.sh similarity index 86% rename from scripts/libs/ios/fix_iossimulator_arm64.sh rename to scripts/libs-arch/ios/fix_iossimulator_arm64.sh index dea2c5a..4217219 100644 --- a/scripts/libs/ios/fix_iossimulator_arm64.sh +++ b/scripts/libs-arch/ios/fix_iossimulator_arm64.sh @@ -1,5 +1,8 @@ #!/bin/sh +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + # The Apple sdk for the arm64 simulator produces dylib whose platform in the # headers is `IOS` and not `IOSSIMULATOR`. This is wrong. # So, this script replaces the platform header with `IOSSIMULATOR`. diff --git a/scripts/libs/relink_dylibs.sh b/scripts/libs-arch/relink_dylibs.sh similarity index 89% rename from scripts/libs/relink_dylibs.sh rename to scripts/libs-arch/relink_dylibs.sh index ab3fcc4..899554f 100755 --- a/scripts/libs/relink_dylibs.sh +++ b/scripts/libs-arch/relink_dylibs.sh @@ -1,5 +1,7 @@ #!/bin/sh -set -e + +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error # relink_dylibs updates the dependency paths of dynamic libraries by replacing a # source prefix with a target prefix @@ -40,7 +42,7 @@ relink_dylibs() { } SOURCE_PREFIX=$1 -TARGET_PREFIX="@rpath" -DIR=$2 +TARGET_PREFIX=$2 +DIR=$3 relink_dylibs "$SOURCE_PREFIX" "$TARGET_PREFIX" "$DIR" diff --git a/scripts/libs/build-arch.sh b/scripts/libs/build-arch.sh new file mode 100644 index 0000000..0f673be --- /dev/null +++ b/scripts/libs/build-arch.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + +# copy dylibs +for DEP in ${DEPS}; do + find ${DEP} \ + -type f -name '*.dylib' \ + -exec \ + cp "{}" "${OUTPUT_DIR}" \ + \; +done diff --git a/scripts/libs/build-universal.sh b/scripts/libs/build-universal.sh index 2c618bd..d26d3b9 100644 --- a/scripts/libs/build-universal.sh +++ b/scripts/libs/build-universal.sh @@ -1,12 +1,33 @@ #!/bin/sh -mkdir -p "${LIBS_UNIVERSAL_DIR}" +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error -find "${LIBS_ARCH1_DIR}" -name "*.dylib" -type f | while read DYLIB_ARCH1; do - DYLIB_ARCH2=$(echo "${DYLIB_ARCH1}" | sed -r "s|${ARCH1}|${ARCH2}|g") - DYLIB_UNIVERSAL=$(echo "${DYLIB_ARCH1}" | sed -r "s|${ARCH1}|universal|g") +get_element() { + str="$1" + n="$2" + + i=1 + for word in $str; do + if [ "$i" -eq "$n" ]; then + echo "$word" + return + fi + i=$((i + 1)) + done +} + +DEP=$(get_element "$DEPS" 1) + +find ${DEP} -name '*.dylib' -type f | while read DYLIB_ARCH; do + DYLIB_ARCH1=$(echo ${DYLIB_ARCH} | sed -r "s|amd64|arm64|g") + DYLIB_ARCH2=$(echo ${DYLIB_ARCH} | sed -r "s|arm64|amd64|g") + DYLIB_NAME=$(basename ${DYLIB_ARCH1}) + DYLIB_OUTPUT=${OUTPUT_DIR}/${DYLIB_NAME} + + echo ${DYLIB_OUTPUT} lipo \ -create "${DYLIB_ARCH1}" "${DYLIB_ARCH2}" \ - -output "${DYLIB_UNIVERSAL}" + -output "${DYLIB_OUTPUT}" done diff --git a/scripts/libs/build.sh b/scripts/libs/build.sh index fdc067c..00e2d64 100644 --- a/scripts/libs/build.sh +++ b/scripts/libs/build.sh @@ -1,28 +1,10 @@ #!/bin/sh -rm -rf "${LIBS_DIR}" -mkdir -p "${LIBS_DIR}" +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error -# copy dylibs except '*-subset.*.dylib' -find "${PREFIX}/lib" \ - -type f -name '*.dylib' \ - ! -name '*-subset.*.dylib' \ - -exec \ - cp "{}" "${LIBS_DIR}" \ - \; - -# libfoo.100.99.88.dylib -> libfoo.100.dylib -find ${LIBS_DIR} -type f -name '*.dylib' -exec \ - sh -c 'mv "{}" $(echo "{}" | sed -r "s|([0-9]+)(\.[0-9]+)*|\1|g")' \ - \; - -mv "${LIBS_DIR}"/libmpv.*.dylib "${LIBS_DIR}/libmpv.dylib" -install_name_tool -id @rpath/libmpv.dylib "${LIBS_DIR}/libmpv.dylib" - -./scripts/libs/relink_dylibs.sh "${PREFIX}/lib" "${LIBS_DIR}" - -codesign --remove "${LIBS_DIR}"/*.dylib - -if [ "${OS}" == "iossimulator" ] && [ "${ARCH}" == "arm64" ]; then - sh "${PROJECT_DIR}/scripts/libs/ios/fix_iossimulator_arm64.sh" "${LIBS_DIR}" +if [ "${ARCH}" == "universal" ]; then + sh ${PROJECT_DIR}/scripts/libs/build-universal.sh +else + sh ${PROJECT_DIR}/scripts/libs/build-arch.sh fi diff --git a/scripts/links/build.sh b/scripts/links/build.sh index e81eb10..de52246 100644 --- a/scripts/links/build.sh +++ b/scripts/links/build.sh @@ -1,6 +1,9 @@ #!/bin/sh -mkdir -p ${TOOLS_PREFIX}/bin +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + +mkdir -p ${OUTPUT_DIR}/bin # check BINARY presence in PATH for BINARY in ${BINARIES}; do @@ -11,7 +14,7 @@ done # sym link BINARY for BINARY in ${BINARIES}; do - [ ! -h ${TOOLS_PREFIX}/bin/$BINARY ] && - ln -s $(which $BINARY) ${TOOLS_PREFIX}/bin/$BINARY || + [ ! -h ${OUTPUT_DIR}/bin/$BINARY ] && + ln -s $(which $BINARY) ${OUTPUT_DIR}/bin/$BINARY || true done diff --git a/scripts/links/status.sh b/scripts/links/status.sh deleted file mode 100644 index 641d830..0000000 --- a/scripts/links/status.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -# check BINARY presence in \$TOOLS_PREFIX/bin -for BINARY in ${BINARIES}; do - test -f ${TOOLS_PREFIX}/bin/$BINARY -done diff --git a/scripts/mpv/build.sh b/scripts/mpv/build.sh index abfa332..bc6b4a4 100644 --- a/scripts/mpv/build.sh +++ b/scripts/mpv/build.sh @@ -1,6 +1,9 @@ #!/bin/bash -cd ${SOURCES_DIR}/mpv +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + +cd ${SRC_DIR} if [ "${VARIANT}" == "audio" ]; then patch -p1 <${PROJECT_DIR}/patches/mpv-remove-libass.patch @@ -73,7 +76,7 @@ fi meson setup build \ --cross-file ${PROJECT_DIR}/cross-files/${OS}-${ARCH}.ini \ - --prefix="${PREFIX}" \ + --prefix="${OUTPUT_DIR}" \ `# booleans` \ -Dgpl=false `# GPL (version 2 or later) build` \ -Dcplayer=false `# mpv CLI player` \ diff --git a/scripts/pkg-config/build.sh b/scripts/pkg-config/build.sh index 0079900..d63f487 100644 --- a/scripts/pkg-config/build.sh +++ b/scripts/pkg-config/build.sh @@ -1,14 +1,17 @@ #!/bin/sh -cd ${TOOLS_SOURCES_DIR}/pkg-config +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + +cd ${SRC_DIR} cp ${PROJECT_DIR}/scripts/pkg-config/meson.build ./meson.build meson setup build \ --cross-file ${PROJECT_DIR}/cross-files/${OS}-${ARCH}.ini \ - --prefix="${TOOLS_PREFIX}" + --prefix="${OUTPUT_DIR}" meson compile -C build pkg-config # manual install to preserve symlinks (meson install -C build) -mkdir -p "${TOOLS_PREFIX}" -cp -R build/dist"${TOOLS_PREFIX}"/* "${TOOLS_PREFIX}"/ +mkdir -p "${OUTPUT_DIR}" +cp -R build/dist"${OUTPUT_DIR}"/* "${OUTPUT_DIR}"/ diff --git a/scripts/uchardet/build.sh b/scripts/uchardet/build.sh index 346c3a8..5dd0087 100644 --- a/scripts/uchardet/build.sh +++ b/scripts/uchardet/build.sh @@ -1,29 +1,32 @@ #!/bin/sh -cd ${SOURCES_DIR}/uchardet +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + +cd ${SRC_DIR} # cross build with meson cp ${PROJECT_DIR}/scripts/uchardet/meson.build ./meson.build meson setup build_cross \ --cross-file ${PROJECT_DIR}/cross-files/${OS}-${ARCH}.ini \ - --prefix="${PREFIX}" + --prefix="${OUTPUT_DIR}" meson compile -C build_cross uchardet # native build with cmake cmake ./subprojects/uchardet \ -B build_native \ - -DCMAKE_INSTALL_PREFIX="${PREFIX}" \ + -DCMAKE_INSTALL_PREFIX="${OUTPUT_DIR}" \ -DBUILD_STATIC=OFF make -C build_native DESTDIR=$PWD/dist make -C build_native install # remove unecessary files -rm -rf "dist/${PREFIX}/bin" -rm -rf "dist/${PREFIX}/lib/cmake" -rm -rf "dist/${PREFIX}/share" +rm -rf "dist/${OUTPUT_DIR}/bin" +rm -rf "dist/${OUTPUT_DIR}/lib/cmake" +rm -rf "dist/${OUTPUT_DIR}/share" # get dylib id -DYLIB_FILE=$(find "dist${PREFIX}/lib" -type f -name '*.dylib') +DYLIB_FILE=$(find "dist${OUTPUT_DIR}/lib" -type f -name '*.dylib') DYLIB_ID=$(otool -l "$DYLIB_FILE" | grep ' name ' | cut -d ' ' -f 11 | head -n +1) # replace native dylib by cross dylib & update id @@ -31,5 +34,5 @@ cp 'build_cross/subprojects/uchardet/liblibuchardet.dylib' "$DYLIB_FILE" install_name_tool -id "$DYLIB_ID" "$DYLIB_FILE" # manual install to preserve symlinks -mkdir -p "${PREFIX}" -cp -R dist"${PREFIX}"/* "${PREFIX}"/ +mkdir -p "${OUTPUT_DIR}" +cp -R dist"${OUTPUT_DIR}"/* "${OUTPUT_DIR}"/ diff --git a/scripts/xcframeworks/build-generic.sh b/scripts/xcframeworks/build-generic.sh new file mode 100755 index 0000000..e590f44 --- /dev/null +++ b/scripts/xcframeworks/build-generic.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + +find ${DEPS} -name '*.framework' -type d | while read FRAMEWORK; do + FRAMEWORK_NAME=$(basename $FRAMEWORK .framework) + + echo ${FRAMEWORK_NAME} + + xcodebuild -create-xcframework \ + -framework ${FRAMEWORK} \ + -output ${OUTPUT_DIR}/${FRAMEWORK_NAME}.xcframework +done diff --git a/scripts/xcframeworks/build-ios.sh b/scripts/xcframeworks/build-ios.sh new file mode 100755 index 0000000..82075b1 --- /dev/null +++ b/scripts/xcframeworks/build-ios.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + +get_element() { + str="$1" + n="$2" + + i=1 + for word in $str; do + if [ "$i" -eq "$n" ]; then + echo "$word" + return + fi + i=$((i + 1)) + done +} + +DEP1=$(get_element "$DEPS" 1) +DEP2=$(get_element "$DEPS" 2) + +find ${DEP1} -name "*.framework" -type d | while read FRAMEWORK; do + FRAMEWORK_NAME=$(basename "$FRAMEWORK" .framework) + FRAMEWORK_OS1=${DEP1}/${FRAMEWORK_NAME}.framework + FRAMEWORK_OS2=${DEP2}/${FRAMEWORK_NAME}.framework + FRAMEWORK_OUTPUT=${OUTPUT_DIR}/${FRAMEWORK_NAME}.xcframework + + echo ${FRAMEWORK_NAME} + + xcodebuild -create-xcframework \ + -framework ${FRAMEWORK_OS1} \ + -framework ${FRAMEWORK_OS2} \ + -output ${FRAMEWORK_OUTPUT} +done diff --git a/scripts/xcframeworks/build.sh b/scripts/xcframeworks/build.sh new file mode 100644 index 0000000..c746475 --- /dev/null +++ b/scripts/xcframeworks/build.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e # exit immediately if a command exits with a non-zero status +set -u # treat unset variables as an error + +if [ "${OS}" == "ios" ]; then + sh ${PROJECT_DIR}/scripts/xcframeworks/build-ios.sh +else + sh ${PROJECT_DIR}/scripts/xcframeworks/build-generic.sh +fi diff --git a/scripts/xcframeworks/ios/create_xcframeworks.sh b/scripts/xcframeworks/ios/create_xcframeworks.sh deleted file mode 100755 index 4d8e3f9..0000000 --- a/scripts/xcframeworks/ios/create_xcframeworks.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -find "${FRAMEWORKS_IOS_DIR}" -name "*.framework" -type d | while read FRAMEWORK_IOS; do - FRAMEWORK_IOSSIMULATOR=$(echo "${FRAMEWORK_IOS}" | sed 's/ios/iossimulator'/g | sed 's/arm64/universal'/g) - FRAMEWORK_NAME=$(basename "$FRAMEWORK_IOS" .framework) - - echo "${FRAMEWORK_NAME}" - - xcodebuild -create-xcframework \ - -framework "${FRAMEWORK_IOS}" \ - -framework "${FRAMEWORK_IOSSIMULATOR}" \ - -output "${XCFRAMEWORKS_DIR}/${FRAMEWORK_NAME}.xcframework" -done diff --git a/scripts/xcframeworks/macos/create_xcframeworks.sh b/scripts/xcframeworks/macos/create_xcframeworks.sh deleted file mode 100755 index 5e0ce3c..0000000 --- a/scripts/xcframeworks/macos/create_xcframeworks.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -find "${FRAMEWORKS_MACOS_DIR}" -name "*.framework" -type d | while read FRAMEWORK_MACOS; do - FRAMEWORK_NAME=$(basename "$FRAMEWORK_MACOS" .framework) - - echo "${FRAMEWORK_NAME}" - - xcodebuild -create-xcframework \ - -framework "${FRAMEWORK_MACOS}" \ - -output "${XCFRAMEWORKS_DIR}/${FRAMEWORK_NAME}.xcframework" -done