-
Notifications
You must be signed in to change notification settings - Fork 132
1831 lines (1575 loc) · 65.1 KB
/
ci.yml
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Zephyr SDK Continuous Integration Workflow
name: CI
on:
push:
branches:
- main
- topic-*
- v*-branch
pull_request_target:
branches:
- main
- topic-*
- v*-branch
workflow_call:
secrets:
AWS_CACHE_SDK_ACCESS_KEY_ID:
required: true
AWS_CACHE_SDK_SECRET_ACCESS_KEY:
required: true
workflow_dispatch:
inputs:
zephyr-ref:
description: 'Zephyr Ref (branch, tag, SHA, ...)'
required: true
default: collab-sdk-0.18-dev
host:
description: 'Host'
type: choice
required: true
options:
- all
- linux-x86_64
- linux-aarch64
- macos-x86_64
- macos-aarch64
- windows-x86_64
target:
description: 'Target'
type: choice
required: true
options:
- all
- aarch64-zephyr-elf
- arc64-zephyr-elf
- arc-zephyr-elf
- arm-zephyr-eabi
- microblazeel-zephyr-elf
- mips-zephyr-elf
- nios2-zephyr-elf
- riscv64-zephyr-elf
- sparc-zephyr-elf
- x86_64-zephyr-elf
- xtensa-amd_acp_6_0_adsp_zephyr-elf
- xtensa-dc233c_zephyr-elf
- xtensa-espressif_esp32_zephyr-elf
- xtensa-espressif_esp32s2_zephyr-elf
- xtensa-espressif_esp32s3_zephyr-elf
- xtensa-intel_ace15_mtpm_zephyr-elf
- xtensa-intel_ace30_ptl_zephyr-elf
- xtensa-intel_tgl_adsp_zephyr-elf
- xtensa-mtk_mt8195_adsp_zephyr-elf
- xtensa-nxp_imx_adsp_zephyr-elf
- xtensa-nxp_imx8m_adsp_zephyr-elf
- xtensa-nxp_imx8ulp_adsp_zephyr-elf
- xtensa-nxp_rt500_adsp_zephyr-elf
- xtensa-nxp_rt600_adsp_zephyr-elf
- xtensa-nxp_rt700_hifi1_zephyr-elf
- xtensa-nxp_rt700_hifi4_zephyr-elf
- xtensa-sample_controller_zephyr-elf
- xtensa-sample_controller32_zephyr-elf
debug:
description: 'Debug'
type: choice
required: true
options:
- none
- toolchain-pre
- toolchain-post
- hosttools
concurrency:
group: ${{ github.event_name == 'workflow_dispatch' && github.run_id || github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name != 'workflow_dispatch' }}
env:
BUG_URL: 'https://github.com/zephyrproject-rtos/sdk-ng/issues'
BUNDLE_NAME: Zephyr SDK
BUNDLE_PREFIX: zephyr-sdk
ZEPHYR_REF: collab-sdk-0.18-dev
jobs:
# Setup
setup:
name: Setup
runs-on: ubuntu-20.04
outputs:
hosts: ${{ steps.generate-matrix.outputs.hosts }}
targets: ${{ steps.generate-matrix.outputs.targets }}
testenvs: ${{ steps.generate-matrix.outputs.testenvs }}
debug: ${{ steps.generate-matrix.outputs.debug }}
steps:
- name: Check out source code
if: ${{ github.event_name != 'pull_request_target' }}
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Check out source code (pull request)
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
persist-credentials: false
- name: Generate version file
run: |
VERSION=$(git describe --tags --match 'v*')
echo "${VERSION:1}" > version
- name: Upload version file
uses: actions/upload-artifact@v4
with:
name: version
path: version
- name: Generate matrix
id: generate-matrix
run: |
# Set build configurations
if [ "${{ github.event_name }}" == "pull_request_target" ]; then
# Set configurations based on the pull request labels
${{ contains(github.event.pull_request.labels.*.name, 'ci-linux-x86_64') }} && build_host_linux_x86_64="y"
${{ contains(github.event.pull_request.labels.*.name, 'ci-linux-aarch64') }} && build_host_linux_aarch64="y"
${{ contains(github.event.pull_request.labels.*.name, 'ci-macos-x86_64') }} && build_host_macos_x86_64="y"
${{ contains(github.event.pull_request.labels.*.name, 'ci-macos-aarch64') }} && build_host_macos_aarch64="y"
${{ contains(github.event.pull_request.labels.*.name, 'ci-windows-x86_64') }} && build_host_windows_x86_64="y"
# Build all targets for pull requests
build_target_all="y"
# Set debug mode based on the pull request labels
${{ contains(github.event.pull_request.labels.*.name, 'debug-toolchain-pre') }} && MATRIX_DEBUG="toolchain-pre"
${{ contains(github.event.pull_request.labels.*.name, 'debug-toolchain-post') }} && MATRIX_DEBUG="toolchain-post"
${{ contains(github.event.pull_request.labels.*.name, 'debug-hosttools') }} && MATRIX_DEBUG="hosttools"
elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
# Set configurations based on the user selection
case '${{ github.event.inputs.host }}' in
all) build_host_all="y";;
linux-x86_64) build_host_linux_x86_64="y";;
linux-aarch64) build_host_linux_aarch64="y";;
macos-x86_64) build_host_macos_x86_64="y";;
macos-aarch64) build_host_macos_aarch64="y";;
windows-x86_64) build_host_windows_x86_64="y";;
esac
case '${{ github.event.inputs.target }}' in
all) build_target_all="y";;
aarch64-zephyr-elf) build_target_aarch64_zephyr_elf="y";;
arc64-zephyr-elf) build_target_arc64_zephyr_elf="y";;
arc-zephyr-elf) build_target_arc_zephyr_elf="y";;
arm-zephyr-eabi) build_target_arm_zephyr_eabi="y";;
microblazeel-zephyr-elf) build_target_microblazeel_zephyr_elf="y";;
mips-zephyr-elf) build_target_mips_zephyr_elf="y";;
nios2-zephyr-elf) build_target_nios2_zephyr_elf="y";;
riscv64-zephyr-elf) build_target_riscv64_zephyr_elf="y";;
sparc-zephyr-elf) build_target_sparc_zephyr_elf="y";;
x86_64-zephyr-elf) build_target_x86_64_zephyr_elf="y";;
xtensa-amd_acp_6_0_adsp_zephyr-elf) build_target_xtensa_amd_acp_6_0_adsp_zephyr_elf="y";;
xtensa-dc233c_zephyr-elf) build_target_xtensa_dc233c_zephyr_elf="y";;
xtensa-espressif_esp32_zephyr-elf) build_target_xtensa_espressif_esp32_zephyr_elf="y";;
xtensa-espressif_esp32s2_zephyr-elf) build_target_xtensa_espressif_esp32s2_zephyr_elf="y";;
xtensa-espressif_esp32s3_zephyr-elf) build_target_xtensa_espressif_esp32s3_zephyr_elf="y";;
xtensa-intel_ace15_mtpm_zephyr-elf) build_target_xtensa_intel_ace15_mtpm_zephyr_elf="y";;
xtensa-intel_ace30_ptl_zephyr-elf) build_target_xtensa_intel_ace30_ptl_zephyr_elf="y";;
xtensa-intel_tgl_adsp_zephyr-elf) build_target_xtensa_intel_tgl_adsp_zephyr_elf="y";;
xtensa-mtk_mt8195_adsp_zephyr-elf) build_target_xtensa_mtk_mt8195_adsp_zephyr_elf="y";;
xtensa-nxp_imx_adsp_zephyr-elf) build_target_xtensa_nxp_imx_adsp_zephyr_elf="y";;
xtensa-nxp_imx8m_adsp_zephyr-elf) build_target_xtensa_nxp_imx8m_adsp_zephyr_elf="y";;
xtensa-nxp_imx8ulp_adsp_zephyr-elf) build_target_xtensa_nxp_imx8ulp_adsp_zephyr_elf="y";;
xtensa-nxp_rt500_adsp_zephyr-elf) build_target_xtensa_nxp_rt500_adsp_zephyr_elf="y";;
xtensa-nxp_rt600_adsp_zephyr-elf) build_target_xtensa_nxp_rt600_adsp_zephyr_elf="y";;
xtensa-nxp_rt700_hifi1_zephyr-elf) build_target_xtensa_nxp_rt700_hifi1_zephyr_elf="y";;
xtensa-nxp_rt700_hifi4_zephyr-elf) build_target_xtensa_nxp_rt700_hifi4_zephyr_elf="y";;
xtensa-sample_controller_zephyr-elf) build_target_xtensa_sample_controller_zephyr_elf="y";;
xtensa-sample_controller32_zephyr-elf) build_target_xtensa_sample_controller32_zephyr_elf="y";;
esac
MATRIX_DEBUG="${{ github.event.inputs.debug }}"
else
# Build all for pushes and releases
build_host_all="y"
build_target_all="y"
fi
if [ "${build_host_all}" == "y" ]; then
build_host_linux_x86_64="y"
build_host_linux_aarch64="y"
build_host_macos_x86_64="y"
build_host_macos_aarch64="y"
build_host_windows_x86_64="y"
fi
if [ "${build_target_all}" == "y" ]; then
build_target_aarch64_zephyr_elf="y"
build_target_arc64_zephyr_elf="y"
build_target_arc_zephyr_elf="y"
build_target_arm_zephyr_eabi="y"
build_target_microblazeel_zephyr_elf="y"
build_target_mips_zephyr_elf="y"
build_target_nios2_zephyr_elf="y"
build_target_riscv64_zephyr_elf="y"
build_target_sparc_zephyr_elf="y"
build_target_x86_64_zephyr_elf="y"
build_target_xtensa_amd_acp_6_0_adsp_zephyr_elf="y"
build_target_xtensa_dc233c_zephyr_elf="y"
build_target_xtensa_espressif_esp32_zephyr_elf="y"
build_target_xtensa_espressif_esp32s2_zephyr_elf="y"
build_target_xtensa_espressif_esp32s3_zephyr_elf="y"
build_target_xtensa_intel_ace15_mtpm_zephyr_elf="y"
build_target_xtensa_intel_ace30_ptl_zephyr_elf="y"
build_target_xtensa_intel_tgl_adsp_zephyr_elf="y"
build_target_xtensa_mtk_mt8195_adsp_zephyr_elf="y"
build_target_xtensa_nxp_imx_adsp_zephyr_elf="y"
build_target_xtensa_nxp_imx8m_adsp_zephyr_elf="y"
build_target_xtensa_nxp_imx8ulp_adsp_zephyr_elf="y"
build_target_xtensa_nxp_rt500_adsp_zephyr_elf="y"
build_target_xtensa_nxp_rt600_adsp_zephyr_elf="y"
build_target_xtensa_nxp_rt700_hifi1_zephyr_elf="y"
build_target_xtensa_nxp_rt700_hifi4_zephyr_elf="y"
build_target_xtensa_sample_controller_zephyr_elf="y"
build_target_xtensa_sample_controller32_zephyr_elf="y"
fi
# Build 'linux_x86_64' by default if no host is selected
list_build_host=(${!build_host_@})
[ "${#list_build_host[@]}" == "0" ] && build_host_linux_x86_64="y"
# Generate host list
MATRIX_HOSTS='['
if [ "${build_host_linux_x86_64}" == "y" ]; then
MATRIX_HOSTS+='{
"name": "linux-x86_64",
"runner": "zephyr-runner-v2-linux-x64-4xlarge",
"container": "ghcr.io/zephyrproject-rtos/sdk-build:v1.3.6",
"archive": "tar.xz"
},'
fi
if [ "${build_host_linux_aarch64}" == "y" ]; then
MATRIX_HOSTS+='{
"name": "linux-aarch64",
"runner": "zephyr-runner-v2-linux-arm64-4xlarge",
"container": "ghcr.io/zephyrproject-rtos/sdk-build:v1.3.6",
"archive": "tar.xz"
},'
fi
if [ "${build_host_macos_x86_64}" == "y" ]; then
MATRIX_HOSTS+='{
"name": "macos-x86_64",
"runner": "zephyr-runner-v2-macos-arm64-2xlarge",
"container": "",
"archive": "tar.xz"
},'
fi
if [ "${build_host_macos_aarch64}" == "y" ]; then
MATRIX_HOSTS+='{
"name": "macos-aarch64",
"runner": "zephyr-runner-v2-macos-arm64-2xlarge",
"container": "",
"archive": "tar.xz"
},'
fi
if [ "${build_host_windows_x86_64}" == "y" ]; then
MATRIX_HOSTS+='{
"name": "windows-x86_64",
"runner": "zephyr-runner-v2-linux-x64-4xlarge",
"container": "ghcr.io/zephyrproject-rtos/sdk-build:v1.3.6",
"archive": "7z"
},'
fi
MATRIX_HOSTS+=']'
# Generate target list
MATRIX_TARGETS='['
[ "${build_target_aarch64_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"aarch64-zephyr-elf",'
[ "${build_target_arc64_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"arc64-zephyr-elf",'
[ "${build_target_arc_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"arc-zephyr-elf",'
[ "${build_target_arm_zephyr_eabi}" == "y" ] && MATRIX_TARGETS+='"arm-zephyr-eabi",'
[ "${build_target_microblazeel_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"microblazeel-zephyr-elf",'
[ "${build_target_mips_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"mips-zephyr-elf",'
[ "${build_target_nios2_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"nios2-zephyr-elf",'
[ "${build_target_riscv64_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"riscv64-zephyr-elf",'
[ "${build_target_sparc_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"sparc-zephyr-elf",'
[ "${build_target_x86_64_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"x86_64-zephyr-elf",'
[ "${build_target_xtensa_amd_acp_6_0_adsp_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-amd_acp_6_0_adsp_zephyr-elf",'
[ "${build_target_xtensa_dc233c_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-dc233c_zephyr-elf",'
[ "${build_target_xtensa_espressif_esp32_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-espressif_esp32_zephyr-elf",'
[ "${build_target_xtensa_espressif_esp32s2_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-espressif_esp32s2_zephyr-elf",'
[ "${build_target_xtensa_espressif_esp32s3_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-espressif_esp32s3_zephyr-elf",'
[ "${build_target_xtensa_intel_ace15_mtpm_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-intel_ace15_mtpm_zephyr-elf",'
[ "${build_target_xtensa_intel_ace30_ptl_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-intel_ace30_ptl_zephyr-elf",'
[ "${build_target_xtensa_intel_tgl_adsp_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-intel_tgl_adsp_zephyr-elf",'
[ "${build_target_xtensa_mtk_mt8195_adsp_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-mtk_mt8195_adsp_zephyr-elf",'
[ "${build_target_xtensa_nxp_imx_adsp_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-nxp_imx_adsp_zephyr-elf",'
[ "${build_target_xtensa_nxp_imx8m_adsp_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-nxp_imx8m_adsp_zephyr-elf",'
[ "${build_target_xtensa_nxp_imx8ulp_adsp_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-nxp_imx8ulp_adsp_zephyr-elf",'
[ "${build_target_xtensa_nxp_rt500_adsp_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-nxp_rt500_adsp_zephyr-elf",'
[ "${build_target_xtensa_nxp_rt600_adsp_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-nxp_rt600_adsp_zephyr-elf",'
[ "${build_target_xtensa_nxp_rt700_hifi1_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-nxp_rt700_hifi1_zephyr-elf",'
[ "${build_target_xtensa_nxp_rt700_hifi4_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-nxp_rt700_hifi4_zephyr-elf",'
[ "${build_target_xtensa_sample_controller_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-sample_controller_zephyr-elf",'
[ "${build_target_xtensa_sample_controller32_zephyr_elf}" == "y" ] && MATRIX_TARGETS+='"xtensa-sample_controller32_zephyr-elf",'
MATRIX_TARGETS+=']'
# Generate test environment list
MATRIX_TESTENVS='['
if [ "${build_host_linux_x86_64}" == "y" ]; then
MATRIX_TESTENVS+='{
"name": "ubuntu-20.04-x86_64",
"runner": "zephyr-runner-v2-linux-x64-4xlarge",
"container": "ghcr.io/zephyrproject-rtos/ci:master",
"bundle-host": "linux-x86_64",
"bundle-archive": "tar.xz"
},'
fi
if [ "${build_host_linux_aarch64}" == "y" ]; then
MATRIX_TESTENVS+='{
"name": "ubuntu-20.04-aarch64",
"runner": "zephyr-runner-v2-linux-arm64-4xlarge",
"container": "ghcr.io/zephyrproject-rtos/ci:master",
"bundle-host": "linux-aarch64",
"bundle-archive": "tar.xz"
},'
fi
if [ "${build_host_macos_x86_64}" == "y" ]; then
MATRIX_TESTENVS+='{
"name": "macos-11-x86_64",
"runner": "zephyr-runner-v2-macos-arm64-2xlarge",
"container": "",
"bundle-host": "macos-x86_64",
"bundle-archive": "tar.xz"
},'
fi
if [ "${build_host_macos_aarch64}" == "y" ]; then
MATRIX_TESTENVS+='{
"name": "macos-11-aarch64",
"runner": "zephyr-runner-v2-macos-arm64-2xlarge",
"container": "",
"bundle-host": "macos-aarch64",
"bundle-archive": "tar.xz"
},'
fi
if [ "${build_host_windows_x86_64}" == "y" ]; then
MATRIX_TESTENVS+='{
"name": "windows-2019-x86_64",
"runner": "zephyr-runner-v2-windows-x64-2xlarge",
"container": "",
"bundle-host": "windows-x86_64",
"bundle-archive": "7z"
},'
fi
MATRIX_TESTENVS+=']'
# Escape control characters because GitHub Actions
MATRIX_HOSTS="${MATRIX_HOSTS//'%'/''}"
MATRIX_HOSTS="${MATRIX_HOSTS//$'\n'/''}"
MATRIX_HOSTS="${MATRIX_HOSTS//$'\r'/''}"
MATRIX_TARGETS="${MATRIX_TARGETS//'%'/''}"
MATRIX_TARGETS="${MATRIX_TARGETS//$'\n'/''}"
MATRIX_TARGETS="${MATRIX_TARGETS//$'\r'/''}"
MATRIX_TESTENVS="${MATRIX_TESTENVS//'%'/''}"
MATRIX_TESTENVS="${MATRIX_TESTENVS//$'\n'/''}"
MATRIX_TESTENVS="${MATRIX_TESTENVS//$'\r'/''}"
# Remove trailing comma
MATRIX_HOSTS=$(echo "${MATRIX_HOSTS}" | sed -zr 's/,([^,]*$)/\1/')
MATRIX_TARGETS=$(echo "${MATRIX_TARGETS}" | sed -zr 's/,([^,]*$)/\1/')
MATRIX_TESTENVS=$(echo "${MATRIX_TESTENVS}" | sed -zr 's/,([^,]*$)/\1/')
# Output matrix variables
echo "hosts=${MATRIX_HOSTS}" >> $GITHUB_OUTPUT
echo "targets=${MATRIX_TARGETS}" >> $GITHUB_OUTPUT
echo "testenvs=${MATRIX_TESTENVS}" >> $GITHUB_OUTPUT
echo "debug=${MATRIX_DEBUG}" >> $GITHUB_OUTPUT
# Prepare configuration report
CONFIG_REPORT=${RUNNER_TEMP}/config-report.txt
echo "Hosts:" > ${CONFIG_REPORT}
echo "$(echo "${MATRIX_HOSTS}" | jq)" >> ${CONFIG_REPORT}
echo "" >> ${CONFIG_REPORT}
echo "Targets:" >> ${CONFIG_REPORT}
echo "$(echo "${MATRIX_TARGETS}" | jq)" >> ${CONFIG_REPORT}
echo "" >> ${CONFIG_REPORT}
echo "Test Environments:" >> ${CONFIG_REPORT}
echo "$(echo "${MATRIX_TESTENVS}" | jq)" >> ${CONFIG_REPORT}
CONFIG_REPORT_CONTENT=$(cat ${CONFIG_REPORT})
CONFIG_REPORT_CONTENT="${CONFIG_REPORT_CONTENT//'%'/'%25'}"
CONFIG_REPORT_CONTENT="${CONFIG_REPORT_CONTENT//$'\n'/'%0A'}"
CONFIG_REPORT_CONTENT="${CONFIG_REPORT_CONTENT//$'\r'/'%0D'}"
echo "::notice:: ${CONFIG_REPORT_CONTENT}"
# Build GNU toolchain
build-gnu-toolchain:
name: GNU Toolchain ${{ matrix.target }} (${{ matrix.host.name }})
needs: setup
runs-on:
group: ${{ matrix.host.runner }}
container: ${{ matrix.host.container }}
timeout-minutes: 720
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
host: ${{ fromJSON(needs.setup.outputs.hosts) }}
target: ${{ fromJSON(needs.setup.outputs.targets) }}
steps:
# - name: echo-default-env-variables
# run: |
# whoami
# echo "Shell: ${SHELL}"
# echo "Home: ${HOME}"
# echo "RUNNER_NAME: ${RUNNER_NAME}"
# echo "RUNNER_TEMP: ${RUNNER_TEMP}"
# echo "GITHUB_WORKFLOW: ${GITHUB_WORKFLOW}"
# echo "GITHUB_ACTIONS: ${GITHUB_ACTIONS}"
# echo "GITHUB_ACTOR: ${GITHUB_ACTOR}"
# echo "GITHUB_REPOSITORY: ${GITHUB_REPOSITORY}"
# echo "GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME}"
# echo "GITHUB_WORKSPACE: ${GITHUB_WORKSPACE}"
# echo "GITHUB_SHA: ${GITHUB_SHA}"
# echo "GITHUB_REF: ${GITHUB_REF}"
- name: Set up build environment (Linux)
if: ${{ runner.os == 'Linux' }}
run: |
# DEBUG++
whoami
# DEBUG--
# Create workspace directory
WORKSPACE="${RUNNER_TEMP}/workspace"
sudo mkdir -p ${WORKSPACE}
# Allow non-root access to the working directories
sudo chmod -R 777 ${GITHUB_WORKSPACE}
sudo chmod -R 777 ${RUNNER_TEMP}
# Install common dependencies
sudo apt-get update
sudo apt-get install -y autoconf automake bison flex gettext \
help2man libboost-dev libboost-regex-dev \
libncurses5-dev libtool-bin libtool-doc \
pkg-config texinfo p7zip
# Install dependencies for cross compilation
if [ "${{ matrix.host.name }}" == "windows-x86_64" ]; then
# Make MinGW-w64 win32 cross toolchain available in PATH
echo "/opt/mingw-w64-win32/bin" >> $GITHUB_PATH
export PATH="/opt/mingw-w64-win32/bin:$PATH"
# Build and install libboost-regex for MinGW-w64 host
## Check out Boost library source code
mkdir -p ${WORKSPACE}/boost
pushd ${WORKSPACE}/boost
git clone \
--branch boost-1.73.0 --depth 1 \
https://github.com/boostorg/boost.git \
src
cd src
git submodule update --init --depth 1
## Bootstrap boost library build system with MinGW-w64 compiler
./bootstrap.sh --with-toolset=gcc --with-libraries=regex --without-icu
sed -i \
's/using gcc ;/using gcc : mingw : x86_64-w64-mingw32-g++ ;/g' \
project-config.jam
## Build and install boost-regex library
./b2 install \
toolset=gcc-mingw link=static threading=multi variant=release \
--prefix=/usr/x86_64-w64-mingw32
## Clean up to reduce disk usage
popd
rm -rf ${WORKSPACE}/boost
fi
# Set environment variables
echo "TAR=tar" >> $GITHUB_ENV
echo "WORKSPACE=${WORKSPACE}" >> $GITHUB_ENV
- name: Set up build environment (macOS)
if: ${{ runner.os == 'macOS' }}
run: |
# Create case-sensitive workspace volume for macOS
hdiutil create ${RUNNER_TEMP}/Workspace.sparseimage \
-volname Workspace -type SPARSE -size 150g -fs HFSX
hdiutil mount ${RUNNER_TEMP}/Workspace.sparseimage -mountpoint ${WORKSPACE}
# Install Python 3.10 (temporary until the sdk-build-macos image is
# updated)
brew install [email protected]
# Install dependencies for cross compilation
if [ "${{ matrix.host.name }}" == "macos-x86_64" ]; then
# Make crosskit available in PATH
echo "${GITHUB_WORKSPACE}/crosskit/crosskit-x86_64-apple-darwin/scripts" >> $GITHUB_PATH
fi
# Make Python 3.10 available in PATH
echo "${HOMEBREW_PREFIX}/opt/[email protected]/bin" >> $GITHUB_PATH
# Set environment variables
echo "TAR=gtar" >> $GITHUB_ENV
echo "WORKSPACE=${WORKSPACE}" >> $GITHUB_ENV
- name: Check out source code
if: ${{ github.event_name != 'pull_request_target' }}
uses: actions/checkout@v4
with:
submodules: recursive
persist-credentials: false
- name: Check out source code (pull request)
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
submodules: recursive
persist-credentials: false
- name: Build crosstool-ng
run: |
# Configure macOS build environment
if [ "$RUNNER_OS" == "macOS" ]; then
export PATH="$PATH:${HOMEBREW_PREFIX}/opt/binutils/bin"
export CPPFLAGS="-I${HOMEBREW_PREFIX}/opt/ncurses/include -I${HOMEBREW_PREFIX}/opt/gettext/include"
export LDFLAGS="-L${HOMEBREW_PREFIX}/opt/ncurses/lib -L${HOMEBREW_PREFIX}/opt/gettext/lib"
fi
# Create build directory
pushd ${WORKSPACE}
mkdir -p crosstool-ng-build
cd crosstool-ng-build
# Bootstrap crosstool-ng
pushd ${GITHUB_WORKSPACE}/crosstool-ng
./bootstrap
popd
# Build and install crosstool-ng
${GITHUB_WORKSPACE}/crosstool-ng/configure --prefix=${WORKSPACE}/crosstool-ng
make
make install
# Clean up build directory to reduce disk usage
popd
rm -rf ${WORKSPACE}/crosstool-ng-build
# Export crosstool-ng executable path
echo "CT_NG=${WORKSPACE}/crosstool-ng/bin/ct-ng" >> $GITHUB_ENV
- name: Test crosstool-ng
run: |
${CT_NG} version
- name: Download version information
uses: actions/download-artifact@v4
with:
name: version
path: ${{ runner.temp }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_CACHE_SDK_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_CACHE_SDK_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Download cached source files
continue-on-error: true
run: |
SRC_CACHE_BASE="s3://cache-sdk/crosstool-ng-sources"
SRC_CACHE_DIR="${{ matrix.host.name }}/${{ matrix.target }}"
SRC_CACHE_URI="${SRC_CACHE_BASE}/${SRC_CACHE_DIR}"
# Download cached source files
mkdir -p ${WORKSPACE}/sources
pushd ${WORKSPACE}/sources
aws s3 sync ${SRC_CACHE_URI} .
popd
# Export environment variables
echo "SRC_CACHE_URI=${SRC_CACHE_URI}" >> $GITHUB_ENV
- name: Setup debug session (pre)
if: always() && needs.setup.outputs.debug == 'toolchain-pre'
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
- name: Build toolchain
run: |
# Set output path
export CT_PREFIX="${WORKSPACE}/output"
# Create build directory
mkdir -p ${WORKSPACE}/build
pushd ${WORKSPACE}/build
# Load default target configurations
cat ${GITHUB_WORKSPACE}/configs/common.config \
${GITHUB_WORKSPACE}/configs/${{ matrix.target }}.config \
> .config
# Set version information
cat <<EOF >> .config
CT_SHOW_CT_VERSION=n
CT_TOOLCHAIN_PKGVERSION="${{ env.BUNDLE_NAME }} $(<${RUNNER_TEMP}/version)"
CT_TOOLCHAIN_BUGURL="${{ env.BUG_URL }}"
EOF
# Set environment configuration
cat <<EOF >> .config
CT_LOCAL_TARBALLS_DIR="${WORKSPACE}/sources"
CT_OVERLAY_LOCATION="${GITHUB_WORKSPACE}/overlays"
EOF
# Set logging configurations
cat <<EOF >> .config
CT_LOG_PROGRESS_BAR=n
CT_LOG_EXTRA=y
CT_LOG_LEVEL_MAX="EXTRA"
EOF
# Set Canadian cross compilation configurations
if [ "${{ matrix.host.name }}" == "macos-x86_64" ]; then
# Building for macos-x86_64 on macos-aarch64
cat <<EOF >> .config
CT_CANADIAN=y
CT_HOST="x86_64-apple-darwin"
EOF
elif [ "${{ matrix.host.name }}" == "windows-x86_64" ]; then
# Building for windows-x86_64 on linux-x86_64
cat <<EOF >> .config
CT_CANADIAN=y
CT_HOST="x86_64-w64-mingw32"
EOF
fi
# Configure GDB Python scripting support
cat <<EOF >> .config
CT_GDB_CROSS_PYTHON=y
CT_GDB_CROSS_PYTHON_VARIANT=y
EOF
if [ "${{ matrix.host.name }}" == "macos-x86_64" ]; then
# Use Python 3.10.15
export LIBPYTHON_KIT_ROOT=${GITHUB_WORKSPACE}/crosskit/crosskit-x86_64-darwin-libpython/python-3.10.15
# Set Python configuration resolver for GDB
cat <<EOF >> .config
CT_GDB_CROSS_PYTHON_BINARY="${LIBPYTHON_KIT_ROOT}/bin/python"
EOF
elif [ "${{ matrix.host.name }}" == "windows-x86_64" ]; then
# Use Python 3.10.11
export LIBPYTHON_KIT_ROOT=${GITHUB_WORKSPACE}/crosskit/crosskit-mingw-w64-libpython/python-3.10.11
# Set Python configuration resolver for GDB
cat <<EOF >> .config
CT_GDB_CROSS_PYTHON_BINARY="${LIBPYTHON_KIT_ROOT}/bin/python"
EOF
else
# Use Python 3.10 for non-Canadian Linux and macOS builds
cat <<EOF >> .config
CT_GDB_CROSS_PYTHON_BINARY="python3.10"
EOF
fi
# Allow building as root on Linux to avoid all sorts of container
# permission issues with the GitHub Actions.
if [ "$RUNNER_OS" == "Linux" ]; then
cat <<EOF >> .config
CT_EXPERIMENTAL=y
CT_ALLOW_BUILD_AS_ROOT=y
CT_ALLOW_BUILD_AS_ROOT_SURE=y
EOF
fi
# Merge configurations
${CT_NG} savedefconfig DEFCONFIG=build.config
${CT_NG} distclean
${CT_NG} defconfig DEFCONFIG=build.config
# Build toolchain
${CT_NG} build
popd
# Resolve output directory path
if [ "${{ matrix.host.name }}" == "macos-x86_64" ]; then
OUTPUT_BASE="${WORKSPACE}/output"
OUTPUT_DIR="HOST-x86_64-apple-darwin"
elif [ "${{ matrix.host.name }}" == "windows-x86_64" ]; then
OUTPUT_BASE="${WORKSPACE}/output"
OUTPUT_DIR="HOST-x86_64-w64-mingw32"
else
OUTPUT_BASE="${WORKSPACE}"
OUTPUT_DIR="output"
fi
# Grant write permission for owner
chmod -R u+w ${OUTPUT_BASE}/${OUTPUT_DIR}
# Remove unneeded files from output directory
pushd ${OUTPUT_BASE}/${OUTPUT_DIR}/${{ matrix.target }}
rm -rf newlib-nano
rm -f build.log.bz2
popd
# Rename Canadian cross-compiled toolchain output directory to
# "output" for consistency
if [ "${OUTPUT_DIR}" != "output" ]; then
mv ${OUTPUT_BASE}/${OUTPUT_DIR} ${OUTPUT_BASE}/output
OUTPUT_DIR="output"
fi
# Create archive
ARCHIVE_NAME=toolchain_gnu_${{ matrix.host.name }}_${{ matrix.target }}
ARCHIVE_FILE=${ARCHIVE_NAME}.${{ matrix.host.archive }}
if [ "${{ matrix.host.archive }}" == "tar.xz" ]; then
XZ_OPT="-T0" \
${TAR} -Jcvf ${ARCHIVE_FILE} \
--owner=0 --group=0 -C ${OUTPUT_BASE}/${OUTPUT_DIR} ${{ matrix.target }}
elif [ "${{ matrix.host.archive }}" == "7z" ]; then
pushd ${OUTPUT_BASE}/${OUTPUT_DIR}
7z a -t7z -l ${GITHUB_WORKSPACE}/${ARCHIVE_FILE} ${{ matrix.target }}
popd
fi
# Compute checksum
md5sum ${ARCHIVE_FILE} > md5.sum
sha256sum ${ARCHIVE_FILE} > sha256.sum
- name: Setup debug session (post)
if: always() && needs.setup.outputs.debug == 'toolchain-post'
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
- name: Sync downloaded source files to cache
continue-on-error: true
run: |
pushd ${WORKSPACE}/sources
aws s3 sync . ${SRC_CACHE_URI}
popd
- name: Prepare toolchain build log
if: always()
run: |
# Move build log file out of workspace
mv ${WORKSPACE}/build/build.log ${{ matrix.target }}.log
- name: Upload toolchain build log
if: always()
uses: actions/upload-artifact@v4
with:
name: log_toolchain_gnu_${{ matrix.host.name }}_${{ matrix.target }}
path: ${{ matrix.target }}.log
- name: Upload toolchain build artifact
uses: actions/upload-artifact@v4
with:
name: toolchain_gnu_${{ matrix.host.name }}_${{ matrix.target }}
path: |
toolchain_gnu_${{ matrix.host.name }}_${{ matrix.target }}.${{ matrix.host.archive }}
md5.sum
sha256.sum
# Build LLVM toolchain
build-llvm-toolchain:
name: LLVM Toolchain (${{ matrix.host.name }})
needs: setup
runs-on:
group: ${{ matrix.host.runner }}
container: ${{ matrix.host.container }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
host: ${{ fromJSON(needs.setup.outputs.hosts) }}
steps:
- name: Set up build environment (Linux)
if: ${{ runner.os == 'Linux' }}
run: |
# Create workspace directory
WORKSPACE="${RUNNER_TEMP}/workspace"
sudo mkdir -p ${WORKSPACE}
# Allow non-root access to the working directories
sudo chmod -R 777 ${GITHUB_WORKSPACE}
sudo chmod -R 777 ${RUNNER_TEMP}
# Install common dependencies
sudo apt-get update
# Install dependencies for cross compilation
if [ "${{ matrix.host.name }}" == "windows-x86_64" ]; then
# Make MinGW-w64 posix cross toolchain available in PATH
echo "/opt/mingw-w64-posix/bin" >> $GITHUB_PATH
fi
# Set environment variables
echo "TAR=tar" >> $GITHUB_ENV
echo "WORKSPACE=${WORKSPACE}" >> $GITHUB_ENV
- name: Set up build environment (macOS)
if: ${{ runner.os == 'macOS' }}
run: |
# Create case-sensitive workspace volume for macOS
WORKSPACE="/Volumes/Workspace"
hdiutil create ${RUNNER_TEMP}/Workspace.sparseimage \
-volname Workspace -type SPARSE -size 150g -fs HFSX
hdiutil mount ${RUNNER_TEMP}/Workspace.sparseimage -mountpoint ${WORKSPACE}
# Install dependencies
brew install qemu
# # Install dependencies for cross compilation
# if [ "${{ matrix.host.name }}" == "macos-x86_64" ]; then
# # Install x86 Homebrew
# arch -x86_64 /bin/bash -c \
# "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# # Install x86 dependencies
# arch -x86_64 /usr/local/bin/brew install pkg-config zstd
# fi
# Set environment variables
echo "TAR=gtar" >> $GITHUB_ENV
echo "WORKSPACE=${WORKSPACE}" >> $GITHUB_ENV
- name: Check out source code
if: ${{ github.event_name != 'pull_request_target' }}
uses: actions/checkout@v4
with:
submodules: recursive
persist-credentials: false
- name: Check out source code (pull request)
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
submodules: recursive
persist-credentials: false
- name: Setup debug session (pre)
if: always() && needs.setup.outputs.debug == 'toolchain-pre'
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
- name: Build LLVM toolchain
run: |
# Create build directory
pushd ${WORKSPACE}
mkdir -p llvm
mkdir -p llvm-build
cd llvm-build
# Configure and generate LLVM build scripts
if [ "${{ matrix.host.name }}" == "windows-x86_64" ]; then
LLVM_CMAKE_ARGS+="-DLLVM_TOOLCHAIN_CROSS_BUILD_MINGW=ON "
elif [ "${{ matrix.host.name }}" == "macos-aarch64" ]; then
LLVM_CMAKE_ARGS+="-DCMAKE_OSX_ARCHITECTURES=arm64 "
elif [ "${{ matrix.host.name }}" == "macos-x86_64" ]; then
LLVM_CMAKE_ARGS+="-DCMAKE_OSX_ARCHITECTURES=x86_64 "
fi
cmake \
-GNinja \
--install-prefix ${WORKSPACE}/llvm \
-DLLVM_ENABLE_ZSTD=OFF \
${LLVM_CMAKE_ARGS} \
${GITHUB_WORKSPACE}/scripts/llvm \
|& tee ${GITHUB_WORKSPACE}/llvm-cmake.log
# Build LLVM toolchain
ninja llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-build.log
# Run LLVM tests
ninja check-llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-test.log
# Install LLVM toolchain
ninja install-llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-install.log
popd
# Create archive
ARCHIVE_NAME=toolchain_llvm_${{ matrix.host.name }}
ARCHIVE_FILE=${ARCHIVE_NAME}.${{ matrix.host.archive }}
if [ "${{ matrix.host.archive }}" == "tar.xz" ]; then
XZ_OPT="-T0" \
${TAR} -Jcvf ${ARCHIVE_FILE} \
--owner=0 --group=0 -C ${WORKSPACE} llvm
elif [ "${{ matrix.host.archive }}" == "7z" ]; then
pushd ${WORKSPACE}
7z a -t7z -l ${GITHUB_WORKSPACE}/${ARCHIVE_FILE} llvm
popd
fi
# Compute checksum
md5sum ${ARCHIVE_FILE} > md5.sum
sha256sum ${ARCHIVE_FILE} > sha256.sum
- name: Setup debug session (post)
if: always() && needs.setup.outputs.debug == 'toolchain-post'
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
- name: Upload toolchain build log
if: always()
uses: actions/upload-artifact@v4
with:
name: log_toolchain_llvm_${{ matrix.host.name }}
path: '*.log'
- name: Upload toolchain build artifact
uses: actions/upload-artifact@v4
with:
name: toolchain_llvm_${{ matrix.host.name }}
path: |
toolchain_llvm_${{ matrix.host.name }}.${{ matrix.host.archive }}
md5.sum
sha256.sum
# Build host tools
build-hosttools:
name: Host Tools (${{ matrix.host.name }})
needs: setup
runs-on:
group: ${{ matrix.host.runner }}
container: ${{ matrix.host.container }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
host: ${{ fromJSON(needs.setup.outputs.hosts) }}
steps:
- name: Apply container owner mismatch workaround
run: |
# FIXME: The owner UID of the GITHUB_WORKSPACE directory may not
# match the container user UID because of the way GitHub
# Actions runner is implemented. Remove this workaround when
# GitHub comes up with a fundamental fix for this problem.
git config --global --add safe.directory '*'
- name: Set up build environment (Linux)
if: ${{ runner.os == 'Linux' }}
run: |
# Set environment variables
echo "TAR=tar" >> $GITHUB_ENV