Skip to content

Commit

Permalink
Merge pull request #2 from birros/feat/add-xcframework
Browse files Browse the repository at this point in the history
feat add xcframeworks
  • Loading branch information
birros authored Apr 3, 2023
2 parents 7da641e + 92d0215 commit 8cb3d35
Show file tree
Hide file tree
Showing 12 changed files with 374 additions and 48 deletions.
5 changes: 3 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
clang 14.0.0
cmake 3.25.3
clang 14.0.3
cmake 3.26.2
golang 1.17
meson 1.0.1
ninja 1.11.1
task 3.21.0
xcode 14.3
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,31 @@ the cost of some heaviness regarding legacy packages.
```
.
├── ...
├── cmd # golang scripts
├── pkg # golang packages
├── downloads # dependencies archives are downloaded here
├── downloads.lock # lock file of dependencies archives
├── Taskfile.yaml # main build script
├── scripts # build scripts
├── cross-files # cross build files used by meson
├── cmd # golang scripts
├── pkg # golang packages
├── downloads # dependencies archives are downloaded here
├── downloads.lock # lock file of dependencies archives
├── Taskfile.yaml # main build script
├── scripts # build scripts
├── cross-files # cross build files used by meson
├── build
│ ├── tool-versions.lock # versions of tools used during build
│ ├── tools # "sanboxed" tools & pkg-config are stored here
│ ├── tool-versions.lock # versions of tools used during build
│ ├── tools # "sanboxed" tools & pkg-config are stored here
│ ├── macos
│ └── ios
│ ├── universal # amd64 & arm64 builds are merge here with lipo
│ ├── universal # amd64 & arm64 builds are merge here with lipo
│ ├── amd64
│ └── arm64
│ ├── sources # archives are extracted here
│ ├── chroot # cross built files
│ ├── sources # archives are extracted here
│ ├── chroot # cross built files
│ │ ├── include
│ │ └── lib
│ ├── libs # cleaned libs from `chroot/lib`.
│ └── packages # zip & tar.gz of `libs`
│ ├── libs # cleaned libs from `chroot/lib`
│ ├── frameworks # `.framework` collection from `libs`
│ ├── xcframeworks # `.xcframework` collection from `frameworks`
│ └── packages
│ ├──libs # tar.gz of `libs`
│ └──xcframeworks # tar.gz of `xcframeworks`
└── ...
```

Expand Down
205 changes: 189 additions & 16 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ vars:
TERM:
sh: echo $TERM
VERSION:
sh: echo $VERSION
sh: echo ${VERSION:-develop}
UNSETENV: |
# unset all env vars
for i in $(env | awk -F"=" '{print $1}') ; do unset $i ; done
Expand Down Expand Up @@ -64,6 +64,7 @@ tasks:
- darwin
deps:
- tool-versions-lock
- packages-ios-universal
- packages-ios-arm64

build-ios-arm64:
Expand Down Expand Up @@ -127,8 +128,14 @@ tasks:
TARGET_DIR: "{{.BUILD_DIR}}/{{.OS}}"
deps:
- libs-macos-universal
- xcframeworks-macos-universal
cmds:
- task: packages
- task: packages-libs
vars:
OS: "{{.OS}}"
ARCH: "{{.ARCH}}"
TARGET_DIR: "{{.TARGET_DIR}}"
- task: packages-xcframeworks
vars:
OS: "{{.OS}}"
ARCH: "{{.ARCH}}"
Expand All @@ -144,7 +151,7 @@ tasks:
deps:
- libs-macos-amd64
cmds:
- task: packages
- task: packages-libs
vars:
OS: "{{.OS}}"
ARCH: "{{.ARCH}}"
Expand All @@ -160,7 +167,23 @@ tasks:
deps:
- libs-macos-arm64
cmds:
- task: packages
- task: packages-libs
vars:
OS: "{{.OS}}"
ARCH: "{{.ARCH}}"
TARGET_DIR: "{{.TARGET_DIR}}"

packages-ios-universal:
internal: true
run: once
vars:
OS: ios
ARCH: universal
TARGET_DIR: "{{.BUILD_DIR}}/{{.OS}}"
deps:
- xcframeworks-ios-universal
cmds:
- task: packages-xcframeworks
vars:
OS: "{{.OS}}"
ARCH: "{{.ARCH}}"
Expand All @@ -176,7 +199,7 @@ tasks:
deps:
- libs-ios-arm64
cmds:
- task: packages
- task: packages-libs
vars:
OS: "{{.OS}}"
ARCH: "{{.ARCH}}"
Expand All @@ -192,7 +215,7 @@ tasks:
deps:
- libs-iossimulator-universal
cmds:
- task: packages
- task: packages-libs
vars:
OS: "{{.OS}}"
ARCH: "{{.ARCH}}"
Expand All @@ -208,7 +231,7 @@ tasks:
deps:
- libs-iossimulator-amd64
cmds:
- task: packages
- task: packages-libs
vars:
OS: "{{.OS}}"
ARCH: "{{.ARCH}}"
Expand All @@ -224,32 +247,52 @@ tasks:
deps:
- libs-iossimulator-arm64
cmds:
- task: packages
- task: packages-libs
vars:
OS: "{{.OS}}"
ARCH: "{{.ARCH}}"
TARGET_DIR: "{{.TARGET_DIR}}"

packages:
label: packages-{{.OS}}-{{.ARCH}}
packages-xcframeworks:
label: packages-xcframeworks-{{.OS}}-{{.ARCH}}
internal: true
run: when_changed
vars:
XCFRAMEWORKS_DIR: "{{.TARGET_DIR}}/{{.ARCH}}/xcframeworks"
PACKAGES_DIR: "{{.TARGET_DIR}}/{{.ARCH}}/packages/xcframeworks"
sources:
- "{{.XCFRAMEWORKS_DIR}}/*.xcframework/*"
generates:
- "{{.PACKAGES_DIR}}/*.tar.gz"
cmds:
- rm -rf "{{.PACKAGES_DIR}}"
- |
set -e
NAME=libmpv-xcframeworks-{{.VERSION}}-{{.OS}}-{{.ARCH}}
mkdir -p "{{.PACKAGES_DIR}}/$NAME"
cp -r "{{.XCFRAMEWORKS_DIR}}"/*.xcframework "{{.PACKAGES_DIR}}"/$NAME/
cd "{{.PACKAGES_DIR}}"
tar -czvf $NAME.tar.gz $NAME
packages-libs:
label: packages-libs-{{.OS}}-{{.ARCH}}
internal: true
run: when_changed
vars:
LIBS_DIR: "{{.TARGET_DIR}}/{{.ARCH}}/libs"
PACKAGES_DIR: "{{.TARGET_DIR}}/{{.ARCH}}/packages"
PACKAGES_DIR: "{{.TARGET_DIR}}/{{.ARCH}}/packages/libs"
sources:
- "{{.LIBS_DIR}}/*.dylib"
generates:
- "{{.PACKAGES_DIR}}/*.tar.gz"
cmds:
- rm -rf "{{.PACKAGES_DIR}}"
- |
set -e
if [ -z "{{.VERSION}}" ]; then \
echo "package creation skipped for {{.OS}}/{{.ARCH}} (env var VERSION required)" ; \
exit 0; \
fi
NAME=libmpv-{{.VERSION}}-{{.OS}}-{{.ARCH}}
mkdir -p "{{.PACKAGES_DIR}}/$NAME"
Expand All @@ -258,6 +301,132 @@ tasks:
cd "{{.PACKAGES_DIR}}"
tar -czvf $NAME.tar.gz $NAME
xcframeworks-macos-universal:
internal: true
run: once
vars:
FRAMEWORKS_MACOS_DIR: "{{.BUILD_DIR}}/macos/universal/frameworks"
XCFRAMEWORKS_DIR: "{{.BUILD_DIR}}/macos/universal/xcframeworks"
deps:
- frameworks-macos-universal
sources:
- "{{.FRAMEWORKS_MACOS_DIR}}/*.framework/*"
generates:
- "{{.XCFRAMEWORKS_DIR}}/*.xcframework/*"
cmds:
- rm -rf "{{.XCFRAMEWORKS_DIR}}"
- |
set -e
{{.UNSETENV}}
export PATH={{.PATH}}
export TERM={{.TERM}}
sh "{{.PROJECT_DIR}}/scripts/xcframeworks/macos/create_xcframeworks.sh" \
"{{.FRAMEWORKS_MACOS_DIR}}" \
"{{.XCFRAMEWORKS_DIR}}"
xcframeworks-ios-universal:
internal: true
run: once
vars:
FRAMEWORKS_IOS_DIR: "{{.BUILD_DIR}}/ios/arm64/frameworks"
FRAMEWORKS_IOSSIMULATOR_DIR: "{{.BUILD_DIR}}/iossimulator/universal/frameworks"
XCFRAMEWORKS_DIR: "{{.BUILD_DIR}}/ios/universal/xcframeworks"
deps:
- frameworks-ios-arm64
- frameworks-iossimulator-universal
sources:
- "{{.FRAMEWORKS_IOS_DIR}}/*.framework/*"
- "{{.FRAMEWORKS_IOSSIMULATOR_DIR}}/*.framework/*"
generates:
- "{{.XCFRAMEWORKS_DIR}}/*.xcframework/*"
cmds:
- rm -rf "{{.XCFRAMEWORKS_DIR}}"
- |
set -e
{{.UNSETENV}}
export PATH={{.PATH}}
export TERM={{.TERM}}
sh "{{.PROJECT_DIR}}/scripts/xcframeworks/ios/create_xcframeworks.sh" \
"{{.FRAMEWORKS_IOS_DIR}}" \
"{{.FRAMEWORKS_IOSSIMULATOR_DIR}}" \
"{{.XCFRAMEWORKS_DIR}}"
frameworks-macos-universal:
internal: true
run: once
vars:
OS: macos
ARCH: universal
TARGET_DIR: "{{.BUILD_DIR}}/{{.OS}}"
deps:
- libs-macos-universal
cmds:
- task: frameworks
vars:
OS: "{{.OS}}"
ARCH: "{{.ARCH}}"
TARGET_DIR: "{{.TARGET_DIR}}"

frameworks-ios-arm64:
internal: true
run: once
vars:
OS: ios
ARCH: arm64
TARGET_DIR: "{{.BUILD_DIR}}/{{.OS}}"
deps:
- libs-ios-arm64
cmds:
- task: frameworks
vars:
OS: "{{.OS}}"
ARCH: "{{.ARCH}}"
TARGET_DIR: "{{.TARGET_DIR}}"

frameworks-iossimulator-universal:
internal: true
run: once
vars:
OS: iossimulator
ARCH: universal
TARGET_DIR: "{{.BUILD_DIR}}/{{.OS}}"
deps:
- libs-iossimulator-universal
cmds:
- task: frameworks
vars:
OS: "{{.OS}}"
ARCH: "{{.ARCH}}"
TARGET_DIR: "{{.TARGET_DIR}}"

frameworks:
label: frameworks-{{.OS}}-{{.ARCH}}
internal: true
run: when_changed
vars:
LIBS_DIR: "{{.TARGET_DIR}}/{{.ARCH}}/libs"
FRAMEWORKS_DIR: "{{.TARGET_DIR}}/{{.ARCH}}/frameworks"
sources:
- "{{.LIBS_DIR}}/*.dylib"
generates:
- "{{.FRAMEWORKS_DIR}}/*.framework/*"
cmds:
- |
set -e
{{.UNSETENV}}
export PATH={{.PATH}}
export TERM={{.TERM}}
sh "{{.PROJECT_DIR}}/scripts/frameworks/create_frameworks.sh" \
"{{.OS}}" \
"{{.LIBS_DIR}}" \
"{{.FRAMEWORKS_DIR}}"
libs-macos-universal:
internal: true
desc: merge {{.ARHC1}} & {{.ARHC2}} libs to {{.ARHC3}}
Expand Down Expand Up @@ -470,6 +639,10 @@ tasks:
codesign --remove "{{.LIBS_DIR}}"/*.dylib
if [ "{{.OS}}" == "iossimulator" ] && [ "{{.ARCH}}" == "arm64" ]; then \
sh "{{.PROJECT_DIR}}/scripts/libs/fix_iossimulator_arm64.sh" "{{.LIBS_DIR}}"; \
fi
downloads:
run: once
sources:
Expand Down
16 changes: 8 additions & 8 deletions cross-files/macos-amd64.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ strip = ['strip']
pkgconfig = ['pkg-config']

[built-in options]
c_args = ['-arch', 'x86_64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=10.14']
cpp_args = ['-stdlib=libc++', '-arch', 'x86_64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=10.14']
objc_args = ['-arch', 'x86_64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=10.14']
objcpp_args = ['-stdlib=libc++', '-arch', 'x86_64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=10.14']
c_link_args = ['-arch', 'x86_64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=10.14']
cpp_link_args = ['-arch', 'x86_64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=10.14']
objc_link_args = ['-arch', 'x86_64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=10.14']
objcpp_link_args = ['-arch', 'x86_64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=10.14']
c_args = ['-arch', 'x86_64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=11.0']
cpp_args = ['-stdlib=libc++', '-arch', 'x86_64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=11.0']
objc_args = ['-arch', 'x86_64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=11.0']
objcpp_args = ['-stdlib=libc++', '-arch', 'x86_64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=11.0']
c_link_args = ['-arch', 'x86_64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=11.0']
cpp_link_args = ['-arch', 'x86_64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=11.0']
objc_link_args = ['-arch', 'x86_64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=11.0']
objcpp_link_args = ['-arch', 'x86_64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=11.0']
16 changes: 8 additions & 8 deletions cross-files/macos-arm64.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ strip = ['strip']
pkgconfig = ['pkg-config']

[built-in options]
c_args = ['-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=10.14']
cpp_args = ['-stdlib=libc++', '-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=10.14']
objc_args = ['-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=10.14']
objcpp_args = ['-stdlib=libc++', '-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=10.14']
c_link_args = ['-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=10.14']
cpp_link_args = ['-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=10.14']
objc_link_args = ['-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=10.14']
objcpp_link_args = ['-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=10.14']
c_args = ['-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=11.0']
cpp_args = ['-stdlib=libc++', '-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=11.0']
objc_args = ['-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=11.0']
objcpp_args = ['-stdlib=libc++', '-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=11.0']
c_link_args = ['-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=11.0']
cpp_link_args = ['-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=11.0']
objc_link_args = ['-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=11.0']
objcpp_link_args = ['-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', '-mmacosx-version-min=11.0']
Loading

0 comments on commit 8cb3d35

Please sign in to comment.