Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
BB9z committed Mar 3, 2024
2 parents d1e5fcc + 6063a86 commit 9f9b106
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 80 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ on: [push, pull_request]

jobs:
build:
runs-on: macos-13
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: XCFramework Make
run: |
cd macosx
./make-xcframework.sh
env:
# Seems unable build visionOS at the moment
B9_BUILD_VISION_OS: false
1 change: 1 addition & 0 deletions macosx/Lame-Framework.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ PRODUCT_BUNDLE_IDENTIFIER = net.sourceforge.LAMEframework;
PRODUCT_MODULE_NAME = LAME;
PRODUCT_NAME = LAME;
SKIP_INSTALL = YES;
WARNING_CFLAGS = -Wno-shift-negative-value -Wno-shorten-64-to-32 -Wno-absolute-value -Wno-comma -Wno-tautological-pointer-compare;
WRAPPER_EXTENSION = framework;
169 changes: 95 additions & 74 deletions macosx/make-xcframework.sh
Original file line number Diff line number Diff line change
@@ -1,91 +1,112 @@
#!/bin/sh
#!/bin/zsh

# The script to create LAME.xcframework
# Build all platform targets and package them into the xcframework.
# Set `B9_BUILD_VISION_OS` environment variable to 0 can disable building for visionOS.
#
# Copyright © 2021, 2024 BB9z.
# https://github.com/BB9z/LAME-xcframework
#
# The MIT License
# https://opensource.org/licenses/MIT

set -euo pipefail

# Check if a variable is empty or 0 or false
#
# Return: 0 if variable is not empty or 0 or false
#
# Usage:
# if [[ $(check_var "$test_var") == 0 ]]; then
# echo "Variable is not 0, false, or empty"
# else
# echo "Variable is 0, false, or empty"
# fi
checkVar() {
local var_value="$1"
if [[ -z "$var_value" || "$var_value" == "0" || "${var_value:l}" == "false" ]]; then
echo "1"
else
echo "0"
fi
}

function _xcbuild() {
scheme=$1
destination=$2
archivePath=$3

echo "\nBuilding $scheme for $destination..." >&2

xcodebuild archive \
-scheme $scheme \
-destination $destination \
-archivePath $archivePath \
SKIP_INSTALL=NO
}

function xcbuild() {
if ! command -v xcbeautify &> /dev/null; then
_xcbuild "$@"
else
_xcbuild "$@" | xcbeautify
fi
}

## Check environment

echo "$PWD"

readonly B9_BUILD_VISION_OS=${B9_BUILD_VISION_OS:=1}

if [[ $(checkVar "$B9_BUILD_VISION_OS") != 0 ]]; then
echo "Skip building for visionOS."
fi

## Clean

if [ -d "LAME.xcframework" ]; then
echo "Remove previous result."
rm -r "LAME.xcframework"
else
echo "No previous build, go on."
fi

xcodebuild archive \
-scheme LAME-macOS \
-destination "generic/platform=macOS" \
-archivePath "build/macOS" \
SKIP_INSTALL=NO

xcodebuild archive \
-scheme LAME-iOS \
-destination "generic/platform=iOS" \
-archivePath "build/iOS" \
SKIP_INSTALL=NO

xcodebuild archive \
-scheme LAME-iOS \
-destination "generic/platform=iOS Simulator" \
-archivePath "build/iOS-Simulator" \
SKIP_INSTALL=NO

xcodebuild archive \
-scheme LAME-iOS \
-destination "generic/platform=macOS,variant=Mac Catalyst" \
-archivePath "build/Catalyst" \
SKIP_INSTALL=NO

xcodebuild archive \
-scheme LAME-tvOS \
-destination "generic/platform=tvOS" \
-archivePath "build/tvOS" \
SKIP_INSTALL=NO

xcodebuild archive \
-scheme LAME-tvOS \
-destination "generic/platform=tvOS Simulator" \
-archivePath "build/tvOS-Simulator" \
SKIP_INSTALL=NO

xcodebuild archive \
-scheme LAME-watchOS \
-destination "generic/platform=watchOS" \
-archivePath "build/watchOS" \
SKIP_INSTALL=NO

xcodebuild archive \
-scheme LAME-watchOS \
-destination "generic/platform=watchOS Simulator" \
-archivePath "build/watchOS-Simulator" \
SKIP_INSTALL=NO

xcodebuild archive \
-scheme LAME-visionOS \
-destination "generic/platform=visionOS" \
-archivePath "build/visonOS" \
SKIP_INSTALL=NO

xcodebuild archive \
-scheme LAME-visionOS \
-destination "generic/platform=visionOS Simulator" \
-archivePath "build/visonOS-Simulator" \
SKIP_INSTALL=NO

xcodebuild -create-xcframework \
-framework "build/macOS.xcarchive/Products/Library/Frameworks/LAME.framework" \
-framework "build/iOS.xcarchive/Products/Library/Frameworks/LAME.framework" \
-framework "build/iOS-Simulator.xcarchive/Products/Library/Frameworks/LAME.framework" \
-framework "build/Catalyst.xcarchive/Products/Library/Frameworks/LAME.framework" \
-framework "build/tvOS.xcarchive/Products/Library/Frameworks/LAME.framework" \
-framework "build/tvOS-Simulator.xcarchive/Products/Library/Frameworks/LAME.framework" \
-framework "build/watchOS.xcarchive/Products/Library/Frameworks/LAME.framework" \
-framework "build/watchOS-Simulator.xcarchive/Products/Library/Frameworks/LAME.framework" \
-framework "build/visonOS.xcarchive/Products/Library/Frameworks/LAME.framework" \
-framework "build/visonOS-Simulator.xcarchive/Products/Library/Frameworks/LAME.framework" \
-output "LAME.xcframework"
## Build

xcbuild LAME-macOS "generic/platform=macOS" "build/macOS"
xcbuild LAME-iOS "generic/platform=iOS" "build/iOS"
xcbuild LAME-iOS "generic/platform=iOS Simulator" "build/iOS-Simulator"
xcbuild LAME-iOS "generic/platform=macOS,variant=Mac Catalyst" "build/Catalyst"
xcbuild LAME-tvOS "generic/platform=tvOS" "build/tvOS"
xcbuild LAME-tvOS "generic/platform=tvOS Simulator" "build/tvOS-Simulator"
xcbuild LAME-watchOS "generic/platform=watchOS" "build/watchOS"
xcbuild LAME-watchOS "generic/platform=watchOS Simulator" "build/watchOS-Simulator"
if [[ $(checkVar "$B9_BUILD_VISION_OS") == 0 ]]; then
xcbuild LAME-visionOS "generic/platform=visionOS" "build/visonOS"
xcbuild LAME-visionOS "generic/platform=visionOS Simulator" "build/visonOS-Simulator"
fi

## Package

archivePaths=(
"build/macOS.xcarchive"
"build/iOS.xcarchive"
"build/iOS-Simulator.xcarchive"
"build/Catalyst.xcarchive"
"build/tvOS.xcarchive"
"build/tvOS-Simulator.xcarchive"
"build/watchOS.xcarchive"
"build/watchOS-Simulator.xcarchive"
)
if [[ $(checkVar "$B9_BUILD_VISION_OS") == 0 ]]; then
archivePaths+=("build/visonOS.xcarchive" "build/visonOS-Simulator.xcarchive")
fi

packageCmds=("xcodebuild" "-create-xcframework")
for part in $archivePaths; do
packageCmds+=("-framework" "$part/Products/Library/Frameworks/LAME.framework")
done
packageCmds+=("-output" "LAME.xcframework")

echo "${packageCmds[*]}"
"${packageCmds[@]}"
6 changes: 1 addition & 5 deletions make-package.command
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ readonly ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
rm -rf "$ROOT_DIR/LAME.xcframework" "$ROOT_DIR/LAME.xcframework.zip"

cd "$ROOT_DIR/macosx"
if [ -x "$(command -v xcpretty)" ]; then
sh ./make-xcframework.sh | xcpretty
else
sh ./make-xcframework.sh
fi
sh ./make-xcframework.sh

cd "$ROOT_DIR"

Expand Down

0 comments on commit 9f9b106

Please sign in to comment.