-
Notifications
You must be signed in to change notification settings - Fork 5
/
build_linux.sh
executable file
·109 lines (85 loc) · 3.01 KB
/
build_linux.sh
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
#!/bin/bash
set -euo pipefail
# Defaults
SKIP_RISCV=${SKIP_RISCV-0}
SKIP_OPENOCD=${SKIP_OPENOCD-0}
# Install prerequisites
sudo apt install -y jq cmake libtool automake libusb-1.0-0-dev libhidapi-dev libftdi1-dev
# RISC-V prerequisites
sudo apt install -y autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev ninja-build git cmake libglib2.0-dev libslirp-dev
# RPi Only prerequisites
if [[ $(uname -m) == 'aarch64' ]]; then
sudo apt install -y libgpiod-dev
fi
repos=$(cat config/repositories.json | jq -c '.repositories[]')
export version=$(cat ./version.txt)
suffix="$(uname -m)-lin"
builddir="build"
mkdir -p $builddir
mkdir -p "bin"
while read -r repo
do
tree=$(echo "$repo" | jq -r .tree)
href=$(echo "$repo" | jq -r .href)
filename=$(basename -- "$href")
extension="${filename##*.}"
filename="${filename%.*}"
filename=${filename%"-rp2350"}
repodir="$builddir/${filename}"
echo "${href} ${tree} ${filename} ${extension} ${repodir}"
rm -rf "${repodir}"
git clone -b "${tree}" --depth=1 -c advice.detachedHead=false "${href}" "${repodir}"
done < <(echo "$repos")
cd $builddir
if [[ "$SKIP_OPENOCD" != 1 ]]; then
if ! ../packages/linux/openocd/build-openocd.sh; then
echo "OpenOCD Build failed"
SKIP_OPENOCD=1
fi
fi
if [[ "$SKIP_RISCV" != 1 ]]; then
# Takes ages to build
../packages/linux/riscv/build-riscv-gcc.sh
fi
../packages/linux/picotool/build-picotool.sh
cd ..
topd=$PWD
if [ ${version:0:1} -ge 2 ]; then
# Package pico-sdk-tools separately as well
filename="pico-sdk-tools-${version}-${suffix}.tar.gz"
echo "Saving pico-sdk-tools package to $filename"
pushd "$builddir/pico-sdk-tools/"
tar -a -cf "$topd/bin/$filename" * .keep
popd
fi
# Package picotool separately as well
version=$("./$builddir/picotool-install/picotool/picotool" version -s)
echo "Picotool version $version"
filename="picotool-${version}-${suffix}.tar.gz"
echo "Saving picotool package to $filename"
pushd "$builddir/picotool-install/"
tar -a -cf "$topd/bin/$filename" * .keep
popd
if [[ "$SKIP_OPENOCD" != 1 ]]; then
# Package OpenOCD separately as well
version=($("./$builddir/openocd-install/usr/local/bin/openocd" --version 2>&1))
version=${version[0]}
version=${version[3]}
version=$(echo $version | cut -d "-" -f 1)
echo "OpenOCD version $version"
filename="openocd-${version}-${suffix}.tar.gz"
echo "Saving OpenOCD package to $filename"
pushd "$builddir/openocd-install/usr/local/bin"
tar -a -cf "$topd/bin/$filename" * -C "../share/openocd" "scripts"
popd
fi
if [[ "$SKIP_RISCV" != 1 ]]; then
# Package riscv toolchain separately as well
version="14"
echo "RISC-V Toolchain version $version"
filename="riscv-toolchain-${version}-${suffix}.tar.gz"
echo "Saving RISC-V Toolchain package to $filename"
pushd "$builddir/riscv-install/"
tar -a -cf "$topd/bin/$filename" *
popd
fi