This repository was archived by the owner on Sep 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
171 lines (159 loc) · 5.34 KB
/
noosphere_apple_build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
on:
workflow_call:
inputs:
for-test:
type: boolean
default: false
workflow_dispatch:
inputs:
for-test:
description: 'MacOS x86_64 support only'
type: boolean
default: false
name: 'Build Noosphere artifacts (Apple)'
jobs:
determine-build-matrix:
name: 'Determine build matrix'
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
env:
FOR_TEST: ${{ inputs.for-test }}
run: |
if [[ $FOR_TEST == true ]]; then
targets=("x86_64-apple-darwin")
else
targets=(
"aarch64-apple-ios"
"x86_64-apple-ios"
"aarch64-apple-ios-sim"
"x86_64-apple-darwin"
"aarch64-apple-darwin"
)
fi
echo -n 'matrix={"include":[' >> $GITHUB_OUTPUT
target_out=""
for target in "${targets[@]}"; do
target_json="{\"target\":\"$target\"}"
if [ -z "$target_out" ]; then
target_out="$target_json"
else
target_out="$target_out,$target_json"
fi
done
echo -n "$target_out ]}" >> $GITHUB_OUTPUT
# Build Noosphere out of the noosphere crate for Apple targets
noosphere-apple-build:
name: 'Build Noosphere libraries (Apple)'
needs: ['determine-build-matrix']
strategy:
fail-fast: true
matrix: ${{ fromJSON(needs.determine-build-matrix.outputs.matrix) }}
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ matrix.target }}
- name: 'Setup Rust'
run: |
curl -sSf https://sh.rustup.rs | sh -s -- -y
rustup target add ${{ matrix.target }}
- uses: ConorMacBride/install-package@v1
with:
brew: protobuf cmake
- name: 'Cargo Build'
run: cargo build --package noosphere --release --locked --target ${{ matrix.target }} --features rocksdb
- run: |
cd target/${{ matrix.target }}/release
- uses: actions/upload-artifact@v3
with:
name: lib_${{ matrix.target }}
path: target/${{ matrix.target }}/release/libnoosphere.a
# Generates the FFI C header for Noosphere and bundles it with a
# modulemap for Apple use cases
noosphere-header-generation:
name: 'Generate Noosphere C header'
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: 'Setup Rust'
run: |
curl -sSf https://sh.rustup.rs | sh -s -- -y
- uses: ConorMacBride/install-package@v1
with:
brew: protobuf cmake
- name: 'Generate the header'
run: |
./scripts/generate-headers.sh
- uses: actions/upload-artifact@v3
with:
name: include
path: target/headers/include
# Generate Apple "universal" libraries for Noosphere for supported targets
noosphere-apple-lipo:
name: 'Generate Noosphere universal libraries (Apple)'
needs: ['noosphere-apple-build']
strategy:
fail-fast: false
matrix:
include:
# iOS Simulator
- legacy_target: x86_64-apple-ios
future_target: aarch64-apple-ios-sim
platform: ios-simulator
# Mac OS
- legacy_target: x86_64-apple-darwin
future_target: aarch64-apple-darwin
platform: macos
runs-on: macos-12
steps:
- uses: actions/download-artifact@v3
if: ${{ !inputs.for-test }}
- name: 'Make a universal library'
if: ${{ !inputs.for-test }}
run: |
lipo -create \
./lib_${{ matrix.legacy_target }}/libnoosphere.a \
./lib_${{ matrix.future_target }}/libnoosphere.a \
-output ./libnoosphere.a
- uses: actions/upload-artifact@v3
if: ${{ !inputs.for-test }}
with:
name: lib_${{ matrix.platform }}-universal
path: libnoosphere.a
# Generates an Apple XCode Framework for Noosphere from all the built
# Apple libraries
noosphere-apple-xcframework:
name: 'Generate Noosphere XCFramework'
needs: ['noosphere-apple-lipo', 'noosphere-header-generation']
runs-on: macos-12
steps:
- uses: actions/download-artifact@v3
- name: 'Generate XCFramework'
env:
FOR_TEST: ${{ inputs.for-test }}
run: |
if [ "$FOR_TEST" = true ]; then
xcodebuild -create-xcframework \
-library ./lib_x86_64-apple-darwin/libnoosphere.a \
-headers ./include/ \
-output ./LibNoosphere.xcframework
else
xcodebuild -create-xcframework \
-library ./lib_macos-universal/libnoosphere.a \
-headers ./include/ \
-library ./lib_ios-simulator-universal/libnoosphere.a \
-headers ./include/ \
-library ./lib_aarch64-apple-ios/libnoosphere.a \
-headers ./include/ \
-output ./LibNoosphere.xcframework
fi
zip -r ./libnoosphere-apple-xcframework.zip ./LibNoosphere.xcframework
- uses: actions/upload-artifact@v3
with:
name: libnoosphere_apple_framework
path: ./libnoosphere-apple-xcframework.zip