Skip to content

Commit

Permalink
Skip openocd if git2cl clone is failing
Browse files Browse the repository at this point in the history
  • Loading branch information
will-v-pi committed Aug 30, 2024
1 parent 76c579e commit c4355a7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
with:
ssh-private-key: ${{ secrets.SSH_KEY }}
- name: Build
run: SKIP_RISCV=0 ./build_macos.sh
run: ./build_macos.sh
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
with:
ssh-private-key: ${{ secrets.SSH_KEY }}
- name: Build
run: SKIP_RISCV=0 ./build_linux.sh
run: ./build_linux.sh
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
Expand Down
38 changes: 26 additions & 12 deletions build_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

set -euo pipefail

# Defaults
SKIP_RISCV=${SKIP_RISCV-0}
if git clone https://git.savannah.nongnu.org/git/git2cl.git; then
SKIP_OPENOCD=${SKIP_OPENOCD-0}
else
# Clone is failing, so skip build
echo "Skipping openocd build, as likely to fail"
SKIP_OPENOCD=${SKIP_OPENOCD-1}
fi

# Install prerequisites
sudo apt install -y jq cmake libtool automake libusb-1.0-0-dev libhidapi-dev libftdi1-dev
# Risc-V prerequisites
Expand Down Expand Up @@ -36,7 +46,9 @@ if [[ "$SKIP_RISCV" != 1 ]]; then
# Takes ages to build
../packages/linux/riscv/build-riscv-gcc.sh
fi
../packages/linux/openocd/build-openocd.sh
if [[ "$SKIP_OPENOCD" != 1 ]]; then
../packages/linux/openocd/build-openocd.sh
fi
../packages/linux/picotool/build-picotool.sh
cd ..

Expand Down Expand Up @@ -64,21 +76,23 @@ pushd "$builddir/picotool-install/"
tar -a -cf "$topd/bin/$filename" * .keep
popd

# Package OpenOCD separately as well
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)
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"
echo "OpenOCD version $version"

filename="openocd-${version}-${suffix}.tar.gz"
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
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
Expand Down
14 changes: 12 additions & 2 deletions build_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

set -euo pipefail

# Defaults
SKIP_RISCV=${SKIP_RISCV-0}
if git clone https://git.savannah.nongnu.org/git/git2cl.git; then
SKIP_OPENOCD=${SKIP_OPENOCD-0}
else
# Clone is failing, so skip build
echo "Skipping openocd build, as likely to fail"
SKIP_OPENOCD=${SKIP_OPENOCD-1}
fi

# Install prerequisites
arch -x86_64 /usr/local/bin/brew install jq libtool libusb automake hidapi
arch -arm64 /opt/homebrew/bin/brew install jq libtool libusb automake hidapi
Expand Down Expand Up @@ -47,7 +57,7 @@ if [[ "$SKIP_RISCV" != 1 ]]; then
# Takes ages to build
../packages/macos/riscv/build-riscv-gcc.sh
fi
if [[ $(uname -m) == 'arm64' ]]; then
if [[ "$SKIP_OPENOCD" != 1 ]] && [[ $(uname -m) == 'arm64' ]]; then
../packages/macos/openocd/build-openocd.sh
fi
arch -x86_64 ../packages/macos/picotool/build-picotool.sh
Expand Down Expand Up @@ -78,7 +88,7 @@ pushd "$builddir/picotool-install/"
tar -a -cf "$topd/bin/$filename" * .keep
popd

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

version=($("./$builddir/openocd-install/usr/local/bin/openocd" --version 2>&1))
Expand Down

0 comments on commit c4355a7

Please sign in to comment.