forked from zephyrproject-rtos/action-zephyr-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
273 lines (241 loc) · 9.14 KB
/
Copy pathaction.yml
File metadata and controls
273 lines (241 loc) · 9.14 KB
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
# Copyright 2024 Google LLC
# SPDX-License-Identifier: Apache-2.0
name: Setup Zephyr project
description: Setup a Zephyr base project using west and downloading the Zephyr SDK
inputs:
app-path:
description: |
Application code path, should contain a west.yml file if
"manifest-file-name" is not specified, cannot contain multiple
directories (use base-path instead)
required: true
base-path:
description: |
Application base path, should contain the app-path. Defaults to "." if
unspecified
required: false
default: .
ccache-max-size:
description: |
Maximum size of the files stored in the compiler cache (ccache). Defaults to 512MB.
required: false
default: 512MB
enable-ccache:
description: |
Enable caching/restoring of compiler cache (ccache) files between invocations.
Defaults to 'true'.
required: false
default: true
ccache-cache-key:
description: |
An additional string used in the ccache cache key, use it to identify the
cache in a way that makes sense for compiled object cache reuse between
different build workflows. Default to "default".
required: false
default: default
manifest-file-name:
description: Name of the west workspace manifest file name in "app-path"
required: false
default: west.yml
sdk-version:
description: Zephyr SDK version to use or "auto" to detect automatically
required: false
default: auto
sdk-base:
description: Base URL of the Zephyr SDK
required: false
default: https://github.com/zephyrproject-rtos/sdk-ng/releases/download
toolchains:
description: List of toolchains to install, colon separated
required: false
default: arm-zephyr-eabi
west-project-filter:
description: West project filter
required: false
default: ""
west-group-filter:
description: West group filter
required: false
default: ""
west-version:
description: West version to install, latest if omitted
required: false
default: ""
runs:
using: "composite"
steps:
- name: Install dependencies
shell: bash
run: |
if [ "${{ runner.os }}" = "Windows" ]; then
python.exe -m pip install -U pip
fi
pip3 install -U pip wheel
if [ -n "${{ inputs.west-version }}" ]; then
pip3 install west==${{ inputs.west-version }}
else
pip3 install west
fi
if [ "${{ runner.os }}" = "Linux" ]; then
sudo rm -f /var/lib/man-db/auto-update
sudo apt-get update -y
sudo apt-get install -y ccache gperf
if [ "${{ runner.arch }}" = "X64" ]; then
sudo apt-get install -y libc6-dev-i386 g++-multilib
fi
elif [ "${{ runner.os }}" = "macOS" ]; then
brew install ccache qemu dtc gperf coreutils
elif [ "${{ runner.os }}" = "Windows" ]; then
choco feature enable -n allowGlobalConfirmation
choco install wget gperf --no-progress
fi
- name: Initialize
working-directory: ${{ inputs.base-path }}
shell: bash
run: |
west init -l ${{ inputs.app-path }} --mf ${{ inputs.manifest-file-name }}
if [ -n "${{ inputs.west-group-filter }}" ]; then
west config manifest.group-filter -- ${{ inputs.west-group-filter }}
fi
if [ -n "${{ inputs.west-project-filter }}" ]; then
west config manifest.project-filter -- ${{ inputs.west-project-filter }}
fi
west update -o=--depth=1 -n
- name: Environment setup
working-directory: ${{ inputs.base-path }}
id: env-setup
shell: bash
run: |
runner="${{ runner.os }}-${{ runner.arch }}"
if [ "$runner" = "Linux-X64" ]; then
sdk_variant="linux-x86_64"
elif [ "$runner" = "Linux-ARM64" ]; then
sdk_variant="linux-aarch64"
elif [ "$runner" = "macOS-X64" ]; then
sdk_variant="macos-x86_64"
elif [ "$runner" = "macOS-ARM64" ]; then
sdk_variant="macos-aarch64"
elif [ "$runner" = "Windows-X64" ]; then
sdk_variant="windows-x86_64"
else
echo "Unsupported runner platform: $runner"
fi
if [ "${{ runner.os }}" = "Linux" ]; then
pip_cache_path="~/.cache/pip"
ccache_path="$HOME/.cache/ccache"
sdk_ext="tar.xz"
setup_file="./setup.sh"
setup_opt="-"
elif [ "${{ runner.os }}" = "macOS" ]; then
pip_cache_path="~/Library/Caches/pip"
ccache_path="$HOME/Library/Caches/ccache"
sdk_ext="tar.xz"
setup_file="./setup.sh"
setup_opt="-"
elif [ "${{ runner.os }}" = "Windows" ]; then
pip_cache_path="~/AppData/Local/pip/Cache"
ccache_path="$HOME/AppData/Local/ccache/Cache"
sdk_ext="7z"
setup_file="./setup.cmd"
setup_opt="//"
fi
if [ "${{ inputs.sdk-version }}" = "auto" ]; then
zephyr_path="zephyr"
if west list -f '{abspath}' zephyr; then
zephyr_path="$( west list -f '{abspath}' zephyr )"
fi
if [ -f "${zephyr_path}/SDK_VERSION" ]; then
echo "Reading SDK version from ${zephyr_path}/SDK_VERSION"
sdk_version=$( cat ${zephyr_path}/SDK_VERSION )
else
echo "Cannot find ${zephyr_path}/SDK_VERSION"
exit 1
fi
else
sdk_version="${{ inputs.sdk-version }}"
fi
sdk_file="zephyr-sdk-${sdk_version}_${sdk_variant}_minimal.${sdk_ext}"
sdk_cache_key="$( sha1sum <<< ${sdk_file}-${{ github.event.repository.name }}-${{ inputs.toolchains }} | cut -d' ' -f1 )"
echo "SDK_VERSION=${sdk_version}" >> $GITHUB_ENV
echo "SDK_FILE=${sdk_file}" >> $GITHUB_ENV
echo "SDK_CACHE_KEY=${sdk_cache_key}" >> $GITHUB_ENV
echo "PIP_CACHE_PATH=${pip_cache_path}" >> $GITHUB_ENV
echo "CCACHE_TIMESTAMP=$(date +%s)" >> $GITHUB_ENV
echo "CCACHE_DIR=${ccache_path}" >> $GITHUB_ENV
echo "CCACHE_IGNOREOPTIONS=-specs=* --specs=*" >> $GITHUB_ENV
echo "SETUP_FILE=${setup_file}" >> $GITHUB_ENV
echo "SETUP_OPT=${setup_opt}" >> $GITHUB_ENV
- name: Cache Python packages
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ env.PIP_CACHE_PATH }}
key: pip-${{ runner.os }}-${{ hashFiles(format('{0}/zephyr/scripts/requirements*.txt', inputs.base-path)) }}
- name: Install Python packages
if: runner.os != 'Windows'
working-directory: ${{ inputs.base-path }}
shell: bash
# The direct use of pip3 should be removed after zephyr 3.7 has been phased out, and the west
# command should only be used instead.
run: |
west packages pip --install --ignore-venv-check || pip3 install -r zephyr/scripts/requirements.txt
- name: Install Python packages (Windows)
if: runner.os == 'Windows'
working-directory: ${{ inputs.base-path }}
shell: powershell
# The direct use of pip3 should be removed after zephyr 3.7 has been phased out, and the west
# command should only be used instead.
run: |
pip3 install @((west packages pip) -split ' '); if (!$?) { pip3 install -r zephyr/scripts/requirements.txt }
- name: Cache Zephyr SDK
id: cache-toolchain
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ inputs.base-path }}/zephyr-sdk
key: ${{ env.SDK_CACHE_KEY }}
- if: steps.cache-toolchain.outputs.cache-hit != 'true'
working-directory: ${{ inputs.base-path }}
name: Download Zephyr SDK
shell: bash
run: |
wget --progress=dot:giga ${{ inputs.sdk-base }}/v${SDK_VERSION}/${SDK_FILE}
rm -rf zephyr-sdk
if [ "${{ runner.os }}" = "Windows" ]; then
7z x $SDK_FILE
mv zephyr-sdk-${SDK_VERSION} zephyr-sdk
else
mkdir zephyr-sdk
tar xvf $SDK_FILE -C zephyr-sdk --strip-components=1
fi
rm -f $SDK_FILE
- name: Setup Zephyr SDK
working-directory: ${{ inputs.base-path }}/zephyr-sdk
shell: bash
run: |
IFS=":"
TOOLCHAINS="${{ inputs.toolchains }}"
for toolchain in $TOOLCHAINS; do
if [ "$toolchain" == "llvm" ]; then
${SETUP_FILE} ${SETUP_OPT}l
else
${SETUP_FILE} ${SETUP_OPT}t $toolchain
fi
done
if [ ! -d sysroots ]; then
${SETUP_FILE} ${SETUP_OPT}h
fi
${SETUP_FILE} ${SETUP_OPT}c
- name: Cache ccache data
if: inputs.enable-ccache == 'true' && runner.os != 'Windows'
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ inputs.ccache-cache-key }}-${{ env.CCACHE_TIMESTAMP }}
restore-keys: ccache-${{ inputs.ccache-cache-key }}-
- name: Set up ccache
if: inputs.enable-ccache == 'true' && runner.os != 'Windows'
shell: bash
run: |
mkdir -p ${{ env.CCACHE_DIR }}
ccache -M ${{ inputs.ccache-max-size }}
ccache -p
ccache -z -s -vv