Skip to content

Commit 496cc70

Browse files
committed
chore: Support arm64 iphone simulator.
1 parent aa0e2a8 commit 496cc70

File tree

9 files changed

+159
-45
lines changed

9 files changed

+159
-45
lines changed

.github/workflows/deploy.yml

+14-20
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
- name: Cache dependencies
5252
uses: actions/cache@v4
5353
with:
54-
path: prefix
54+
path: deps-prefix-linux-${{ matrix.arch }}
5555
key: ${{ github.job }}-${{ matrix.arch }}-deps
5656
- name: Run build
5757
run: other/deploy/linux.sh "${{ matrix.arch }}"
@@ -108,12 +108,10 @@ jobs:
108108
- uses: actions/checkout@v4
109109
with:
110110
submodules: recursive
111-
- name: Install build tools
112-
run: brew install coreutils ninja yasm
113111
- name: Cache dependencies
114112
uses: actions/cache@v4
115113
with:
116-
path: prefix
114+
path: deps-prefix-macos-${{ matrix.arch }}
117115
key: ${{ github.job }}-${{ matrix.arch }}-deps
118116
- name: Run build
119117
run: other/deploy/macos.sh "${{ matrix.arch }}"
@@ -164,36 +162,34 @@ jobs:
164162
needs: [update-nightly-tag]
165163
strategy:
166164
matrix:
167-
arch: [arm64, armv7, armv7s, i386, x86_64]
165+
target: [ios-arm64, ios-armv7, ios-armv7s, iphonesimulator-arm64, iphonesimulator-x86_64]
168166
runs-on: 'macos-14'
169167
steps:
170168
- uses: actions/checkout@v4
171169
with:
172170
submodules: recursive
173-
- name: Install build tools
174-
run: brew install coreutils ninja yasm
175171
- name: Cache dependencies
176172
uses: actions/cache@v4
177173
with:
178-
path: prefix
179-
key: ${{ github.job }}-${{ matrix.arch }}-deps
174+
path: deps-prefix-${{ matrix.target }}
175+
key: ${{ github.job }}-${{ matrix.target }}-deps
180176
- name: Run build
181-
run: other/deploy/ios.sh "${{ matrix.arch }}"
177+
run: other/deploy/ios.sh "${{ matrix.target }}"
182178
- name: Upload artifacts
183179
uses: actions/upload-artifact@v4
184180
with:
185-
name: toxcore-ios-${{ matrix.arch }}
186-
path: toxcore-ios-${{ matrix.arch }}
181+
name: toxcore-${{ matrix.target }}
182+
path: toxcore-${{ matrix.target }}
187183
- name: Get tag name for release file name
188184
if: contains(github.ref, 'refs/tags/v')
189185
id: get_version
190186
run: |
191187
VERSION="$(echo "$GITHUB_REF" | cut -d / -f 3)"
192-
echo "release_tarball=toxcore-$VERSION-ios-${{ matrix.arch }}.tar.gz" >>$GITHUB_OUTPUT
188+
echo "release_tarball=toxcore-$VERSION-${{ matrix.target }}.tar.gz" >>$GITHUB_OUTPUT
193189
- name: Create tarball for release upload
194190
if: contains(github.ref, 'refs/tags/v')
195191
run: |
196-
tar zcf "${{ steps.get_version.outputs.release_tarball }}" toxcore-ios-${{ matrix.arch }}
192+
tar zcf "${{ steps.get_version.outputs.release_tarball }}" toxcore-${{ matrix.target }}
197193
sha256sum "${{ steps.get_version.outputs.release_tarball }}" > "${{ steps.get_version.outputs.release_tarball }}.sha256"
198194
- name: Upload to versioned release
199195
if: contains(github.ref, 'refs/tags/v')
@@ -206,8 +202,8 @@ jobs:
206202
- name: Create tarball for nightly upload
207203
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
208204
run: |
209-
tar zcf toxcore-nightly-ios-${{ matrix.arch }}.tar.gz toxcore-ios-${{ matrix.arch }}
210-
sha256sum toxcore-nightly-ios-${{ matrix.arch }}.tar.gz > toxcore-nightly-ios-${{ matrix.arch }}.tar.gz.sha256
205+
tar zcf toxcore-nightly-${{ matrix.target }}.tar.gz toxcore-${{ matrix.target }}
206+
sha256sum toxcore-nightly-${{ matrix.target }}.tar.gz > toxcore-nightly-${{ matrix.target }}.tar.gz.sha256
211207
- name: Upload to nightly release
212208
uses: ncipollo/release-action@v1
213209
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
@@ -219,7 +215,7 @@ jobs:
219215
prerelease: true
220216
replacesArtifacts: true
221217
token: ${{ secrets.GITHUB_TOKEN }}
222-
artifacts: "toxcore-nightly-ios-${{ matrix.arch }}.tar.gz,toxcore-nightly-ios-${{ matrix.arch }}.tar.gz.sha256"
218+
artifacts: "toxcore-nightly-${{ matrix.target }}.tar.gz,toxcore-nightly-${{ matrix.target }}.tar.gz.sha256"
223219

224220
build-android:
225221
name: Android
@@ -232,12 +228,10 @@ jobs:
232228
- uses: actions/checkout@v4
233229
with:
234230
submodules: recursive
235-
- name: Install build tools
236-
run: sudo apt-get install -y --no-install-recommends ninja-build yasm
237231
- name: Cache dependencies
238232
uses: actions/cache@v4
239233
with:
240-
path: prefix
234+
path: deps-prefix-android-${{ matrix.arch }}
241235
key: ${{ github.job }}-${{ matrix.arch }}-deps
242236
- name: Run build
243237
run: other/deploy/android.sh "${{ matrix.arch }}"

other/deploy/android.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
set -eu
44

5+
if [ -n "${CI-}" ]; then
6+
sudo apt-get install -y --no-install-recommends ninja-build yasm
7+
fi
8+
59
# Set up environment
610
NDK=$ANDROID_NDK_HOME
711

@@ -33,7 +37,7 @@ case $ABI in
3337
;;
3438
esac
3539

36-
PREFIX="$PWD/prefix"
40+
PREFIX="$PWD/deps-prefix-android-$ABI"
3741

3842
TOOLCHAIN="$NDK/toolchains/llvm/prebuilt/linux-x86_64"
3943
SYSROOT="$TOOLCHAIN/sysroot"

other/deploy/deps.sh

+13-12
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,28 @@
22

33
set -eux -o pipefail
44

5-
if [ -d "prefix" ]; then
6-
exit 0
7-
fi
5+
SYSTEM="$1"
6+
ARCH="$2"
87

98
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
109

11-
git clone --depth=1 https://github.com/TokTok/dockerfiles "$SCRIPT_DIR/dockerfiles"
10+
DEP_PREFIX="$PWD/deps-prefix-$SYSTEM-$ARCH"
1211

13-
SYSTEM="$1"
14-
ARCH="$2"
12+
if [ -d "$DEP_PREFIX" ]; then
13+
exit 0
14+
fi
1515

16-
DEP_PREFIX="$PWD/prefix"
16+
if [ -d ../dockerfiles ]; then
17+
DOCKERFILES="$(realpath ../dockerfiles)"
18+
else
19+
git clone --depth=1 https://github.com/TokTok/dockerfiles "$SCRIPT_DIR/dockerfiles"
20+
DOCKERFILES="$SCRIPT_DIR/dockerfiles"
21+
fi
1722

1823
for dep in sodium opus vpx; do
1924
mkdir -p "external/$dep"
2025
pushd "external/$dep"
21-
if [ -f "$SCRIPT_DIR/dockerfiles/qtox/build_${dep}_$SYSTEM.sh" ]; then
22-
SCRIPT="$SCRIPT_DIR/dockerfiles/qtox/build_${dep}_$SYSTEM.sh"
23-
else
24-
SCRIPT="$SCRIPT_DIR/dockerfiles/qtox/build_$dep.sh"
25-
fi
26+
SCRIPT="$DOCKERFILES/qtox/build_$dep.sh"
2627
"$SCRIPT" --arch "$SYSTEM-$ARCH" --libtype "static" --buildtype "release" --prefix "$DEP_PREFIX" --macos "10.15"
2728
popd
2829
rm -rf "external/$dep"

other/deploy/ios.sh

+25-10
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,39 @@ set -eux -o pipefail
44

55
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
66

7-
ARCH="$1"
8-
"$SCRIPT_DIR/deps.sh" ios "$ARCH"
7+
TARGET="$1"
98

10-
export PKG_CONFIG_PATH="$PWD/prefix/lib/pkgconfig"
9+
SYSTEM="${TARGET%%-*}"
10+
ARCH="${TARGET#*-}"
1111

12-
IOS_FLAGS="-miphoneos-version-min=10.0 -arch $ARCH"
12+
if [ -n "${CI-}" ]; then
13+
brew install coreutils ninja yasm
14+
fi
15+
16+
"$SCRIPT_DIR/deps.sh" "$SYSTEM" "$ARCH"
17+
18+
export PKG_CONFIG_PATH="$PWD/deps-prefix-$SYSTEM-$ARCH/lib/pkgconfig"
1319

14-
if [ "$ARCH" = "i386" ] || [ "$ARCH" = "x86_64" ]; then
20+
if [ "$SYSTEM" = "ios" ]; then
21+
XC_SDK="iphoneos"
22+
TARGET_IPHONE_SIMULATOR=OFF
23+
IOS_FLAGS="-miphoneos-version-min=10.0 -arch $ARCH"
24+
elif [ "$SYSTEM" = "iphonesimulator" ]; then
1525
XC_SDK="iphonesimulator"
26+
TARGET_IPHONE_SIMULATOR=ON
27+
IOS_FLAGS="-arch $ARCH"
1628
else
17-
XC_SDK="iphoneos"
29+
echo "Unexpected system $SYSTEM"
30+
exit 1
1831
fi
1932

33+
BUILD_DIR="_build-$SYSTEM-$ARCH"
34+
2035
# Build for iOS 10
2136
cmake \
22-
-B _build \
37+
-B "$BUILD_DIR" \
2338
-G Ninja \
24-
-DCMAKE_INSTALL_PREFIX="$PWD/toxcore-ios-$ARCH" \
39+
-DCMAKE_INSTALL_PREFIX="$PWD/toxcore-$SYSTEM-$ARCH" \
2540
-DCMAKE_BUILD_TYPE=Release \
2641
-DENABLE_STATIC=OFF \
2742
-DENABLE_SHARED=ON \
@@ -38,5 +53,5 @@ cmake \
3853
-DCMAKE_OSX_SYSROOT="$(xcrun --sdk "$XC_SDK" --show-sdk-path)" \
3954
-DCMAKE_OSX_ARCHITECTURES="$ARCH"
4055

41-
cmake --build _build
42-
cmake --install _build
56+
cmake --build "$BUILD_DIR"
57+
cmake --install "$BUILD_DIR"

other/deploy/ios/LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../LICENSE

other/deploy/ios/make_framework

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
3+
set -eux -o pipefail
4+
5+
# Make a Tox.xcframework for iOS, iPhone simulator, and macOS from the nightly builds.
6+
for arch in arm64 armv7 armv7s; do
7+
rm -rf "ios/$arch"
8+
mkdir -p "ios/$arch"
9+
tar -C "ios/$arch" --strip-components=1 -zxf \
10+
<(curl -L "https://github.com/TokTok/c-toxcore/releases/download/nightly/toxcore-nightly-ios-$arch.tar.gz")
11+
done
12+
13+
for arch in arm64 x86_64; do
14+
rm -rf "iphonesimulator/$arch"
15+
mkdir -p "iphonesimulator/$arch"
16+
tar -C "iphonesimulator/$arch" --strip-components=1 -zxf \
17+
<(curl -L "https://github.com/TokTok/c-toxcore/releases/download/nightly/toxcore-nightly-iphonesimulator-$arch.tar.gz")
18+
done
19+
20+
for arch in arm64 x86_64; do
21+
rm -rf "macos/$arch"
22+
mkdir -p "macos/$arch"
23+
tar -C "macos/$arch" --strip-components=1 -zxf \
24+
<(curl -L "https://github.com/TokTok/c-toxcore/releases/download/nightly/toxcore-nightly-macos-$arch.tar.gz")
25+
done
26+
27+
# Make a Tox.framework for iOS.
28+
rm -rf ios/Tox.framework
29+
mkdir -p ios/Tox.framework
30+
cp -r ios/arm64/include/tox ios/Tox.framework/Headers
31+
lipo -create -output ios/Tox.framework/Tox ios/arm64/lib/libtoxcore.dylib ios/armv7/lib/libtoxcore.dylib ios/armv7s/lib/libtoxcore.dylib
32+
install_name_tool -id @rpath/Tox.framework/Tox ios/Tox.framework/Tox
33+
34+
# Make a Tox.framework for iPhone simulator.
35+
rm -rf iphonesimulator/Tox.framework
36+
mkdir -p iphonesimulator/Tox.framework
37+
cp -r iphonesimulator/arm64/include/tox iphonesimulator/Tox.framework/Headers
38+
lipo -create -output iphonesimulator/Tox.framework/Tox iphonesimulator/arm64/lib/libtoxcore.dylib iphonesimulator/x86_64/lib/libtoxcore.dylib
39+
install_name_tool -id @rpath/Tox.framework/Tox iphonesimulator/Tox.framework/Tox
40+
41+
# Make a Tox.framework for macOS.
42+
rm -rf macos/Tox.framework
43+
mkdir -p macos/Tox.framework
44+
cp -r macos/arm64/include/tox macos/Tox.framework/Headers
45+
lipo -create -output macos/Tox.framework/Tox macos/arm64/lib/libtoxcore.dylib macos/x86_64/lib/libtoxcore.dylib
46+
install_name_tool -id @rpath/Tox.framework/Tox macos/Tox.framework/Tox
47+
48+
# Make a Tox.xcframework for iOS, iPhone simulator, and macOS.
49+
rm -rf Tox.xcframework
50+
xcodebuild -create-xcframework -framework ios/Tox.framework -framework iphonesimulator/Tox.framework -framework macos/Tox.framework -output Tox.xcframework
51+
52+
# Test the Tox.xcframework.
53+
cat >smoke-test.c <<'EOF'
54+
#include <stdio.h>
55+
56+
#pragma GCC diagnostic push
57+
#pragma GCC diagnostic ignored "-Wdocumentation-deprecated-sync"
58+
#include <tox/tox.h>
59+
#pragma GCC diagnostic pop
60+
61+
int main(void) {
62+
Tox *tox = tox_new(NULL, NULL);
63+
if (tox == NULL) {
64+
fprintf(stderr, "tox_new failed\n");
65+
return 1;
66+
}
67+
tox_kill(tox);
68+
return 0;
69+
}
70+
EOF
71+
pod lib lint toxcore.podspec

other/deploy/ios/toxcore.podspec

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Pod::Spec.new do |s|
2+
s.name = "toxcore"
3+
s.version = "0.2.20"
4+
s.summary = "Cocoapods wrapper for toxcore"
5+
s.homepage = "https://github.com/TokTok/c-toxcore"
6+
s.license = 'GPLv3'
7+
s.author = { "Iphigenia Df" => "[email protected]" }
8+
s.source = {
9+
:git => "https://github.com/TokTok/c-toxcore.git",
10+
:tag => s.version.to_s,
11+
:submodules => true
12+
}
13+
14+
s.requires_arc = false
15+
16+
s.ios.deployment_target = '12.0'
17+
s.osx.deployment_target = '10.15'
18+
19+
s.vendored_frameworks = 'Tox.xcframework'
20+
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}"' }
21+
s.test_spec 'Tests' do |test_spec|
22+
test_spec.source_files = 'smoketest.c'
23+
end
24+
end

other/deploy/linux.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
77
ARCH="$1"
88
"$SCRIPT_DIR/deps.sh" linux "$ARCH"
99

10-
export PKG_CONFIG_PATH="$PWD/prefix/lib/pkgconfig"
10+
export PKG_CONFIG_PATH="$PWD/deps-prefix-linux-$ARCH/lib/pkgconfig"
1111

1212
# Build
1313
cmake \

other/deploy/macos.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ set -eux -o pipefail
44

55
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
66

7+
if [ -n "${CI-}" ]; then
8+
brew install coreutils ninja yasm
9+
fi
10+
711
ARCH="$1"
812
"$SCRIPT_DIR/deps.sh" macos "$ARCH"
913

10-
export PKG_CONFIG_PATH="$PWD/prefix/lib/pkgconfig"
14+
export PKG_CONFIG_PATH="$PWD/deps-prefix-macos-$ARCH/lib/pkgconfig"
1115

1216
# Build for macOS
1317
cmake \

0 commit comments

Comments
 (0)