Skip to content

Commit 67fbef4

Browse files
committed
Add x64 MacOS build
1 parent be62258 commit 67fbef4

File tree

7 files changed

+105
-103
lines changed

7 files changed

+105
-103
lines changed

.github/workflows/build.yml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ jobs:
4949
bin/openocd-*-x64-win.zip
5050
bin/riscv-toolchain-*-x64-win.zip
5151
52-
build_macos:
53-
name: Build MacOS
52+
build_macos_arm64:
53+
name: Build MacOS Arm64
5454
# runs-on: [self-hosted, macOS]
5555
runs-on: 'macos-latest'
5656

@@ -90,6 +90,36 @@ jobs:
9090
bin/pico-sdk-tools-*-mac.zip
9191
bin/openocd-*-mac.zip
9292
bin/riscv-toolchain-*.zip
93+
94+
build_macos_x64:
95+
name: Build MacOS x64
96+
runs-on: 'macos-13'
97+
env:
98+
SKIP_PICOTOOL: 1
99+
100+
steps:
101+
- name: Checkout
102+
uses: actions/checkout@v4
103+
- name: Set up Homebrew
104+
if: runner.environment == 'github-hosted'
105+
id: set-up-homebrew
106+
uses: Homebrew/actions/setup-homebrew@master
107+
- name: Build
108+
run: ./build_macos.sh
109+
- name: Upload Artifact
110+
uses: actions/upload-artifact@v4
111+
with:
112+
name: tools-mac-x64
113+
path: |
114+
bin/openocd-*-mac.zip
115+
bin/riscv-toolchain-*.zip
116+
- name: Add Release Asset
117+
uses: softprops/action-gh-release@v2
118+
if: startsWith(github.ref, 'refs/tags/')
119+
with:
120+
files: |
121+
bin/openocd-*-mac.zip
122+
bin/riscv-toolchain-*.zip
93123
94124
build_linux:
95125
name: Build Linux

build_macos.sh

Lines changed: 54 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,30 @@ set -euo pipefail
55
# Defaults
66
SKIP_RISCV=${SKIP_RISCV-0}
77
SKIP_OPENOCD=${SKIP_OPENOCD-0}
8+
SKIP_PICOTOOL=${SKIP_PICOTOOL-0}
89

910
# Install prerequisites
10-
arch -x86_64 /usr/local/bin/brew install jq libtool libusb automake hidapi jimtcl --quiet
11-
arch -arm64 /opt/homebrew/bin/brew install jq libtool libusb automake hidapi jimtcl --quiet
11+
if [[ $(uname -m) == 'arm64' ]]; then
12+
ARCH_x86="arch -x86_64"
13+
else
14+
ARCH_x86=""
15+
fi
16+
17+
ARCH_x86 /usr/local/bin/brew install jq libtool libusb automake hidapi jimtcl --quiet
18+
if [[ $(uname -m) == 'arm64' ]]; then
19+
arch -arm64 /opt/homebrew/bin/brew install jq libtool libusb automake hidapi jimtcl --quiet
20+
fi
1221
# RISC-V prerequisites
1322
echo "Listing local"
1423
ls /usr/local/bin
1524
rm /usr/local/bin/2to3* || true
1625
rm /usr/local/bin/idle3* || true
1726
rm /usr/local/bin/pip* || true
1827
rm /usr/local/bin/py* || true
19-
arch -x86_64 /usr/local/bin/brew install python3 gawk gnu-sed make gmp mpfr libmpc isl zlib expat texinfo flock libslirp --quiet
20-
arch -arm64 /opt/homebrew/bin/brew install python3 gawk gnu-sed make gmp mpfr libmpc isl zlib expat texinfo flock libslirp --quiet
28+
ARCH_x86 /usr/local/bin/brew install python3 gawk gnu-sed make gmp mpfr libmpc isl zlib expat texinfo flock libslirp --quiet
29+
if [[ $(uname -m) == 'arm64' ]]; then
30+
arch -arm64 /opt/homebrew/bin/brew install python3 gawk gnu-sed make gmp mpfr libmpc isl zlib expat texinfo flock libslirp --quiet
31+
fi
2132

2233
repos=$(cat config/repositories.json | jq -c '.repositories.[]')
2334
export version=$(cat ./version.txt)
@@ -51,7 +62,7 @@ done < <(echo "$repos")
5162

5263

5364
cd $builddir
54-
if [[ "$SKIP_OPENOCD" != 1 ]] && [[ $(uname -m) == 'arm64' ]]; then
65+
if [[ "$SKIP_OPENOCD" != 1 ]]; then
5566
if ! ../packages/macos/openocd/build-openocd.sh; then
5667
echo "::error title=openocd-fail-macos::OpenOCD Build Failed on macOS"
5768
SKIP_OPENOCD=1
@@ -61,35 +72,51 @@ if [[ "$SKIP_RISCV" != 1 ]]; then
6172
# Takes ages to build
6273
../packages/macos/riscv/build-riscv-gcc.sh
6374
fi
64-
arch -x86_64 ../packages/macos/picotool/build-picotool.sh
65-
arch -arm64 ../packages/macos/picotool/build-picotool.sh
66-
../packages/macos/picotool/merge-picotool.sh
75+
if [[ "$SKIP_PICOTOOL" != 1 ]]; then
76+
ARCH_x86 ../packages/macos/picotool/build-picotool.sh
77+
if [[ $(uname -m) == 'arm64' ]]; then
78+
arch -arm64 ../packages/macos/picotool/build-picotool.sh
79+
fi
80+
81+
INSTALLDIR="pico-sdk-tools"
82+
BINDIR="pioasm"
83+
BINNAME="pioasm"
84+
../packages/macos/make-universal.sh
85+
86+
INSTALLDIR="picotool-install"
87+
BINDIR="picotool"
88+
BINNAME="picotool"
89+
../packages/macos/make-universal.sh
90+
fi
6791
cd ..
6892

6993
topd=$PWD
70-
if [ ${version:0:1} -ge 2 ]; then
71-
# Package pico-sdk-tools separately as well
7294

73-
filename="pico-sdk-tools-${version}-${suffix}.zip"
95+
if [[ "$SKIP_PICOTOOL" != 1 ]]; then
96+
if [ ${version:0:1} -ge 2 ]; then
97+
# Package pico-sdk-tools separately as well
7498

75-
echo "Saving pico-sdk-tools package to $filename"
76-
pushd "$builddir/pico-sdk-tools/"
77-
tar -a -cf "$topd/bin/$filename" * .keep
78-
popd
79-
fi
99+
filename="pico-sdk-tools-${version}-${suffix}.zip"
80100

81-
# Package picotool separately as well
82-
version=$("./$builddir/picotool-install/picotool/picotool" version -s)
83-
echo "Picotool version $version"
101+
echo "Saving pico-sdk-tools package to $filename"
102+
pushd "$builddir/pico-sdk-tools/"
103+
tar -a -cf "$topd/bin/$filename" * .keep
104+
popd
105+
fi
106+
107+
# Package picotool separately as well
108+
version=$("./$builddir/picotool-install/picotool/picotool" version -s)
109+
echo "Picotool version $version"
84110

85-
filename="picotool-${version}-${suffix}.zip"
111+
filename="picotool-${version}-${suffix}.zip"
86112

87-
echo "Saving picotool package to $filename"
88-
pushd "$builddir/picotool-install/"
89-
tar -a -cf "$topd/bin/$filename" * .keep
90-
popd
113+
echo "Saving picotool package to $filename"
114+
pushd "$builddir/picotool-install/"
115+
tar -a -cf "$topd/bin/$filename" * .keep
116+
popd
117+
fi
91118

92-
if [[ "$SKIP_OPENOCD" != 1 ]] && [[ $(uname -m) == 'arm64' ]]; then
119+
if [[ "$SKIP_OPENOCD" != 1 ]]; then
93120
# Package OpenOCD separately as well
94121

95122
version=($("./$builddir/openocd-install/usr/local/bin/openocd" --version 2>&1))
@@ -99,7 +126,7 @@ if [[ "$SKIP_OPENOCD" != 1 ]] && [[ $(uname -m) == 'arm64' ]]; then
99126

100127
echo "OpenOCD version $version"
101128

102-
filename="openocd-${version}-arm64-${suffix}.zip"
129+
filename="openocd-${version}-$(uname -m)-${suffix}.zip"
103130

104131
echo "Saving OpenOCD package to $filename"
105132
pushd "$builddir/openocd-install/usr/local/bin"
@@ -113,21 +140,10 @@ if [[ "$SKIP_RISCV" != 1 ]]; then
113140
version=$(echo $version | cut -d "." -f 1)
114141
echo "Risc-V Toolchain version $version"
115142

116-
filename="riscv-toolchain-${version}-arm64-${suffix}.zip"
143+
filename="riscv-toolchain-${version}-$(uname -m)-${suffix}.zip"
117144

118145
echo "Saving RISC-V Toolchain package to $filename"
119146
pushd "$builddir/riscv-install/"
120147
tar -a -cf "$topd/bin/$filename" *
121148
popd
122-
123-
# Package x64-mac riscv toolchain separately as well
124-
version="14"
125-
echo "RISC-V Toolchain version $version"
126-
127-
filename="riscv-toolchain-${version}-x64-mac.zip"
128-
129-
echo "Saving RISC-V Toolchain package to $filename"
130-
pushd "$builddir/riscv-install-x64-mac/"
131-
tar -a -cf "$topd/bin/$filename" *
132-
popd
133149
fi

packages/macos/make-universal.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
rm -rf $INSTALLDIR
6+
mkdir -p $INSTALLDIR
7+
8+
cp -r $INSTALLDIR-arm64/* $INSTALLDIR
9+
touch $INSTALLDIR/.keep
10+
11+
lipo -create -output $INSTALLDIR/$BINDIR/$BINNAME $INSTALLDIR-x86_64/$BINDIR/$BINNAME $INSTALLDIR-arm64/$BINDIR/$BINNAME
12+
13+
for f in $INSTALLDIR-arm64/$BINDIR/*.dylib; do
14+
lipo -create -output $INSTALLDIR/$BINDIR/$(basename $f) $INSTALLDIR-x86_64/$BINDIR/$(basename $f) $INSTALLDIR-arm64/$BINDIR/$(basename $f)
15+
done

packages/macos/openocd/build-openocd.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ cd openocd
1010
./configure --disable-werror
1111
make clean
1212
make
13-
INSTALLDIR="$PWD/../openocd-install/usr/local/bin"
14-
rm -rf "$PWD/../openocd-install"
15-
DESTDIR="$PWD/../openocd-install" make install
13+
INSTALLDIR="$PWD/../openocd-install-$(uname -m)/usr/local/bin"
14+
rm -rf "$PWD/../openocd-install-$(uname -m)"
15+
DESTDIR="$PWD/../openocd-install-$(uname -m)" make install
1616

1717
libusbpath=($(otool -L $INSTALLDIR/openocd | grep libusb))
1818
echo ${libusbpath[0]}

packages/macos/picotool/merge-picotool.sh

Lines changed: 0 additions & 21 deletions
This file was deleted.

packages/macos/riscv/build-riscv-gcc-other.sh

Lines changed: 0 additions & 31 deletions
This file was deleted.

packages/macos/riscv/build-riscv-gcc.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
set -euo pipefail
44

5-
# INSTALLDIR="riscv-install-$(uname -m)"
6-
INSTALLDIR="riscv-install"
5+
INSTALLDIR="riscv-install-$(uname -m)"
76
rm -rf $INSTALLDIR
87
mkdir -p $INSTALLDIR
98

@@ -16,9 +15,3 @@ cd riscv-gnu-toolchain
1615
./configure --prefix=$BUILDDIR/$INSTALLDIR --with-arch=rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb --with-abi=ilp32 --with-multilib-generator="rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb-ilp32--;rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb-ilp32--"
1716
# 4 threads, as 8 threads runs out of memory
1817
gmake -j4
19-
20-
# Make x64 and Windows toolchains, by copying multilib into existing toolchains
21-
cd ..
22-
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
23-
24-
$SCRIPT_DIR/build-riscv-gcc-other.sh "https://buildbot.embecosm.com/job/riscv32-gcc-macos-release/21/artifact/riscv32-embecosm-macos-gcc13.3.0.zip" "x64-mac"

0 commit comments

Comments
 (0)