16
16
17
17
env :
18
18
OUTPUT_DIR : ${{ github.workspace }}/output
19
- LIBRARIES : ' ("opencore-amrnb" "opencore-amrwb")'
20
- PLATFORMS : ' ("macos" "iphoneos" "iphonesimulator")'
21
19
22
20
jobs :
23
21
build :
@@ -34,12 +32,20 @@ jobs:
34
32
steps :
35
33
- uses : actions/checkout@v4
36
34
35
+ - name : Get Xcode version
36
+ id : xcode-version
37
+ run : echo "version=$(xcodebuild -version | grep Xcode | awk '{print $2}')" >> $GITHUB_OUTPUT
38
+
39
+ - name : Get macOS version
40
+ id : macos-version
41
+ run : echo "version=$(sw_vers -productVersion)" >> $GITHUB_OUTPUT
42
+
37
43
- name : Cache build results
38
44
uses : actions/cache@v4
39
45
id : cache
40
46
with :
41
47
path : ${{ env.OUTPUT_DIR }}
42
- key : ${{ runner.os }}-build-${{ matrix.config.sdk }}-${{ matrix.config.arch }}-${{ hashFiles('**/*.c', '**/*.cpp', '**/*.h', '**/*.m', '**/*.mm') }}
48
+ key : ${{ runner.os }}-build-${{ matrix.config.sdk }}-${{ matrix.config.arch }}-${{ hashFiles('**/*.c', '**/*.cpp', '**/*.h', '**/*.m', '**/*.mm', '.github/actions/*.sh') }}-${{ steps.xcode-version.outputs.version }}-${{ steps.macos-version.outputs.version }}
43
49
44
50
- name : Set up Xcode
45
51
if : steps.cache.outputs.cache-hit != 'true'
@@ -86,54 +92,57 @@ jobs:
86
92
ls -R ${{ env.OUTPUT_DIR }}
87
93
88
94
- name : Create fat libraries using lipo
89
- shell : bash
90
95
run : |
91
96
mkdir -p "${OUTPUT_DIR}/fat"
92
- declare -A ARCHITECTURES=(
93
- ["macos"]="arm64 x86_64"
94
- ["iphoneos"]="arm64"
95
- ["iphonesimulator"]="x86_64 arm64"
96
- )
97
- eval "LIBRARIES=(${LIBRARIES})"
98
- eval "PLATFORMS=(${PLATFORMS})"
99
-
100
- for lib in "${LIBRARIES[@]}"; do
97
+
98
+ MACOS_ARCHS="arm64 x86_64"
99
+ IPHONEOS_ARCHS="arm64"
100
+ IPHONESIMULATOR_ARCHS="x86_64 arm64"
101
+
102
+ LIBRARIES="libopencore-amrnb libopencore-amrwb"
103
+
104
+ for lib in $LIBRARIES; do
101
105
# For macOS
102
- lipo -create $(for arch in ${ARCHITECTURES["macos"]} ; do echo "${OUTPUT_DIR}/build-macosx-${arch}/macosx-${arch}-MacOSX/lib/${lib}.a"; done) \
106
+ lipo -create $(for arch in $MACOS_ARCHS ; do echo "${OUTPUT_DIR}/build-macosx-${arch}/macosx-${arch}-MacOSX/lib/${lib}.a"; done) \
103
107
-output "${OUTPUT_DIR}/fat/${lib}-macos.a"
104
-
108
+
105
109
# For iOS device
106
110
cp "${OUTPUT_DIR}/build-iphoneos-arm64/iphoneos-arm64-iPhoneOS/lib/${lib}.a" "${OUTPUT_DIR}/fat/${lib}-iphoneos.a"
107
-
111
+
108
112
# For iOS simulator
109
- lipo -create $(for arch in ${ARCHITECTURES["iphonesimulator"]} ; do echo "${OUTPUT_DIR}/build-iphonesimulator-${arch}/iphonesimulator-${arch}-iPhoneSimulator/lib/${lib}.a"; done) \
113
+ lipo -create $(for arch in $IPHONESIMULATOR_ARCHS ; do echo "${OUTPUT_DIR}/build-iphonesimulator-${arch}/iphonesimulator-${arch}-iPhoneSimulator/lib/${lib}.a"; done) \
110
114
-output "${OUTPUT_DIR}/fat/${lib}-iphonesimulator.a"
111
115
done
112
116
113
117
- name : Create XCFrameworks
114
- shell : bash
115
118
run : |
116
119
mkdir -p "${OUTPUT_DIR}/Headers/"
117
- eval "LIBRARIES=(${LIBRARIES})"
118
- eval "PLATFORMS=(${PLATFORMS})"
119
- declare -A HEADERS=(
120
- ["opencore-amrnb"]="amrnb/interf_dec.h amrnb/interf_enc.h"
121
- ["opencore-amrwb"]="amrwb/dec_if.h amrwb/if_rom.h"
122
- )
123
- for lib in "${!HEADERS[@]}"; do
120
+
121
+ LIBRARIES="opencore-amrnb opencore-amrwb"
122
+ PLATFORMS="macos iphoneos iphonesimulator"
123
+
124
+ for lib in $LIBRARIES; do
124
125
rm -rf ${OUTPUT_DIR}/Headers/*
125
126
rm -rf ${OUTPUT_DIR}/${lib}.xcframework
127
+
126
128
# Copy headers
127
- for header in ${HEADERS[$lib]}; do
128
- cp -a $header ${OUTPUT_DIR}/Headers/
129
- done
129
+ case $lib in
130
+ opencore-amrnb)
131
+ cp -a amrnb/interf_dec.h amrnb/interf_enc.h ${OUTPUT_DIR}/Headers/
132
+ ;;
133
+ opencore-amrwb)
134
+ cp -a amrwb/dec_if.h amrwb/if_rom.h ${OUTPUT_DIR}/Headers/
135
+ ;;
136
+ esac
137
+
130
138
# Prepare xcodebuild command
131
139
cmd="xcodebuild -create-xcframework"
132
- for platform in "${ PLATFORMS[@]}" ; do
140
+ for platform in $ PLATFORMS; do
133
141
cmd+=" -library ${OUTPUT_DIR}/fat/lib${lib}-${platform}.a"
134
142
cmd+=" -headers ${OUTPUT_DIR}/Headers"
135
143
done
136
144
cmd+=" -output ${OUTPUT_DIR}/${lib}.xcframework"
145
+
137
146
# Execute xcodebuild command
138
147
eval $cmd
139
148
done
0 commit comments