@@ -12,70 +12,51 @@ jobs:
12
12
cache :
13
13
name : Update Submodule Cache
14
14
runs-on : ubuntu-24.04
15
+ outputs :
16
+ key : submodules-${{ steps.submodule-hash.outputs.HASH }}
17
+ env :
18
+ cache-path : |
19
+ .git/modules
20
+ binutils
21
+ gdb
22
+ gcc
23
+ llvm
24
+ newlib
25
+ glibc
26
+ musl
27
+ uclib-ng
28
+ dejagnu
29
+ pk
30
+ qemu
31
+ spike
15
32
steps :
16
33
- uses : actions/checkout@v4
17
34
18
- - name : Cache GCC
19
- uses : actions/cache@v4
20
- with :
21
- path : |
22
- .git/modules/gcc
23
- gcc
24
- key : compiler-gcc
25
-
26
- - name : Cache LLVM
27
- uses : actions/cache@v4
28
- with :
29
- path : |
30
- .git/modules/llvm
31
- llvm
32
- key : compiler-llvm
33
-
34
- - name : Cache Newlib
35
- uses : actions/cache@v4
36
- with :
37
- path : |
38
- .git/modules/newlib
39
- newlib
40
- key : mode-newlib
35
+ - name : Generate Submodule Hash
36
+ id : submodule-hash
37
+ run : echo "HASH=$(git submodule | sha1sum | sed 's/.\{3\}$//')" >> $GITHUB_OUTPUT
41
38
42
- - name : Cache Linux
39
+ - name : Check is Cache Exists for Exact Submodule Configuration
40
+ id : cache-check
43
41
uses : actions/cache@v4
44
42
with :
45
- path : |
46
- .git/modules/glibc
47
- glibc
48
- key : mode-linux
43
+ path : ${{ env.cache-path }}
44
+ key : submodules-${{ steps.submodule-hash.outputs.HASH }}
45
+ lookup-only : true
49
46
50
- - name : Cache musl
47
+ - name : If no Cache Hit, Update Cache
51
48
uses : actions/cache@v4
49
+ if : steps.cache-check.outputs.cache-hit != 'true'
52
50
with :
53
- path : |
54
- .git/modules/musl
55
- musl
56
- key : mode-musl
57
-
58
- - name : Cache uClibc
59
- uses : actions/cache@v4
60
- with :
61
- path : |
62
- .git/modules/uclibc-ng
63
- uclibc-ng
64
- key : mode-uclibc
51
+ path : ${{ env.cache-path }}
52
+ key : submodules-${{ steps.submodule-hash.outputs.HASH }}
53
+ restore-keys : |
54
+ submodules-
65
55
66
- - name : Cache Always Required Submodules
67
- uses : actions/cache@v4
68
- with :
69
- path : |
70
- .git/modules/binutils
71
- .git/modules/gdb
72
- binutils
73
- gdb
74
- key : general-dependencies
75
-
76
- - name : Clone needed submodules
56
+ - name : Clone submodules
57
+ if : steps.cache-check.outputs.cache-hit != 'true'
77
58
run : |
78
- git submodule update --init --progress --depth 1 --jobs $(nproc) binutils gdb gcc llvm newlib glibc musl
59
+ git submodule update --init --progress --depth 1 --jobs $(nproc) binutils gdb gcc llvm newlib glibc musl dejagnu pk qemu spike
79
60
git submodule update --init --progress uclibc-ng
80
61
81
62
84
65
name : Build Toolchain Variants
85
66
runs-on : ${{ matrix.os }}
86
67
needs : [cache]
68
+ env :
69
+ cache-key : ${{ needs.cache.outputs.key }}
87
70
strategy :
88
71
matrix :
89
72
os : [ubuntu-22.04, ubuntu-24.04]
@@ -105,63 +88,44 @@ jobs:
105
88
echo "-- After --"
106
89
df -h
107
90
108
- - name : Generate Required Submodules
109
- id : required-submodules
91
+ - name : Generate Submodules List
92
+ id : cache-path
110
93
run : |
94
+ submodules="gdb:binutils"
111
95
case "${{ matrix.mode }}" in
112
96
"linux")
113
- MODE_SUBMODULE=" glibc";;
97
+ submodules="$submodules: glibc";;
114
98
"musl")
115
- MODE_SUBMODULE=" musl";;
99
+ submodules="$submodules: musl";;
116
100
"uclibc")
117
- MODE_SUBMODULE=" uclibc-ng";;
101
+ submodules="$submodules: uclibc-ng";;
118
102
"newlib")
119
- MODE_SUBMODULE=" newlib";;
103
+ submodules="$submodules: newlib";;
120
104
*)
121
105
echo "Invalid Mode"; exit 1;;
122
106
esac
123
- echo "MODE_SUBMODULE=$MODE_SUBMODULE" >> $GITHUB_OUTPUT
124
107
case "${{ matrix.compiler }}" in
125
108
"gcc")
126
- COMPILER_SUBMODULE=" gcc";;
109
+ submodules="$submodules: gcc";;
127
110
"llvm")
128
- COMPILER_SUBMODULE=" llvm";;
111
+ submodules="$submodules: llvm";;
129
112
*)
130
113
echo "Invalid Compiler"; exit 1;;
131
114
esac
132
- echo "COMPILER_SUBMODULE=$COMPILER_SUBMODULE" >> $GITHUB_OUTPUT
115
+ submodules=$(echo $submodules | sed 's/:/\n/g')
116
+ submodules=$submodules$'\n'$(echo "$submodules" | sed -e 's/^/.git\/modules\//')
117
+ echo 'submodules<<EOF' >> $GITHUB_OUTPUT
118
+ echo "$submodules" >> $GITHUB_OUTPUT
119
+ echo 'EOF' >> $GITHUB_OUTPUT
133
120
134
121
- uses : actions/checkout@v4
135
122
136
- - name : Load Compiler Submodule from Cache
123
+ - name : Load Cache
137
124
uses : actions/cache/restore@v4
138
- env :
139
- submodule : ${{ steps.required-submodules.outputs.COMPILER_SUBMODULE }}
140
125
with :
141
126
path : |
142
- .git/modules/${{ env.submodule }}
143
- ${{ env.submodule }}
144
- key : compiler-${{ matrix.compiler }}
145
-
146
- - name : Load Mode Submodule from Cache
147
- uses : actions/cache/restore@v4
148
- env :
149
- submodule : ${{ steps.required-submodules.outputs.MODE_SUBMODULE }}
150
- with :
151
- path : |
152
- .git/modules/${{ env.submodule }}
153
- ${{ env.submodule }}
154
- key : mode-${{ matrix.mode }}
155
-
156
- - name : Load Always Required Submodules from Cache
157
- uses : actions/cache/restore@v4
158
- with :
159
- path : |
160
- .git/modules/binutils
161
- .git/modules/gdb
162
- binutils
163
- gdb
164
- key : general-dependencies
127
+ ${{ steps.cache-path.outputs.submodules }}
128
+ key : ${{ env.cache-key }}
165
129
166
130
- name : Install Dependencies
167
131
run : sudo ./.github/setup-apt.sh
@@ -218,6 +182,9 @@ jobs:
218
182
test-sim :
219
183
name : Test Simulation
220
184
runs-on : ${{ matrix.os }}
185
+ needs : [cache]
186
+ env :
187
+ cache-key : ${{ needs.cache.outputs.key }}
221
188
strategy :
222
189
matrix :
223
190
os : [ubuntu-24.04]
@@ -236,6 +203,25 @@ jobs:
236
203
237
204
- uses : actions/checkout@v4
238
205
206
+ - uses : actions/cache/restore@v4
207
+ with :
208
+ path : |
209
+ .git/modules/gcc
210
+ .git/modules/newlib
211
+ .git/modules/binutils
212
+ .git/modules/gdb
213
+ .git/modules/spike
214
+ .git/modules/pk
215
+ .git/modules/dejagnu
216
+ gcc
217
+ newlib
218
+ binutils
219
+ gdb
220
+ spike
221
+ pk
222
+ dejagnu
223
+ key : ${{ env.cache-key }}
224
+
239
225
- name : Install Dependencies
240
226
run : sudo ./.github/setup-apt.sh
241
227
0 commit comments