Skip to content

Commit 401a0ac

Browse files
committed
Build MacOS Intel OpenOCD and Toolchain
1 parent 178ced3 commit 401a0ac

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed

.github/workflows/build.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,40 @@ jobs:
8181
bin/openocd-*-mac.zip
8282
bin/riscv-toolchain-*.zip
8383
84+
build_macos_intel:
85+
name: Build Intel MacOS
86+
# runs-on: [self-hosted, macOS]
87+
runs-on: 'macos-13'
88+
89+
steps:
90+
- name: Checkout
91+
uses: actions/checkout@v4
92+
- name: Set up Homebrew
93+
if: runner.environment == 'github-hosted'
94+
id: set-up-homebrew
95+
uses: Homebrew/actions/setup-homebrew@master
96+
- name: Setup SSH Auth
97+
if: runner.environment == 'github-hosted'
98+
uses: webfactory/[email protected]
99+
with:
100+
ssh-private-key: ${{ secrets.SSH_KEY }}
101+
- name: Build
102+
run: ./build_macos_intel.sh
103+
- name: Upload Artifact
104+
uses: actions/upload-artifact@v4
105+
with:
106+
name: tools-mac-x64
107+
path: |
108+
bin/openocd-*-mac.zip
109+
bin/riscv-toolchain-*.zip
110+
- name: Add Release Asset
111+
uses: softprops/action-gh-release@v2
112+
if: startsWith(github.ref, 'refs/tags/')
113+
with:
114+
files: |
115+
bin/openocd-*-mac.zip
116+
bin/riscv-toolchain-*.zip
117+
84118
build_linux:
85119
name: Build Linux
86120
# strategy:

build_macos_intel.sh

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
# Defaults
6+
SKIP_RISCV=${SKIP_RISCV-0}
7+
SKIP_OPENOCD=${SKIP_OPENOCD-0}
8+
9+
# Install prerequisites
10+
/usr/local/bin/brew install jq libtool libusb automake hidapi --quiet
11+
# RISC-V prerequisites
12+
echo "Listing local"
13+
ls /usr/local/bin
14+
rm /usr/local/bin/2to3*
15+
rm /usr/local/bin/idle3*
16+
rm /usr/local/bin/pip*
17+
rm /usr/local/bin/py*
18+
/usr/local/bin/brew install python3 gawk gnu-sed gmp mpfr libmpc isl zlib expat texinfo flock libslirp --quiet
19+
20+
repos=$(cat config/repositories.json | jq -c '.repositories.[]')
21+
export version=$(cat ./version.txt)
22+
suffix="mac"
23+
builddir="build"
24+
25+
# nproc alias
26+
alias nproc="sysctl -n hw.logicalcpu"
27+
28+
mkdir -p $builddir
29+
mkdir -p "bin"
30+
31+
while read -r repo
32+
do
33+
tree=$(echo "$repo" | jq -r .tree)
34+
href=$(echo "$repo" | jq -r .href)
35+
filename=$(basename -- "$href")
36+
extension="${filename##*.}"
37+
filename="${filename%.*}"
38+
filename=${filename%"-rp2350"}
39+
repodir="$builddir/${filename}"
40+
41+
echo "${href} ${tree} ${filename} ${extension} ${repodir}"
42+
rm -rf "${repodir}"
43+
git clone -b "${tree}" --depth=1 -c advice.detachedHead=false "${href}" "${repodir}"
44+
done < <(echo "$repos")
45+
46+
47+
cd $builddir
48+
if [[ "$SKIP_OPENOCD" != 1 ]]; then
49+
if ! ../packages/macos/openocd/build-openocd.sh; then
50+
echo "OpenOCD Build failed"
51+
SKIP_OPENOCD=1
52+
fi
53+
fi
54+
if [[ "$SKIP_RISCV" != 1 ]]; then
55+
# Takes ages to build
56+
../packages/macos/riscv/build-riscv-gcc.sh
57+
fi
58+
59+
topd=$PWD
60+
if [[ "$SKIP_OPENOCD" != 1 ]]; then
61+
# Package OpenOCD separately as well
62+
63+
version=($("./$builddir/openocd-install/usr/local/bin/openocd" --version 2>&1))
64+
version=${version[0]}
65+
version=${version[3]}
66+
version=$(echo $version | cut -d "-" -f 1)
67+
68+
echo "OpenOCD version $version"
69+
70+
filename="openocd-${version}-x64-${suffix}.zip"
71+
72+
echo "Saving OpenOCD package to $filename"
73+
pushd "$builddir/openocd-install/usr/local/bin"
74+
tar -a -cf "$topd/bin/$filename" * -C "../share/openocd" "scripts"
75+
popd
76+
fi
77+
78+
if [[ "$SKIP_RISCV" != 1 ]]; then
79+
# Package riscv toolchain separately as well
80+
version="14"
81+
echo "Risc-V Toolchain version $version"
82+
83+
filename="riscv-toolchain-${version}-x64-${suffix}.zip"
84+
85+
echo "Saving RISC-V Toolchain package to $filename"
86+
pushd "$builddir/riscv-install/"
87+
tar -a -cf "$topd/bin/$filename" *
88+
popd
89+
fi

0 commit comments

Comments
 (0)