Skip to content

Commit 8cd44f3

Browse files
committed
ci: add github build&test workflows
1 parent 7b3c09b commit 8cd44f3

File tree

7 files changed

+253
-69
lines changed

7 files changed

+253
-69
lines changed
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
name: Build OpenOCD for Windows, MacOS and Linux
2+
3+
on:
4+
workflow_call: {}
5+
workflow_dispatch: {}
6+
jobs:
7+
build-macos-x86:
8+
runs-on: macos-12
9+
env:
10+
BUILD_DIR: build
11+
OPENOCD_CONFIGURE_OPTS: "--disable-doxygen-html --enable-remote-bitbang"
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: install deps
15+
run: brew install automake texinfo coreutils
16+
- name: build
17+
run: |
18+
export LDFLAGS="-Wl,-framework,CoreFoundation -Wl,-framework,IOKit -Wl,-framework,Security"
19+
20+
export PREFIX="$(realpath $BUILD_DIR)/opt"
21+
export DL_DIR="$(realpath $BUILD_DIR)/dl"
22+
mkdir -p $PREFIX $DL_DIR
23+
24+
#LIBUSB
25+
export LIBUSB_VER=libusb-1.0.26
26+
cd $DL_DIR && wget https://dl.espressif.com/dl/$LIBUSB_VER.tar.gz -O $LIBUSB_VER.tar.gz
27+
tar xzf $LIBUSB_VER.tar.gz && rm $LIBUSB_VER.tar.gz && pushd $LIBUSB_VER && ./bootstrap.sh
28+
./configure --prefix="$PREFIX" --enable-shared=no --enable-static=yes
29+
make install
30+
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
31+
popd
32+
33+
#HIDAPI
34+
export HIDAPI_VER=hidapi-0.14.0
35+
cd $DL_DIR && wget https://dl.espressif.com/dl/hidapi-$HIDAPI_VER.tar.gz -O $HIDAPI_VER.tar.gz
36+
tar xzf $HIDAPI_VER.tar.gz && rm $HIDAPI_VER.tar.gz && pushd hidapi-$HIDAPI_VER && ./bootstrap
37+
./configure --prefix="$PREFIX" --enable-shared=no --enable-static=yes --disable-testgui CFLAGS=-std=gnu99
38+
make install
39+
popd
40+
41+
#LIBJAYLINK
42+
export LIBJAYLINK_VER=libjaylink-0.3.1
43+
cd $DL_DIR && wget https://dl.espressif.com/dl/$LIBJAYLINK_VER.tar.gz -O $LIBJAYLINK_VER.tar.gz
44+
tar xzf $LIBJAYLINK_VER.tar.gz && rm $LIBJAYLINK_VER.tar.gz && pushd $LIBJAYLINK_VER
45+
./autogen.sh
46+
./configure --prefix="$PREFIX" --disable-shared
47+
make install
48+
popd
49+
50+
cd $PREFIX/../..
51+
./bootstrap
52+
./configure --prefix="$PREFIX/openocd" $OPENOCD_CONFIGURE_OPTS
53+
make -j `nproc`
54+
make install-strip
55+
56+
echo "ARTIFACT_PATH=$PREFIX/openocd" >> $GITHUB_ENV
57+
58+
- name: Upload artifact
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: openocd-macos-x86
62+
path: ${{ env.ARTIFACT_PATH }}/*
63+
64+
build-linux:
65+
runs-on: ubuntu-20.04
66+
env:
67+
BUILD_DIR: build
68+
steps:
69+
- uses: actions/checkout@v4
70+
- name: install deps
71+
run: sudo apt-get install libudev-dev systemd --force-yes -y
72+
- name: build
73+
run: |
74+
export PREFIX="$(realpath $BUILD_DIR)/opt"
75+
export DL_DIR="$(realpath $BUILD_DIR)/dl"
76+
mkdir -p $PREFIX $DL_DIR
77+
78+
#LIBUSB
79+
export LIBUSB_VER=libusb-1.0.26
80+
cd $DL_DIR && wget https://dl.espressif.com/dl/$LIBUSB_VER.tar.gz -O $LIBUSB_VER.tar.gz
81+
tar xzf $LIBUSB_VER.tar.gz && rm $LIBUSB_VER.tar.gz && pushd $LIBUSB_VER && ./bootstrap.sh
82+
./configure --prefix="$PREFIX" --enable-shared=no --enable-static=yes
83+
make install
84+
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
85+
popd
86+
87+
#HIDAPI
88+
export HIDAPI_VER=hidapi-0.14.0
89+
cd $DL_DIR && wget https://dl.espressif.com/dl/hidapi-$HIDAPI_VER.tar.gz -O $HIDAPI_VER.tar.gz
90+
tar xzf $HIDAPI_VER.tar.gz && rm $HIDAPI_VER.tar.gz && pushd hidapi-$HIDAPI_VER && ./bootstrap
91+
./configure --prefix="$PREFIX" --enable-shared=no --enable-static=yes --disable-testgui CFLAGS=-std=gnu99
92+
make install
93+
popd
94+
95+
#LIBJAYLINK
96+
export LIBJAYLINK_VER=libjaylink-0.3.1
97+
cd $DL_DIR && wget https://dl.espressif.com/dl/$LIBJAYLINK_VER.tar.gz -O $LIBJAYLINK_VER.tar.gz
98+
tar xzf $LIBJAYLINK_VER.tar.gz && rm $LIBJAYLINK_VER.tar.gz && pushd $LIBJAYLINK_VER
99+
./autogen.sh
100+
./configure --prefix="$PREFIX" --disable-shared
101+
make install
102+
popd
103+
104+
cd $PREFIX/../..
105+
./bootstrap
106+
./configure --prefix="$PREFIX/openocd" $OPENOCD_CONFIGURE_OPTS
107+
make -j `nproc`
108+
make install-strip
109+
110+
echo "ARTIFACT_PATH=$PREFIX/openocd" >> $GITHUB_ENV
111+
112+
- name: Upload artifact
113+
uses: actions/upload-artifact@v4
114+
with:
115+
name: openocd-linux
116+
path: ${{ env.ARTIFACT_PATH }}/*
117+
118+
build-windows:
119+
runs-on: ubuntu-20.04
120+
env:
121+
BUILD_DIR: build
122+
steps:
123+
- uses: actions/checkout@v4
124+
- name: install deps
125+
run: sudo apt-get install libtool-bin libudev-dev gcc-mingw-w64-i686
126+
- name: build
127+
run: |
128+
export PREFIX="$(realpath $BUILD_DIR)/opt"
129+
export DL_DIR="$(realpath $BUILD_DIR)/dl"
130+
mkdir -p $PREFIX $DL_DIR
131+
132+
export CONF_HOST="i686-w64-mingw32"
133+
export PLATFORM_NAME="win32"
134+
export HOST_CC=${CONF_HOST}-gcc
135+
136+
#LIBUSB
137+
export LIBUSB_VER=libusb-1.0.26
138+
cd $DL_DIR && wget https://dl.espressif.com/dl/$LIBUSB_VER.tar.gz -O $LIBUSB_VER.tar.gz
139+
tar xzf $LIBUSB_VER.tar.gz && rm $LIBUSB_VER.tar.gz && pushd $LIBUSB_VER && ./bootstrap.sh
140+
./configure --prefix="$PREFIX" --host=${CONF_HOST} --enable-shared=no --enable-static=yes CC=${HOST_CC}
141+
make install
142+
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
143+
popd
144+
145+
#HIDAPI
146+
export HIDAPI_VER=hidapi-0.14.0
147+
cd $DL_DIR && wget https://dl.espressif.com/dl/hidapi-$HIDAPI_VER.tar.gz -O $HIDAPI_VER.tar.gz
148+
tar xzf $HIDAPI_VER.tar.gz && rm $HIDAPI_VER.tar.gz && pushd hidapi-$HIDAPI_VER && ./bootstrap
149+
./configure --prefix="$PREFIX" --host=${CONF_HOST} --enable-shared=no --enable-static=yes --disable-testgui CC=${HOST_CC} CFLAGS=-std=gnu99
150+
make install
151+
popd
152+
153+
#LIBJAYLINK
154+
export LIBJAYLINK_VER=libjaylink-0.3.1
155+
cd $DL_DIR && wget https://dl.espressif.com/dl/$LIBJAYLINK_VER.tar.gz -O $LIBJAYLINK_VER.tar.gz
156+
tar xzf $LIBJAYLINK_VER.tar.gz && rm $LIBJAYLINK_VER.tar.gz && pushd $LIBJAYLINK_VER
157+
./autogen.sh
158+
./configure --prefix="$PREFIX" --host=${CONF_HOST} --disable-shared CC=${HOST_CC}
159+
make install
160+
popd
161+
162+
#ZLIB
163+
export ZLIB_VER=zlib-1.2.11
164+
cd $DL_DIR && wget https://dl.espressif.com/dl/$ZLIB_VER.tar.xz -O $ZLIB_VER.tar.xz
165+
tar xf $ZLIB_VER.tar.xz && rm $ZLIB_VER.tar.xz && pushd $ZLIB_VER
166+
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
167+
export CPPFLAGS="-I$PREFIX/include/zlib"
168+
export LDFLAGS="-L$PREFIX/lib"
169+
popd
170+
171+
cd $PREFIX/../..
172+
./bootstrap
173+
./configure --prefix="$PREFIX/openocd" --host=${CONF_HOST} $OPENOCD_CONFIGURE_OPTS CC=${HOST_CC}
174+
make -j `nproc`
175+
make install-strip
176+
177+
cp $PREFIX/lib/zlib1.dll $PREFIX/openocd/bin
178+
echo "ARTIFACT_PATH=$PREFIX/openocd" >> $GITHUB_ENV
179+
180+
- name: Upload artifact
181+
uses: actions/upload-artifact@v4
182+
with:
183+
name: openocd-windows
184+
path: ${{ env.ARTIFACT_PATH }}/*

.github/workflows/ci_workflow.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Build and Test OpenOCD Workflow
2+
3+
on:
4+
push:
5+
workflow_dispatch: # (to start the workflow manually)
6+
7+
jobs:
8+
build-openocd:
9+
name: Build OpenOCD
10+
uses: ./.github/workflows/build_openocd.yml
11+
12+
test-openocd:
13+
name: Test OpenOCD
14+
uses: ./.github/workflows/test_openocd.yml
15+
needs: build-openocd

.github/workflows/issue_comment.yml

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

.github/workflows/new_issues.yml

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

.github/workflows/new_prs.yml

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

.github/workflows/test_openocd.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Test OpenOCD
2+
3+
on:
4+
workflow_call: {}
5+
workflow_dispatch: {}
6+
jobs:
7+
run-macos-host:
8+
name: Test OpenOCD on MacOS
9+
runs-on: macos-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
- name: Download files / artifacts from build job
14+
uses: actions/download-artifact@v4
15+
with:
16+
name: openocd-macos-x86
17+
- name: Run OpenOCD
18+
run: chmod +x bin/openocd && ./bin/openocd --version
19+
20+
run-linux-host:
21+
name: Test OpenOCD on Linux
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
- name: Download files / artifacts from build job
27+
uses: actions/download-artifact@v4
28+
with:
29+
name: openocd-linux
30+
- name: Run OpenOCD
31+
run: chmod +x bin/openocd && ./bin/openocd --version
32+
33+
run-win-host:
34+
name: Test OpenOCD on Windows
35+
runs-on: windows-latest
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v4
39+
- name: Download files / artifacts from build job
40+
uses: actions/download-artifact@v4
41+
with:
42+
name: openocd-windows
43+
- name: Run OpenOCD
44+
run: .\bin\openocd --version

contrib/cross-build.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/sh
2-
# SPDX-License-Identifier: GPL-2.0-or-later
32

43
# This is an example of how to do a cross-build of OpenOCD using pkg-config.
54
# Cross-building with pkg-config is deceptively hard and most guides and
@@ -122,11 +121,17 @@ fi
122121
if [ -d $LIBFTDI_SRC ] ; then
123122
mkdir -p $LIBFTDI_BUILD_DIR
124123
cd $LIBFTDI_BUILD_DIR
125-
# libftdi requires libusb1 static libraries, granted by:
126-
# export LIBUSB1_CONFIG="--enable-static ..."
124+
# note : libftdi versions < 1.5 requires libusb1 static
125+
# hint use : # export LIBUSB1_CONFIG="--enable-static ..."
126+
# not needed since libftdi-1.5 when LIBFTDI_CONFIG="-DSTATICLIBS=OFF ..."
127+
128+
# fix <toolchain>.cmake file
129+
ESCAPED_SYSROOT=$(printf '%s\n' "$SYSROOT" | sed -e 's/[\/&]/\\&/g')
130+
sed -i -E "s/(SET\(CMAKE_FIND_ROOT_PATH\s+).+\)/\1${ESCAPED_SYSROOT})/" \
131+
${LIBFTDI_SRC}/cmake/Toolchain-${HOST_TRIPLET}.cmake
132+
127133
cmake $LIBFTDI_CONFIG \
128-
-DLIBUSB_INCLUDE_DIR=${SYSROOT}${PREFIX}/include/libusb-1.0 \
129-
-DLIBUSB_LIBRARIES=${SYSROOT}${PREFIX}/lib/libusb-1.0.a \
134+
-DCMAKE_TOOLCHAIN_FILE=${LIBFTDI_SRC}/cmake/Toolchain-${HOST_TRIPLET}.cmake \
130135
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
131136
-DPKG_CONFIG_EXECUTABLE=`which pkg-config` \
132137
$LIBFTDI_SRC
@@ -165,4 +170,3 @@ make install-strip DESTDIR=$SYSROOT
165170
# Separate OpenOCD install w/o dependencies. OpenOCD will have to be linked
166171
# statically or have dependencies packaged/installed separately.
167172
make install-strip DESTDIR=$PACKAGE_DIR
168-

0 commit comments

Comments
 (0)