Skip to content

Commit

Permalink
Merge pull request media-kit#324 from birros/feat/darwin-default-libs
Browse files Browse the repository at this point in the history
feat: use darwin default libs
  • Loading branch information
alexmercerind authored Aug 6, 2023
2 parents 111d9e8 + c0c52d4 commit 9bac9dd
Show file tree
Hide file tree
Showing 21 changed files with 366 additions and 28 deletions.
5 changes: 5 additions & 0 deletions libs/ios/media_kit_libs_ios_audio/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.1.0

- build: bump libs to default flavor
- build: add symlinks to `Mpv.framework`

## 1.0.5

- build: bump min iOS version to 9.0
Expand Down
13 changes: 9 additions & 4 deletions libs/ios/media_kit_libs_ios_audio/ios/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
all: Frameworks/*.xcframework
all: Frameworks/*.xcframework Frameworks/.symlinks

MPV_XCFRAMEWORKS_VERSION=v0.4.2
MPV_XCFRAMEWORKS_SHA256SUM=e57471a3a59177b13fd14df6e01419a9682b53c5732b8a109c938ebc650f0326
MPV_XCFRAMEWORKS_VERSION=v0.5.1
MPV_XCFRAMEWORKS_SHA256SUM=3160b4e747f928c90fc9efd3208225a2bbebe2afe21d460165eb2f29fb0596f7

.cache/xcframeworks/libmpv-xcframeworks-${MPV_XCFRAMEWORKS_VERSION}-ios-universal.tar.gz:
mkdir -p .cache/xcframeworks
rm -f .cache/xcframeworks/*.tmp .cache/xcframeworks/*-ios-universal.tar.gz
curl -L \
https://github.com/media-kit/libmpv-darwin-build/releases/download/${MPV_XCFRAMEWORKS_VERSION}/libmpv-xcframeworks-audio-${MPV_XCFRAMEWORKS_VERSION}-ios-universal.tar.gz \
https://github.com/media-kit/libmpv-darwin-build/releases/download/${MPV_XCFRAMEWORKS_VERSION}/libmpv-xcframeworks_${MPV_XCFRAMEWORKS_VERSION}_ios-universal-audio-default.tar.gz \
-o .cache/xcframeworks/libmpv.tar.gz.tmp
shasum -a 256 -c <<< '${MPV_XCFRAMEWORKS_SHA256SUM} .cache/xcframeworks/libmpv.tar.gz.tmp'
mv .cache/xcframeworks/libmpv.tar.gz.tmp .cache/xcframeworks/libmpv-xcframeworks-${MPV_XCFRAMEWORKS_VERSION}-ios-universal.tar.gz
Expand All @@ -23,6 +23,11 @@ Frameworks/*.xcframework: .cache/xcframeworks/libmpv-xcframeworks-ios-universal.
tar -xvf .cache/xcframeworks/libmpv-xcframeworks-ios-universal.tar.gz --strip-components 1 -C Frameworks
touch Frameworks/*.xcframework

Frameworks/.symlinks: Frameworks/*.xcframework
rm -rf Frameworks/.symlinks
mkdir -p Frameworks/.symlinks/mpv
sh create_framework_symlinks.sh Frameworks/Mpv.xcframework Frameworks/.symlinks/mpv

.PHONY: clean
clean:
rm -rf .cache
Expand Down
72 changes: 72 additions & 0 deletions libs/ios/media_kit_libs_ios_audio/ios/create_framework_symlinks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/sh

# `create_framework_symlinks.sh` is duplicated across:
# - `media_kit_libs_ios_audio`
# - `media_kit_libs_ios_video`
# - `media_kit_libs_macos_audio`
# - `media_kit_libs_macos_video`

set -e
set -u

SRC_DIR="$1"
SYMLINKS_DIR="$2"

# Computes the relative path between two given paths
#
# Example:
# ```
# relpath Frameworks/Mpv.xcframework/ios-arm64 Frameworks/.symlinks/mpv
# ../../Mpv.xcframework/ios-arm64
# ```
#
# Source: https://stackoverflow.com/a/14914070
relpath() {
[ $# -ge 1 ] && [ $# -le 2 ] || return 1
current="${2:+"$1"}"
target="${2:-"$1"}"
[ "$target" != . ] || target=/
target="/${target##/}"
[ "$current" != . ] || current=/
current="${current:="/"}"
current="/${current##/}"
appendix="${target##/}"
relative=''
while appendix="${target#"$current"/}"
[ "$current" != '/' ] && [ "$appendix" = "$target" ]; do
if [ "$current" = "$appendix" ]; then
relative="${relative:-.}"
echo "${relative#/}"
return 0
fi
current="${current%/*}"
relative="$relative${relative:+/}.."
done
relative="$relative${relative:+${appendix:+/}}${appendix#/}"
echo "$relative"
}

# Create symbolic links from a given source directory to a destination directory
# for a specific framework
#
# Example:
# ```
# create_framework_symlinks Frameworks/Mpv.xcframework Frameworks/.symlinks/mpv
# Frameworks/.symlinks/mpv/ios -> ../../Mpv.xcframework/ios-arm64
# Frameworks/.symlinks/mpv/ios-simulator -> ../../Mpv.xcframework/ios-arm64_x86_64-simulator
# ```
create_framework_symlinks() {
SRC_DIR="$1"
SYMLINKS_DIR="$2"

find "${SRC_DIR}" -depth 1 -type d | while read SRC; do
SLUG="$(basename "${SRC}")"
NAME="$(echo "${SLUG}" | cut -d '-' -f 1 -f 3)"

SRC_RELATIVE="$(relpath "${SYMLINKS_DIR}" "${SRC}")"

ln -s "${SRC_RELATIVE}" "${SYMLINKS_DIR}/${NAME}"
done
}

create_framework_symlinks "${SRC_DIR}" "${SYMLINKS_DIR}"
5 changes: 5 additions & 0 deletions libs/ios/media_kit_libs_ios_video/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.1.0

- build: bump libs to default flavor
- build: add symlinks to `Mpv.framework`

## 1.0.5

- build: bump min iOS version to 9.0
Expand Down
13 changes: 9 additions & 4 deletions libs/ios/media_kit_libs_ios_video/ios/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
all: Frameworks/*.xcframework
all: Frameworks/*.xcframework Frameworks/.symlinks

MPV_XCFRAMEWORKS_VERSION=v0.4.2
MPV_XCFRAMEWORKS_SHA256SUM=9de3160558561500e8e89e192c78aed470fcec5d552ebc91a07d14cf7bf83699
MPV_XCFRAMEWORKS_VERSION=v0.5.1
MPV_XCFRAMEWORKS_SHA256SUM=a6c7cd6aec15c29ffef8f70ef0eedabaa10d9691832ec9bdccac1277ab23736f

.cache/xcframeworks/libmpv-xcframeworks-${MPV_XCFRAMEWORKS_VERSION}-ios-universal.tar.gz:
mkdir -p .cache/xcframeworks
rm -f .cache/xcframeworks/*.tmp .cache/xcframeworks/*-ios-universal.tar.gz
curl -L \
https://github.com/media-kit/libmpv-darwin-build/releases/download/${MPV_XCFRAMEWORKS_VERSION}/libmpv-xcframeworks-video-${MPV_XCFRAMEWORKS_VERSION}-ios-universal.tar.gz \
https://github.com/media-kit/libmpv-darwin-build/releases/download/${MPV_XCFRAMEWORKS_VERSION}/libmpv-xcframeworks_${MPV_XCFRAMEWORKS_VERSION}_ios-universal-video-default.tar.gz \
-o .cache/xcframeworks/libmpv.tar.gz.tmp
shasum -a 256 -c <<< '${MPV_XCFRAMEWORKS_SHA256SUM} .cache/xcframeworks/libmpv.tar.gz.tmp'
mv .cache/xcframeworks/libmpv.tar.gz.tmp .cache/xcframeworks/libmpv-xcframeworks-${MPV_XCFRAMEWORKS_VERSION}-ios-universal.tar.gz
Expand All @@ -23,6 +23,11 @@ Frameworks/*.xcframework: .cache/xcframeworks/libmpv-xcframeworks-ios-universal.
tar -xvf .cache/xcframeworks/libmpv-xcframeworks-ios-universal.tar.gz --strip-components 1 -C Frameworks
touch Frameworks/*.xcframework

Frameworks/.symlinks: Frameworks/*.xcframework
rm -rf Frameworks/.symlinks
mkdir -p Frameworks/.symlinks/mpv
sh create_framework_symlinks.sh Frameworks/Mpv.xcframework Frameworks/.symlinks/mpv

.PHONY: clean
clean:
rm -rf .cache
Expand Down
72 changes: 72 additions & 0 deletions libs/ios/media_kit_libs_ios_video/ios/create_framework_symlinks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/sh

# `create_framework_symlinks.sh` is duplicated across:
# - `media_kit_libs_ios_audio`
# - `media_kit_libs_ios_video`
# - `media_kit_libs_macos_audio`
# - `media_kit_libs_macos_video`

set -e
set -u

SRC_DIR="$1"
SYMLINKS_DIR="$2"

# Computes the relative path between two given paths
#
# Example:
# ```
# relpath Frameworks/Mpv.xcframework/ios-arm64 Frameworks/.symlinks/mpv
# ../../Mpv.xcframework/ios-arm64
# ```
#
# Source: https://stackoverflow.com/a/14914070
relpath() {
[ $# -ge 1 ] && [ $# -le 2 ] || return 1
current="${2:+"$1"}"
target="${2:-"$1"}"
[ "$target" != . ] || target=/
target="/${target##/}"
[ "$current" != . ] || current=/
current="${current:="/"}"
current="/${current##/}"
appendix="${target##/}"
relative=''
while appendix="${target#"$current"/}"
[ "$current" != '/' ] && [ "$appendix" = "$target" ]; do
if [ "$current" = "$appendix" ]; then
relative="${relative:-.}"
echo "${relative#/}"
return 0
fi
current="${current%/*}"
relative="$relative${relative:+/}.."
done
relative="$relative${relative:+${appendix:+/}}${appendix#/}"
echo "$relative"
}

# Create symbolic links from a given source directory to a destination directory
# for a specific framework
#
# Example:
# ```
# create_framework_symlinks Frameworks/Mpv.xcframework Frameworks/.symlinks/mpv
# Frameworks/.symlinks/mpv/ios -> ../../Mpv.xcframework/ios-arm64
# Frameworks/.symlinks/mpv/ios-simulator -> ../../Mpv.xcframework/ios-arm64_x86_64-simulator
# ```
create_framework_symlinks() {
SRC_DIR="$1"
SYMLINKS_DIR="$2"

find "${SRC_DIR}" -depth 1 -type d | while read SRC; do
SLUG="$(basename "${SRC}")"
NAME="$(echo "${SLUG}" | cut -d '-' -f 1 -f 3)"

SRC_RELATIVE="$(relpath "${SYMLINKS_DIR}" "${SRC}")"

ln -s "${SRC_RELATIVE}" "${SYMLINKS_DIR}/${NAME}"
done
}

create_framework_symlinks "${SRC_DIR}" "${SYMLINKS_DIR}"
5 changes: 5 additions & 0 deletions libs/macos/media_kit_libs_macos_audio/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.1.0

- build: bump libs to default flavor
- build: add symlinks to `Mpv.framework`

## 1.0.6

- build: bump libs version
Expand Down
13 changes: 9 additions & 4 deletions libs/macos/media_kit_libs_macos_audio/macos/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
all: Frameworks/*.xcframework
all: Frameworks/*.xcframework Frameworks/.symlinks

MPV_XCFRAMEWORKS_VERSION=v0.4.2
MPV_XCFRAMEWORKS_SHA256SUM=6714cd04d2ca9fe1d8bfc3a369e589a55f1d01963d93e057b5e0379f13962116
MPV_XCFRAMEWORKS_VERSION=v0.5.1
MPV_XCFRAMEWORKS_SHA256SUM=2dd65f4afc5031e22794a5b583cf56f8e6b4e901d2d811cf5c8a0dd1d083c08f

.cache/xcframeworks/libmpv-xcframeworks-${MPV_XCFRAMEWORKS_VERSION}-macos-universal.tar.gz:
mkdir -p .cache/xcframeworks
rm -f .cache/xcframeworks/*.tmp .cache/xcframeworks/*-macos-universal.tar.gz
curl -L \
https://github.com/media-kit/libmpv-darwin-build/releases/download/${MPV_XCFRAMEWORKS_VERSION}/libmpv-xcframeworks-audio-${MPV_XCFRAMEWORKS_VERSION}-macos-universal.tar.gz \
https://github.com/media-kit/libmpv-darwin-build/releases/download/${MPV_XCFRAMEWORKS_VERSION}/libmpv-xcframeworks_${MPV_XCFRAMEWORKS_VERSION}_macos-universal-audio-default.tar.gz \
-o .cache/xcframeworks/libmpv.tar.gz.tmp
shasum -a 256 -c <<< '${MPV_XCFRAMEWORKS_SHA256SUM} .cache/xcframeworks/libmpv.tar.gz.tmp'
mv .cache/xcframeworks/libmpv.tar.gz.tmp .cache/xcframeworks/libmpv-xcframeworks-${MPV_XCFRAMEWORKS_VERSION}-macos-universal.tar.gz
Expand All @@ -23,6 +23,11 @@ Frameworks/*.xcframework: .cache/xcframeworks/libmpv-xcframeworks-macos-universa
tar -xvf .cache/xcframeworks/libmpv-xcframeworks-macos-universal.tar.gz --strip-components 1 -C Frameworks
touch Frameworks/*.xcframework

Frameworks/.symlinks: Frameworks/*.xcframework
rm -rf Frameworks/.symlinks
mkdir -p Frameworks/.symlinks/mpv
sh create_framework_symlinks.sh Frameworks/Mpv.xcframework Frameworks/.symlinks/mpv

.PHONY: clean
clean:
rm -rf .cache
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/sh

# `create_framework_symlinks.sh` is duplicated across:
# - `media_kit_libs_ios_audio`
# - `media_kit_libs_ios_video`
# - `media_kit_libs_macos_audio`
# - `media_kit_libs_macos_video`

set -e
set -u

SRC_DIR="$1"
SYMLINKS_DIR="$2"

# Computes the relative path between two given paths
#
# Example:
# ```
# relpath Frameworks/Mpv.xcframework/ios-arm64 Frameworks/.symlinks/mpv
# ../../Mpv.xcframework/ios-arm64
# ```
#
# Source: https://stackoverflow.com/a/14914070
relpath() {
[ $# -ge 1 ] && [ $# -le 2 ] || return 1
current="${2:+"$1"}"
target="${2:-"$1"}"
[ "$target" != . ] || target=/
target="/${target##/}"
[ "$current" != . ] || current=/
current="${current:="/"}"
current="/${current##/}"
appendix="${target##/}"
relative=''
while appendix="${target#"$current"/}"
[ "$current" != '/' ] && [ "$appendix" = "$target" ]; do
if [ "$current" = "$appendix" ]; then
relative="${relative:-.}"
echo "${relative#/}"
return 0
fi
current="${current%/*}"
relative="$relative${relative:+/}.."
done
relative="$relative${relative:+${appendix:+/}}${appendix#/}"
echo "$relative"
}

# Create symbolic links from a given source directory to a destination directory
# for a specific framework
#
# Example:
# ```
# create_framework_symlinks Frameworks/Mpv.xcframework Frameworks/.symlinks/mpv
# Frameworks/.symlinks/mpv/ios -> ../../Mpv.xcframework/ios-arm64
# Frameworks/.symlinks/mpv/ios-simulator -> ../../Mpv.xcframework/ios-arm64_x86_64-simulator
# ```
create_framework_symlinks() {
SRC_DIR="$1"
SYMLINKS_DIR="$2"

find "${SRC_DIR}" -depth 1 -type d | while read SRC; do
SLUG="$(basename "${SRC}")"
NAME="$(echo "${SLUG}" | cut -d '-' -f 1 -f 3)"

SRC_RELATIVE="$(relpath "${SYMLINKS_DIR}" "${SRC}")"

ln -s "${SRC_RELATIVE}" "${SYMLINKS_DIR}/${NAME}"
done
}

create_framework_symlinks "${SRC_DIR}" "${SYMLINKS_DIR}"
5 changes: 5 additions & 0 deletions libs/macos/media_kit_libs_macos_video/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.1.0

- build: bump libs to default flavor
- build: add symlinks to `Mpv.framework`

## 1.0.6

- build: bump libs version
Expand Down
13 changes: 9 additions & 4 deletions libs/macos/media_kit_libs_macos_video/macos/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
all: Frameworks/*.xcframework
all: Frameworks/*.xcframework Frameworks/.symlinks

MPV_XCFRAMEWORKS_VERSION=v0.4.2
MPV_XCFRAMEWORKS_SHA256SUM=67ad90c1ff7d939848d57b5b6359741a3e0c9a0c3b15d9ec1d6d2744089b78d5
MPV_XCFRAMEWORKS_VERSION=v0.5.1
MPV_XCFRAMEWORKS_SHA256SUM=c36cced892588399d9268d3e514e0bca871ef09f0e04cef8078e9f172a8caadb

.cache/xcframeworks/libmpv-xcframeworks-${MPV_XCFRAMEWORKS_VERSION}-macos-universal.tar.gz:
mkdir -p .cache/xcframeworks
rm -f .cache/xcframeworks/*.tmp .cache/xcframeworks/*-macos-universal.tar.gz
curl -L \
https://github.com/media-kit/libmpv-darwin-build/releases/download/${MPV_XCFRAMEWORKS_VERSION}/libmpv-xcframeworks-video-${MPV_XCFRAMEWORKS_VERSION}-macos-universal.tar.gz \
https://github.com/media-kit/libmpv-darwin-build/releases/download/${MPV_XCFRAMEWORKS_VERSION}/libmpv-xcframeworks_${MPV_XCFRAMEWORKS_VERSION}_macos-universal-video-default.tar.gz \
-o .cache/xcframeworks/libmpv.tar.gz.tmp
shasum -a 256 -c <<< '${MPV_XCFRAMEWORKS_SHA256SUM} .cache/xcframeworks/libmpv.tar.gz.tmp'
mv .cache/xcframeworks/libmpv.tar.gz.tmp .cache/xcframeworks/libmpv-xcframeworks-${MPV_XCFRAMEWORKS_VERSION}-macos-universal.tar.gz
Expand All @@ -23,6 +23,11 @@ Frameworks/*.xcframework: .cache/xcframeworks/libmpv-xcframeworks-macos-universa
tar -xvf .cache/xcframeworks/libmpv-xcframeworks-macos-universal.tar.gz --strip-components 1 -C Frameworks
touch Frameworks/*.xcframework

Frameworks/.symlinks: Frameworks/*.xcframework
rm -rf Frameworks/.symlinks
mkdir -p Frameworks/.symlinks/mpv
sh create_framework_symlinks.sh Frameworks/Mpv.xcframework Frameworks/.symlinks/mpv

.PHONY: clean
clean:
rm -rf .cache
Expand Down
Loading

0 comments on commit 9bac9dd

Please sign in to comment.