Skip to content

Commit 58d259f

Browse files
committed
ci: Add workflow to build macosx-x86_64 toolchains
Add a github workflow that will build macosx-x86_64 toolchains and publish the packages on release. The workflow only runs after a commit since it takes 6+ hours to run on current github macosx builders. A few notes / caveats on the macosx toolchain build / packages: * NO host tools (ie qemu, openocd, dtc, etc). Since we dont build yocto on MacOS we dont currently have any of the host tools at this time * GDB build is without python. The python GDB on MacOS doesn't currently work so we limit GDB to only a non-python enabled build. * gcc build with --without-zstd to make builds portable. As zstd isn't a common library on MacOS we build with this flag since it is found in homebrew with the github MacOS setup Signed-off-by: Kumar Gala <[email protected]>
1 parent 088304b commit 58d259f

File tree

1 file changed

+227
-0
lines changed

1 file changed

+227
-0
lines changed

.github/workflows/mac.yml

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
name: macos-ci
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
# Cancel job is setup to not cancel jobs associated with
8+
# a tag (ie a release). Also we run it on ubuntu in the
9+
# hopes that if the macos builders are full that it can
10+
# still run
11+
cancel:
12+
runs-on: "ubuntu-latest"
13+
steps:
14+
- name: "Cancel Previous Runs"
15+
uses: styfle/[email protected]
16+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
17+
with:
18+
access_token: ${{ github.token }}
19+
20+
# Crosstool job creates a disk image, builds crosstool so we
21+
# only do that once per toolchain, and preloads the disk image with
22+
# the sources so we only download them once.
23+
#
24+
# NOTES:
25+
# - uses 'go.sh cmake' as a way to easily just build crosstool
26+
# - to download sources we use arm.config and utilize setting
27+
# CT_ONLY_DOWNLOAD in the env plus invoking crosstool with
28+
# a STOP=companion_libs_for_build condition.
29+
crosstool:
30+
needs: cancel
31+
runs-on: ${{ matrix.host }}
32+
strategy:
33+
matrix:
34+
host: [
35+
"macos-10.15",
36+
]
37+
steps:
38+
- name: "clone"
39+
uses: actions/checkout@v2
40+
- name: "prereq macOS"
41+
run: |
42+
brew install autoconf automake bash binutils gawk gnu-sed \
43+
gnu-tar help2man ncurses
44+
- name: "build ct-ng"
45+
run: |
46+
export HOMEBREW_ROOT="/usr/local"
47+
export PATH="$PATH:${HOMEBREW_ROOT}/opt/binutils/bin"
48+
export CPPFLAGS="-I${HOMEBREW_ROOT}/opt/ncurses/include -I${HOMEBREW_ROOT}/opt/gettext/include"
49+
export LDFLAGS="-L${HOMEBREW_ROOT}/opt/ncurses/lib -L${HOMEBREW_ROOT}/opt/gettext/lib"
50+
./go.sh cmake
51+
- name: "preload sources"
52+
run: |
53+
export GITDIR=${PWD}
54+
export SDK_NG_HOME=/Volumes/CrossToolNGNew
55+
export CT_NG=${SDK_NG_HOME}/bin/ct-ng
56+
export CT_PREFIX=${SDK_NG_HOME}/build/output/
57+
export CT_ONLY_DOWNLOAD=y
58+
mkdir -p ${SDK_NG_HOME}/build/dummy
59+
cd ${SDK_NG_HOME}/build/dummy
60+
$CT_NG defconfig DEFCONFIG=${GITDIR}/configs/arm.config
61+
$CT_NG build STOP=companion_libs_for_build
62+
cd ${GITDIR}
63+
rm -fr ${CT_PREFIX}/arm-zephyr-eabi
64+
rm -fr ${SDK_NG_HOME}/build/dummy
65+
- name: "upload cmake"
66+
uses: actions/upload-artifact@v2
67+
with:
68+
name: cmake.x86_64.tar.bz2
69+
path: /Volumes/CrossToolNGNew/cmake.x86_64.tar.bz2
70+
- name: "prep to upload"
71+
continue-on-error: true
72+
run: |
73+
sync
74+
sleep 10
75+
hdiutil unmount /Volumes/CrossToolNGNew -force
76+
- name: "upload ct-ng"
77+
uses: actions/upload-artifact@v2
78+
with:
79+
name: CrossToolNGNew.sparseimage
80+
path: CrossToolNGNew.sparseimage
81+
82+
# Build the actual toolchains. This will publish artifacts for the
83+
# toolchain builds and build logs
84+
toolchains:
85+
needs: crosstool
86+
runs-on: ${{ matrix.host }}
87+
strategy:
88+
matrix:
89+
host: [
90+
"macos-10.15",
91+
]
92+
sample: [
93+
"arm",
94+
"arc",
95+
"riscv64",
96+
"nios2",
97+
"sparc",
98+
"x86_64-zephyr-elf",
99+
"arm64",
100+
"xtensa_sample_controller",
101+
"xtensa_intel_apl_adsp",
102+
"xtensa_intel_bdw_adsp",
103+
"xtensa_intel_byt_adsp",
104+
"xtensa_nxp_imx_adsp",
105+
"xtensa_nxp_imx8m_adsp",
106+
"xtensa_intel_s1000",
107+
"mips",
108+
]
109+
steps:
110+
- name: "clone"
111+
uses: actions/checkout@v2
112+
- name: "download ct-ng"
113+
uses: actions/download-artifact@v2
114+
with:
115+
name: CrossToolNGNew.sparseimage
116+
- name: "prereq macOS"
117+
run: |
118+
brew install autoconf automake bash binutils gawk gnu-sed \
119+
gnu-tar help2man ncurses pkg-config
120+
echo "$GITHUB_WORKSPACE/.local/bin" >> $GITHUB_PATH
121+
- name: "prep ${{ matrix.sample }}.config"
122+
run: |
123+
sed -i -e '/CT_GDB_CROSS_PYTHON_BINARY/d' configs/${{ matrix.sample }}.config
124+
sed -i -e '/CT_GDB_CROSS_BUILD_NO_PYTHON/d' configs/${{ matrix.sample }}.config
125+
sed -i -e '/^CT_CC_GCC_EXTRA_CONFIG_ARRAY=/ s/"$/ --without-zstd"/' configs/${{ matrix.sample }}.config
126+
echo "# CT_GDB_CROSS_PYTHON is not set" >> configs/${{ matrix.sample }}.config
127+
- name: "build ${{ matrix.sample }} for ${{ matrix.host }}"
128+
run: |
129+
./go.sh ${{ matrix.sample }}
130+
- name: "tar"
131+
run: |
132+
export TARGET=${{ matrix.sample }}
133+
export MACHINE=$(uname -m)
134+
cd /Volumes/CrossToolNGNew/build/output
135+
case "${TARGET}" in
136+
xtensa_*)
137+
tar --exclude='build.log.bz2' -jcvf ../../${TARGET}.$MACHINE.tar.bz2 xtensa/${TARGET#xtensa_}/*-zephyr-*;
138+
;;
139+
*)
140+
tar --exclude='build.log.bz2' -jcvf ../../${TARGET}.$MACHINE.tar.bz2 *-zephyr-*;
141+
;;
142+
esac
143+
- name: "upload xtensa build log"
144+
if: ${{ always() && startsWith(matrix.sample, 'xtensa') }}
145+
uses: actions/upload-artifact@v2
146+
with:
147+
name: "${{ matrix.sample }}.${{ matrix.host }}.log"
148+
path: /Volumes/CrossToolNGNew/build/output/xtensa/*/*-zephyr-*/build.log.bz2
149+
- name: "upload not-xtensa build log"
150+
if: ${{ always() && !startsWith(matrix.sample, 'xtensa') }}
151+
uses: actions/upload-artifact@v2
152+
with:
153+
name: "${{ matrix.sample }}.${{ matrix.host }}.log"
154+
path: /Volumes/CrossToolNGNew/build/output/*-zephyr-*/build.log.bz2
155+
- name: "upload toolchain tarball"
156+
uses: actions/upload-artifact@v2
157+
with:
158+
name: "${{ matrix.sample }}.x86_64.tar.bz2"
159+
path: /Volumes/CrossToolNGNew/${{ matrix.sample }}.x86_64.tar.bz2
160+
161+
# Create the actual zephyr toolchain and SDK packages
162+
package:
163+
needs: toolchains
164+
runs-on: ${{ matrix.host }}
165+
strategy:
166+
matrix:
167+
host: [
168+
"macos-10.15",
169+
]
170+
steps:
171+
- name: "clone"
172+
uses: actions/checkout@v2
173+
- name: "prereq macOS"
174+
run: |
175+
brew install makeself
176+
- name: mkdir toolchains
177+
run: |
178+
mkdir -p scripts/toolchains/dl
179+
- name: "download ct-ng"
180+
uses: actions/download-artifact@v2
181+
with:
182+
path: scripts/toolchains/dl
183+
- name: "cleanup"
184+
run: |
185+
mv scripts/toolchains/dl/*/*.tar.bz2 scripts/toolchains
186+
rm -fr scripts/toolchains/dl
187+
- name: "build toolchains"
188+
run: |
189+
cd scripts
190+
./make_zephyr_sdk.sh x86_64
191+
- name: "upload toolchains"
192+
uses: actions/upload-artifact@v2
193+
with:
194+
name: zephyr-toolchains
195+
path: scripts/zephyr-toolchain-*
196+
- name: "upload sdk"
197+
uses: actions/upload-artifact@v2
198+
with:
199+
name: zephyr-sdk
200+
path: scripts/zephyr-sdk-*
201+
202+
# Publish the zephyr toolchain and SDK packages if we tagged a release
203+
release:
204+
needs: package
205+
if: startsWith(github.ref, 'refs/tags/')
206+
runs-on: ${{ matrix.host }}
207+
strategy:
208+
matrix:
209+
host: [
210+
"macos-10.15",
211+
]
212+
steps:
213+
- name: "download toolchains"
214+
uses: actions/download-artifact@v2
215+
with:
216+
name: zephyr-toolchains
217+
- name: "download sdk"
218+
uses: actions/download-artifact@v2
219+
with:
220+
name: zephyr-sdk
221+
- name: Release
222+
uses: softprops/action-gh-release@v1
223+
with:
224+
files: |
225+
zephyr-*.run
226+
env:
227+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)