Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 184 additions & 0 deletions .github/workflows/build_openocd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
name: Build OpenOCD for Windows, MacOS and Linux

on:
workflow_call: {}
workflow_dispatch: {}
jobs:
build-macos-x86:
runs-on: macos-12
env:
BUILD_DIR: build
OPENOCD_CONFIGURE_OPTS: "--disable-doxygen-html --enable-remote-bitbang"
steps:
- uses: actions/checkout@v4
- name: install deps
run: brew install automake texinfo coreutils
- name: build
run: |
export LDFLAGS="-Wl,-framework,CoreFoundation -Wl,-framework,IOKit -Wl,-framework,Security"

export PREFIX="$(realpath $BUILD_DIR)/opt"
export DL_DIR="$(realpath $BUILD_DIR)/dl"
mkdir -p $PREFIX $DL_DIR

#LIBUSB
export LIBUSB_VER=libusb-1.0.26
cd $DL_DIR && wget https://dl.espressif.com/dl/$LIBUSB_VER.tar.gz -O $LIBUSB_VER.tar.gz
tar xzf $LIBUSB_VER.tar.gz && rm $LIBUSB_VER.tar.gz && pushd $LIBUSB_VER && ./bootstrap.sh
./configure --prefix="$PREFIX" --enable-shared=no --enable-static=yes
make install
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
popd

#HIDAPI
export HIDAPI_VER=hidapi-0.14.0
cd $DL_DIR && wget https://dl.espressif.com/dl/hidapi-$HIDAPI_VER.tar.gz -O $HIDAPI_VER.tar.gz
tar xzf $HIDAPI_VER.tar.gz && rm $HIDAPI_VER.tar.gz && pushd hidapi-$HIDAPI_VER && ./bootstrap
./configure --prefix="$PREFIX" --enable-shared=no --enable-static=yes --disable-testgui CFLAGS=-std=gnu99
make install
popd

#LIBJAYLINK
export LIBJAYLINK_VER=libjaylink-0.3.1
cd $DL_DIR && wget https://dl.espressif.com/dl/$LIBJAYLINK_VER.tar.gz -O $LIBJAYLINK_VER.tar.gz
tar xzf $LIBJAYLINK_VER.tar.gz && rm $LIBJAYLINK_VER.tar.gz && pushd $LIBJAYLINK_VER
./autogen.sh
./configure --prefix="$PREFIX" --disable-shared
make install
popd

cd $PREFIX/../..
./bootstrap
./configure --prefix="$PREFIX/openocd" $OPENOCD_CONFIGURE_OPTS
make -j `nproc`
make install-strip

echo "ARTIFACT_PATH=$PREFIX/openocd" >> $GITHUB_ENV

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: openocd-macos-x86
path: ${{ env.ARTIFACT_PATH }}/*

build-linux:
runs-on: ubuntu-20.04
env:
BUILD_DIR: build
steps:
- uses: actions/checkout@v4
- name: install deps
run: sudo apt-get install libudev-dev systemd --force-yes -y
- name: build
run: |
export PREFIX="$(realpath $BUILD_DIR)/opt"
export DL_DIR="$(realpath $BUILD_DIR)/dl"
mkdir -p $PREFIX $DL_DIR

#LIBUSB
export LIBUSB_VER=libusb-1.0.26
cd $DL_DIR && wget https://dl.espressif.com/dl/$LIBUSB_VER.tar.gz -O $LIBUSB_VER.tar.gz
tar xzf $LIBUSB_VER.tar.gz && rm $LIBUSB_VER.tar.gz && pushd $LIBUSB_VER && ./bootstrap.sh
./configure --prefix="$PREFIX" --enable-shared=no --enable-static=yes
make install
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
popd

#HIDAPI
export HIDAPI_VER=hidapi-0.14.0
cd $DL_DIR && wget https://dl.espressif.com/dl/hidapi-$HIDAPI_VER.tar.gz -O $HIDAPI_VER.tar.gz
tar xzf $HIDAPI_VER.tar.gz && rm $HIDAPI_VER.tar.gz && pushd hidapi-$HIDAPI_VER && ./bootstrap
./configure --prefix="$PREFIX" --enable-shared=no --enable-static=yes --disable-testgui CFLAGS=-std=gnu99
make install
popd

#LIBJAYLINK
export LIBJAYLINK_VER=libjaylink-0.3.1
cd $DL_DIR && wget https://dl.espressif.com/dl/$LIBJAYLINK_VER.tar.gz -O $LIBJAYLINK_VER.tar.gz
tar xzf $LIBJAYLINK_VER.tar.gz && rm $LIBJAYLINK_VER.tar.gz && pushd $LIBJAYLINK_VER
./autogen.sh
./configure --prefix="$PREFIX" --disable-shared
make install
popd

cd $PREFIX/../..
./bootstrap
./configure --prefix="$PREFIX/openocd" $OPENOCD_CONFIGURE_OPTS
make -j `nproc`
make install-strip

echo "ARTIFACT_PATH=$PREFIX/openocd" >> $GITHUB_ENV

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: openocd-linux
path: ${{ env.ARTIFACT_PATH }}/*

build-windows:
runs-on: ubuntu-20.04
env:
BUILD_DIR: build
steps:
- uses: actions/checkout@v4
- name: install deps
run: sudo apt-get install libtool-bin libudev-dev gcc-mingw-w64-i686
- name: build
run: |
export PREFIX="$(realpath $BUILD_DIR)/opt"
export DL_DIR="$(realpath $BUILD_DIR)/dl"
mkdir -p $PREFIX $DL_DIR

export CONF_HOST="i686-w64-mingw32"
export PLATFORM_NAME="win32"
export HOST_CC=${CONF_HOST}-gcc

#LIBUSB
export LIBUSB_VER=libusb-1.0.26
cd $DL_DIR && wget https://dl.espressif.com/dl/$LIBUSB_VER.tar.gz -O $LIBUSB_VER.tar.gz
tar xzf $LIBUSB_VER.tar.gz && rm $LIBUSB_VER.tar.gz && pushd $LIBUSB_VER && ./bootstrap.sh
./configure --prefix="$PREFIX" --host=${CONF_HOST} --enable-shared=no --enable-static=yes CC=${HOST_CC}
make install
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
popd

#HIDAPI
export HIDAPI_VER=hidapi-0.14.0
cd $DL_DIR && wget https://dl.espressif.com/dl/hidapi-$HIDAPI_VER.tar.gz -O $HIDAPI_VER.tar.gz
tar xzf $HIDAPI_VER.tar.gz && rm $HIDAPI_VER.tar.gz && pushd hidapi-$HIDAPI_VER && ./bootstrap
./configure --prefix="$PREFIX" --host=${CONF_HOST} --enable-shared=no --enable-static=yes --disable-testgui CC=${HOST_CC} CFLAGS=-std=gnu99
make install
popd

#LIBJAYLINK
export LIBJAYLINK_VER=libjaylink-0.3.1
cd $DL_DIR && wget https://dl.espressif.com/dl/$LIBJAYLINK_VER.tar.gz -O $LIBJAYLINK_VER.tar.gz
tar xzf $LIBJAYLINK_VER.tar.gz && rm $LIBJAYLINK_VER.tar.gz && pushd $LIBJAYLINK_VER
./autogen.sh
./configure --prefix="$PREFIX" --host=${CONF_HOST} --disable-shared CC=${HOST_CC}
make install
popd

#ZLIB
export ZLIB_VER=zlib-1.2.11
cd $DL_DIR && wget https://dl.espressif.com/dl/$ZLIB_VER.tar.xz -O $ZLIB_VER.tar.xz
tar xf $ZLIB_VER.tar.xz && rm $ZLIB_VER.tar.xz && pushd $ZLIB_VER
make -f win32/Makefile.gcc BINARY_PATH=$PREFIX/lib INCLUDE_PATH=$PREFIX/include/zlib LIBRARY_PATH=$PREFIX/lib SHARED_MODE=1 PREFIX=${CONF_HOST}- install
export CPPFLAGS="-I$PREFIX/include/zlib"
export LDFLAGS="-L$PREFIX/lib"
popd

cd $PREFIX/../..
./bootstrap
./configure --prefix="$PREFIX/openocd" --host=${CONF_HOST} $OPENOCD_CONFIGURE_OPTS CC=${HOST_CC}
make -j `nproc`
make install-strip

cp $PREFIX/lib/zlib1.dll $PREFIX/openocd/bin
echo "ARTIFACT_PATH=$PREFIX/openocd" >> $GITHUB_ENV

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: openocd-windows
path: ${{ env.ARTIFACT_PATH }}/*
15 changes: 15 additions & 0 deletions .github/workflows/ci_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Build and Test OpenOCD Workflow

on:
push:
workflow_dispatch: # (to start the workflow manually)

jobs:
build-openocd:
name: Build OpenOCD
uses: ./.github/workflows/build_openocd.yml

test-openocd:
name: Test OpenOCD
uses: ./.github/workflows/test_openocd.yml
needs: build-openocd
19 changes: 0 additions & 19 deletions .github/workflows/issue_comment.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/new_issues.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/workflows/new_prs.yml

This file was deleted.

44 changes: 44 additions & 0 deletions .github/workflows/test_openocd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Test OpenOCD

on:
workflow_call: {}
workflow_dispatch: {}
jobs:
run-macos-host:
name: Test OpenOCD on MacOS
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download files / artifacts from build job
uses: actions/download-artifact@v4
with:
name: openocd-macos-x86
- name: Run OpenOCD
run: chmod +x bin/openocd && ./bin/openocd --version

run-linux-host:
name: Test OpenOCD on Linux
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download files / artifacts from build job
uses: actions/download-artifact@v4
with:
name: openocd-linux
- name: Run OpenOCD
run: chmod +x bin/openocd && ./bin/openocd --version

run-win-host:
name: Test OpenOCD on Windows
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download files / artifacts from build job
uses: actions/download-artifact@v4
with:
name: openocd-windows
- name: Run OpenOCD
run: .\bin\openocd --version
16 changes: 10 additions & 6 deletions contrib/cross-build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later

# This is an example of how to do a cross-build of OpenOCD using pkg-config.
# Cross-building with pkg-config is deceptively hard and most guides and
Expand Down Expand Up @@ -122,11 +121,17 @@ fi
if [ -d $LIBFTDI_SRC ] ; then
mkdir -p $LIBFTDI_BUILD_DIR
cd $LIBFTDI_BUILD_DIR
# libftdi requires libusb1 static libraries, granted by:
# export LIBUSB1_CONFIG="--enable-static ..."
# note : libftdi versions < 1.5 requires libusb1 static
# hint use : # export LIBUSB1_CONFIG="--enable-static ..."
# not needed since libftdi-1.5 when LIBFTDI_CONFIG="-DSTATICLIBS=OFF ..."

# fix <toolchain>.cmake file
ESCAPED_SYSROOT=$(printf '%s\n' "$SYSROOT" | sed -e 's/[\/&]/\\&/g')
sed -i -E "s/(SET\(CMAKE_FIND_ROOT_PATH\s+).+\)/\1${ESCAPED_SYSROOT})/" \
${LIBFTDI_SRC}/cmake/Toolchain-${HOST_TRIPLET}.cmake

cmake $LIBFTDI_CONFIG \
-DLIBUSB_INCLUDE_DIR=${SYSROOT}${PREFIX}/include/libusb-1.0 \
-DLIBUSB_LIBRARIES=${SYSROOT}${PREFIX}/lib/libusb-1.0.a \
-DCMAKE_TOOLCHAIN_FILE=${LIBFTDI_SRC}/cmake/Toolchain-${HOST_TRIPLET}.cmake \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DPKG_CONFIG_EXECUTABLE=`which pkg-config` \
$LIBFTDI_SRC
Expand Down Expand Up @@ -165,4 +170,3 @@ make install-strip DESTDIR=$SYSROOT
# Separate OpenOCD install w/o dependencies. OpenOCD will have to be linked
# statically or have dependencies packaged/installed separately.
make install-strip DESTDIR=$PACKAGE_DIR