Skip to content

Commit 141f25c

Browse files
authored
Merge pull request #121 from madsmtm/ci-extern-cache
Put macOS SDK and cargo-dinghy in CI cache
2 parents 94d2e62 + 4be904a commit 141f25c

File tree

1 file changed

+61
-42
lines changed

1 file changed

+61
-42
lines changed

.github/workflows/ci.yml

Lines changed: 61 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,53 @@ jobs:
137137
steps:
138138
- uses: actions/checkout@v2
139139

140+
- name: Cache external dependencies
141+
id: extern-cache
142+
uses: actions/cache@v2
143+
with:
144+
# We could have just cached build-files, and then rerun the build tool
145+
# every time, letting it figure out what's changed. However, this has
146+
# several problems:
147+
#
148+
# - GNUStep-Base ./configure invalidates the cache, which makes it
149+
# very hard to know when to rebuild and when not to.
150+
# - We don't want to rebuild cargo-dinghy every time the ~/.cargo
151+
# folder is invalidated.
152+
#
153+
# So instead we just place the final outputs in ~/extern, and cache
154+
# them there:
155+
# - bin/cargo-dinghy
156+
# - lib/libobjc.so
157+
# - lib/libgnustep-base.so
158+
# - include/Foundation/*
159+
# - include/objc/*
160+
# - sdk/...
161+
path: |
162+
~/extern/bin
163+
~/extern/lib
164+
~/extern/include
165+
~/extern/sdk
166+
# Change this key if we start caching more things
167+
key: ${{ matrix.name }}-extern-v1
168+
169+
- name: Setup environment
170+
# These add to PATH-like variables, so they can always be set
171+
run: |
172+
mkdir -p $HOME/extern/bin
173+
mkdir -p $HOME/extern/lib
174+
mkdir -p $HOME/extern/include
175+
echo "PATH=$HOME/extern/bin:$PATH" >> $GITHUB_ENV
176+
echo "LIBRARY_PATH=$HOME/extern/lib:$LIBRARY_PATH" >> $GITHUB_ENV
177+
echo "LD_LIBRARY_PATH=$HOME/extern/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
178+
echo "CPATH=$HOME/extern/include:$CPATH" >> $GITHUB_ENV
179+
# Debug print these
180+
ls -al $HOME/extern/*
181+
182+
- name: Setup SDK environment
183+
if: matrix.sdk
184+
# This changes a variable, so is only set when a custom SDK is used
185+
run: echo "SDKROOT=$HOME/extern/sdk" >> $GITHUB_ENV
186+
140187
- name: Install Clang
141188
if: contains(matrix.os, 'ubuntu')
142189
run: sudo apt-get -y install clang
@@ -151,7 +198,7 @@ jobs:
151198
libxml2-dev:i386 libicu-dev:i386
152199
153200
- name: Download different macOS SDK
154-
if: matrix.sdk
201+
if: matrix.sdk && steps.extern-cache.outputs.cache-hit != 'true'
155202
# macOS SDKs:
156203
# - https://github.com/alexey-lysiuk/macos-sdk
157204
# - https://github.com/phracker/MacOSX-SDKs
@@ -163,71 +210,41 @@ jobs:
163210
run: |
164211
wget https://github.com/alexey-lysiuk/macos-sdk/releases/download/${{ matrix.sdk }}/MacOSX${{ matrix.sdk }}.tar.bz2
165212
tar -xyf MacOSX${{ matrix.sdk }}.tar.bz2
166-
echo "SDKROOT=$(pwd)/MacOSX${{ matrix.sdk }}.sdk" >> $GITHUB_ENV
167-
168-
- name: Cache GNUStep
169-
if: contains(matrix.os, 'ubuntu')
170-
id: cache-gnustep
171-
uses: actions/cache@v2
172-
with:
173-
# Ideally I would have just cached build-files, and then rerun make
174-
# every time, letting it figure out what's changed. But GNUStep-Base
175-
# ./configure invalidates the cache, which makes it very hard to
176-
# know when to rebuild and when not to.
177-
# So instead we just cache the final output:
178-
# - lib/libobjc.so
179-
# - lib/libgnustep-base.so
180-
# - include/Foundation/*
181-
# - include/objc/*
182-
# - ...
183-
path: |
184-
~/gnustep/lib
185-
~/gnustep/include
186-
key: ${{ matrix.name }}-gnustep-libobjc2_1.9-make_2.9.0-base_1.28.0
187-
188-
- name: Setup GNUStep environment
189-
if: contains(matrix.os, 'ubuntu')
190-
run: |
191-
mkdir -p $HOME/gnustep
192-
echo "PATH=$HOME/gnustep/bin:$PATH" >> $GITHUB_ENV
193-
echo "LIBRARY_PATH=$HOME/gnustep/lib:$LIBRARY_PATH" >> $GITHUB_ENV
194-
echo "LD_LIBRARY_PATH=$HOME/gnustep/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
195-
echo "CPATH=$HOME/gnustep/include:$CPATH" >> $GITHUB_ENV
196-
ls -al ~/gnustep/* || true # Ignore failures
213+
mv MacOSX${{ matrix.sdk }}.sdk $HOME/extern/sdk
197214
198215
- name: Install Make and Cmake
199-
if: contains(matrix.os, 'ubuntu') && steps.cache-gnustep.outputs.cache-hit != 'true'
216+
if: contains(matrix.os, 'ubuntu') && steps.extern-cache.outputs.cache-hit != 'true'
200217
run: sudo apt-get -y install make cmake
201218

202219
- name: Install GNUStep libobjc2 v1.9
203-
if: contains(matrix.os, 'ubuntu') && steps.cache-gnustep.outputs.cache-hit != 'true'
220+
if: contains(matrix.os, 'ubuntu') && steps.extern-cache.outputs.cache-hit != 'true'
204221
run: |
205222
wget https://github.com/gnustep/libobjc2/archive/refs/tags/v1.9.tar.gz
206223
tar -xzf v1.9.tar.gz
207224
mkdir -p libobjc2-1.9/build
208225
cd libobjc2-1.9/build
209-
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=$HOME/gnustep -DTESTS=OFF ..
226+
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=$HOME/extern -DTESTS=OFF ..
210227
make install
211228
212229
- name: Install GNUStep make
213-
if: contains(matrix.os, 'ubuntu') && steps.cache-gnustep.outputs.cache-hit != 'true'
230+
if: contains(matrix.os, 'ubuntu') && steps.extern-cache.outputs.cache-hit != 'true'
214231
run: |
215232
wget https://github.com/gnustep/tools-make/archive/refs/tags/make-2_9_0.tar.gz
216233
tar -xzf make-2_9_0.tar.gz
217234
mkdir -p tools-make-make-2_9_0/build
218235
cd tools-make-make-2_9_0/build
219-
../configure --prefix=$HOME/gnustep --with-library-combo=ng-gnu-gnu
236+
../configure --prefix=$HOME/extern --with-library-combo=ng-gnu-gnu
220237
make install
221238
222239
- name: Install GNUStep-Base
223-
if: contains(matrix.os, 'ubuntu') && steps.cache-gnustep.outputs.cache-hit != 'true'
240+
if: contains(matrix.os, 'ubuntu') && steps.extern-cache.outputs.cache-hit != 'true'
224241
run: |
225242
wget https://github.com/gnustep/libs-base/archive/refs/tags/base-1_28_0.tar.gz
226243
tar -xzf base-1_28_0.tar.gz
227244
cd libs-base-base-1_28_0
228-
./configure --prefix=$HOME/gnustep --disable-tls --disable-xslt ${{ matrix.platform.configureflags }}
245+
./configure --prefix=$HOME/extern --disable-tls --disable-xslt ${{ matrix.platform.configureflags }}
229246
make install
230-
ls -al $HOME/gnustep/*
247+
ls -al $HOME/extern/*
231248
232249
- name: Cache Rust
233250
uses: actions/cache@v2
@@ -247,11 +264,13 @@ jobs:
247264
# Allows installing for a different base target
248265
target: ${{ matrix.rust.target || matrix.target }}
249266

267+
- name: Install Cargo Dinghy
268+
if: matrix.dinghy && steps.extern-cache.outputs.cache-hit != 'true'
269+
run: cargo install cargo-dinghy --version=^0.4 --root=$HOME/extern --target=x86_64-apple-darwin
270+
250271
- name: Run Cargo Dinghy
251272
if: matrix.dinghy
252273
run: |
253-
cargo install cargo-dinghy --target x86_64-apple-darwin
254-
255274
# Launch the simulator
256275
xcrun simctl list runtimes
257276
RUNTIME_ID=$(xcrun simctl list runtimes | grep iOS | cut -d ' ' -f 7 | tail -1)

0 commit comments

Comments
 (0)