Skip to content

Commit bd7f91e

Browse files
committed
ci: install llvm first
1 parent 0ac8c92 commit bd7f91e

File tree

1 file changed

+73
-73
lines changed

1 file changed

+73
-73
lines changed

.github/workflows/ci.yml

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,79 @@ jobs:
174174
with:
175175
apt-get: ${{ matrix.install }}
176176

177+
- name: Resolve LLVM Root
178+
id: resolve-llvm-root
179+
run: |
180+
set -x
181+
cd ..
182+
llvm_root=$(pwd)/third-party/llvm-project/install
183+
if [[ ${{ runner.os }} == 'Windows' ]]; then
184+
llvm_root=$(echo "$llvm_root" | sed 's/\\/\//g')
185+
llvm_root=$(echo $llvm_root | sed 's|^/d/|D:/|')
186+
echo "$llvm_root"
187+
fi
188+
echo -E "llvm-root=$llvm_root" >> $GITHUB_OUTPUT
189+
190+
- name: Cached LLVM Binaries
191+
id: llvm-cache
192+
uses: actions/cache@v4
193+
with:
194+
path: ${{ steps.resolve-llvm-root.outputs.llvm-root }}
195+
key: ${{ matrix.llvm-cache-key }}
196+
197+
- name: Download LLVM Binaries
198+
id: llvm-download
199+
if: steps.llvm-cache.outputs.cache-hit != 'true'
200+
run: |
201+
set -x
202+
url=https://mrdocs.com/llvm+clang/${{ matrix.llvm-archive-filename }}
203+
http_status=$(curl -s -o /dev/null -w "%{http_code}" -I "$url")
204+
if [ "$http_status" -eq 200 ]; then
205+
found="true"
206+
echo "found=$found" >> $GITHUB_OUTPUT
207+
curl -L -o ${{ matrix.llvm-archive-filename }} "$url"
208+
install_prefix=$(pwd)/../third-party/llvm-project/install
209+
mkdir -p $install_prefix
210+
if [[ ${{ matrix.llvm-archive-extension }} == '7z' ]]; then
211+
7z x ${{ matrix.llvm-archive-filename }} -o$install_prefix
212+
else
213+
tar -xjf ${{ matrix.llvm-archive-filename }} -C $install_prefix
214+
fi
215+
if [[ $(ls -1 $install_prefix | wc -l) -eq 1 ]]; then
216+
single_dir=$(ls -1 $install_prefix)
217+
if [[ -d $install_prefix/$single_dir ]]; then
218+
mv $install_prefix/$single_dir/* $install_prefix/
219+
rmdir $install_prefix/$single_dir
220+
fi
221+
fi
222+
else
223+
found="false"
224+
echo "found=$found" >> $GITHUB_OUTPUT
225+
fi
226+
227+
- name: Install LLVM
228+
uses: alandefreitas/cpp-actions/cmake-workflow@v1.8.7
229+
if: steps.llvm-cache.outputs.cache-hit != 'true' && steps.llvm-download.outputs.found != 'true'
230+
with:
231+
cmake-version: '>=3.26'
232+
source-dir: ../third-party/llvm-project/llvm
233+
git-repository: https://github.com/llvm/llvm-project.git
234+
git-tag: ${{ matrix.llvm-hash }}
235+
download-dir: ../third-party/llvm-project
236+
patches: |
237+
./third-party/llvm/CMakePresets.json
238+
./third-party/llvm/CMakeUserPresets.json
239+
build-dir: ${sourceDir}/llvm/build
240+
preset: ${{ matrix.llvm-build-preset }}
241+
build-type: ${{ matrix.build-type }}
242+
cc: ${{ steps.setup-cpp.outputs.cc }}
243+
cxx: ${{ steps.setup-cpp.outputs.cxx }}
244+
generator: Ninja
245+
install: true
246+
install-prefix: ${sourceDir}/../install
247+
run-tests: false
248+
trace-commands: true
249+
177250
- name: Install Duktape
178251
uses: alandefreitas/cpp-actions/cmake-workflow@v1.8.7
179252
with:
@@ -266,79 +339,6 @@ jobs:
266339
run-tests: false
267340
trace-commands: true
268341

269-
- name: Resolve LLVM Root
270-
id: resolve-llvm-root
271-
run: |
272-
set -x
273-
cd ..
274-
llvm_root=$(pwd)/third-party/llvm-project/install
275-
if [[ ${{ runner.os }} == 'Windows' ]]; then
276-
llvm_root=$(echo "$llvm_root" | sed 's/\\/\//g')
277-
llvm_root=$(echo $llvm_root | sed 's|^/d/|D:/|')
278-
echo "$llvm_root"
279-
fi
280-
echo -E "llvm-root=$llvm_root" >> $GITHUB_OUTPUT
281-
282-
- name: Cached LLVM Binaries
283-
id: llvm-cache
284-
uses: actions/cache@v4
285-
with:
286-
path: ${{ steps.resolve-llvm-root.outputs.llvm-root }}
287-
key: ${{ matrix.llvm-cache-key }}
288-
289-
- name: Download LLVM Binaries
290-
id: llvm-download
291-
if: steps.llvm-cache.outputs.cache-hit != 'true'
292-
run: |
293-
set -x
294-
url=https://mrdocs.com/llvm+clang/${{ matrix.llvm-archive-filename }}
295-
http_status=$(curl -s -o /dev/null -w "%{http_code}" -I "$url")
296-
if [ "$http_status" -eq 200 ]; then
297-
found="true"
298-
echo "found=$found" >> $GITHUB_OUTPUT
299-
curl -L -o ${{ matrix.llvm-archive-filename }} "$url"
300-
install_prefix=$(pwd)/../third-party/llvm-project/install
301-
mkdir -p $install_prefix
302-
if [[ ${{ matrix.llvm-archive-extension }} == '7z' ]]; then
303-
7z x ${{ matrix.llvm-archive-filename }} -o$install_prefix
304-
else
305-
tar -xjf ${{ matrix.llvm-archive-filename }} -C $install_prefix
306-
fi
307-
if [[ $(ls -1 $install_prefix | wc -l) -eq 1 ]]; then
308-
single_dir=$(ls -1 $install_prefix)
309-
if [[ -d $install_prefix/$single_dir ]]; then
310-
mv $install_prefix/$single_dir/* $install_prefix/
311-
rmdir $install_prefix/$single_dir
312-
fi
313-
fi
314-
else
315-
found="false"
316-
echo "found=$found" >> $GITHUB_OUTPUT
317-
fi
318-
319-
- name: Install LLVM
320-
uses: alandefreitas/cpp-actions/cmake-workflow@v1.8.7
321-
if: steps.llvm-cache.outputs.cache-hit != 'true' && steps.llvm-download.outputs.found != 'true'
322-
with:
323-
cmake-version: '>=3.26'
324-
source-dir: ../third-party/llvm-project/llvm
325-
git-repository: https://github.com/llvm/llvm-project.git
326-
git-tag: ${{ matrix.llvm-hash }}
327-
download-dir: ../third-party/llvm-project
328-
patches: |
329-
./third-party/llvm/CMakePresets.json
330-
./third-party/llvm/CMakeUserPresets.json
331-
build-dir: ${sourceDir}/llvm/build
332-
preset: ${{ matrix.llvm-build-preset }}
333-
build-type: ${{ matrix.build-type }}
334-
cc: ${{ steps.setup-cpp.outputs.cc }}
335-
cxx: ${{ steps.setup-cpp.outputs.cxx }}
336-
generator: Ninja
337-
install: true
338-
install-prefix: ${sourceDir}/../install
339-
run-tests: false
340-
trace-commands: true
341-
342342
- name: Install Node.js
343343
uses: actions/setup-node@v4
344344
with:

0 commit comments

Comments
 (0)