Skip to content

Commit a0eb377

Browse files
committed
add Dockerfile, enable PR build, and improve documentation
* fix hybrid build
1 parent bc4b16d commit a0eb377

File tree

4 files changed

+137
-68
lines changed

4 files changed

+137
-68
lines changed

.github/workflows/pru.yaml

Lines changed: 61 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,98 @@
11
name: prudynt-t
22
on:
33
workflow_dispatch:
4+
pull_request:
5+
branches:
6+
- '**'
47

58
env:
69
TAG_NAME: release
7-
TOOLCHAIN_MUSL: /home/runner/work/prudynt-t/prudynt-t/mipsel-thingino-linux-musl_sdk-buildroot/bin/mipsel-linux-
10+
TOOLCHAIN_URL: https://github.com/themactep/thingino-firmware/releases/download/toolchain-x86_64/thingino-toolchain-x86_64_xburst1_4_4_musl_gcc14-linux-mipsel.tar.gz
11+
TOOLCHAIN_DIR: /opt/mipsel-thingino-linux-musl_sdk-buildroot
12+
CCACHE_DIR: ${{ github.workspace }}/.ccache
813

914
jobs:
10-
buildroot:
11-
name: prudynt
15+
native-build:
16+
name: prudynt-build
1217
runs-on: ubuntu-latest
1318
strategy:
1419
fail-fast: false
1520
matrix:
16-
include:
17-
- target: T10
18-
build_type: static
19-
- target: T20
20-
build_type: static
21-
- target: T21
22-
build_type: static
23-
- target: T23
24-
build_type: static
25-
- target: T30
26-
build_type: static
27-
- target: T31
28-
build_type: static
29-
- target: C100
30-
build_type: static
31-
- target: T10
32-
build_type: dynamic
33-
- target: T20
34-
build_type: dynamic
35-
- target: T21
36-
build_type: dynamic
37-
- target: T23
38-
build_type: dynamic
39-
- target: T30
40-
build_type: dynamic
41-
- target: T31
42-
build_type: dynamic
43-
- target: C100
44-
build_type: dynamic
21+
target:
22+
- T10
23+
- T20
24+
- T21
25+
- T23
26+
- T30
27+
- T31
28+
- C100
29+
build_type:
30+
- static
31+
- dynamic
32+
- hybrid
4533

4634
steps:
4735
- name: Checkout source
4836
uses: actions/checkout@v4
4937
with:
50-
submodules: 'true'
38+
submodules: true
5139

52-
- name: Setup cache directories
40+
- name: Install dependencies
5341
run: |
54-
mkdir -p /tmp/ccache
55-
ln -s /tmp/ccache ${HOME}/.ccache
42+
sudo apt-get update
43+
sudo apt-get install -y --no-install-recommends --no-install-suggests \
44+
build-essential bc bison cpio curl file flex git libncurses-dev \
45+
make rsync unzip wget whiptail gcc lzop u-boot-tools \
46+
ca-certificates cmake ccache
5647
57-
- name: Setup ccache
58-
uses: actions/cache@v4
59-
if: always()
60-
with:
61-
path: /tmp/ccache
62-
key: ${{ runner.os }}-ccache-${{ github.sha }}
63-
restore-keys: |
64-
${{ runner.os }}-ccache-
65-
66-
- name: Update system sources
67-
run: sudo apt-get update
68-
69-
- name: Install build dependencies
48+
- name: Download and extract toolchain
7049
run: |
71-
sudo apt-get install -y --no-install-recommends --no-install-suggests build-essential bc bison cpio curl file flex git libncurses-dev make rsync unzip wget whiptail gcc lzop u-boot-tools ca-certificates ccache
50+
mkdir -p /opt
51+
cd /opt
52+
wget "$TOOLCHAIN_URL" -O thingino-toolchain.tar.gz
53+
tar -xf thingino-toolchain.tar.gz
54+
cd mipsel-thingino-linux-musl_sdk-buildroot
55+
./relocate-sdk.sh
7256
73-
- name: Download toolchain
57+
- name: Set up toolchain and ccache env vars
7458
run: |
75-
wget https://github.com/themactep/thingino-firmware/releases/download/toolchain/thingino-toolchain_xburst1_musl_gcc14-linux-mipsel.tar.gz
76-
tar -xf thingino-toolchain_xburst1_musl_gcc14-linux-mipsel.tar.gz
77-
cd mipsel-thingino-linux-musl_sdk-buildroot; ./relocate-sdk.sh
78-
cd ../
59+
echo "TOOLCHAIN_DIR=${TOOLCHAIN_DIR}" >> $GITHUB_ENV
60+
echo "PATH=${TOOLCHAIN_DIR}/bin:/usr/lib/ccache:$PATH" >> $GITHUB_ENV
61+
echo "CC=ccache ${TOOLCHAIN_DIR}/bin/mipsel-linux-gcc" >> $GITHUB_ENV
62+
echo "CXX=ccache ${TOOLCHAIN_DIR}/bin/mipsel-linux-g++" >> $GITHUB_ENV
63+
echo "PRUDYNT_CROSS=ccache ${TOOLCHAIN_DIR}/bin/mipsel-linux-" >> $GITHUB_ENV
7964
80-
- name: Build deps for target
65+
- name: Restore ccache
66+
id: restore-ccache
67+
if: always()
68+
uses: actions/cache@v4
69+
with:
70+
path: ${{ github.workspace }}/.ccache
71+
key: ccache-${{ matrix.target }}-${{ matrix.build_type }}-${{ github.sha }}
72+
73+
- name: Set build suffix
74+
id: suffix
8175
run: |
82-
PRUDYNT_CROSS="ccache $TOOLCHAIN_MUSL" ./build.sh deps ${{ matrix.target }} ${{ matrix.build_type == 'static' && '-static' || '' }}
76+
case "${{ matrix.build_type }}" in
77+
static) echo "SUFFIX=-static" >> $GITHUB_ENV ;;
78+
hybrid) echo "SUFFIX=-hybrid" >> $GITHUB_ENV ;;
79+
*) echo "SUFFIX=" >> $GITHUB_ENV ;;
80+
esac
8381
84-
- name: Build prudynt for target
82+
- name: Build deps
8583
run: |
86-
PRUDYNT_CROSS="$TOOLCHAIN_MUSL" ./build.sh prudynt ${{ matrix.target }} ${{ matrix.build_type == 'static' && '-static' || '' }}
84+
./build.sh deps ${{ matrix.target }} $SUFFIX
8785
88-
- name: Rename prudynt for release
86+
- name: Build prudynt
8987
run: |
90-
mv bin/prudynt bin/prudynt-${{ matrix.target }}-${{ matrix.build_type }}
88+
./build.sh prudynt ${{ matrix.target }} $SUFFIX
89+
mv bin/prudynt "bin/prudynt-${{ matrix.target }}-${{ matrix.build_type }}"
9190
9291
- name: Upload binary as artifact
9392
uses: actions/upload-artifact@v4
9493
with:
9594
name: prudynt-${{ matrix.target }}-${{ matrix.build_type }}
96-
path: |
97-
bin/prudynt-${{ matrix.target }}-${{ matrix.build_type }}
95+
path: bin/prudynt-${{ matrix.target }}-${{ matrix.build_type }}
9896

9997
- name: Upload binary to release
10098
if: github.event_name != 'pull_request'

Dockerfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM --platform=linux/amd64 debian:bookworm-slim
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
WORKDIR /src
6+
7+
RUN apt-get update && \
8+
apt-get install -y --no-install-recommends --no-install-suggests \
9+
build-essential bc bison cpio curl file flex git libncurses-dev \
10+
make rsync unzip wget whiptail gcc lzop u-boot-tools \
11+
ca-certificates cmake && \
12+
rm -rf /var/lib/apt/lists/*
13+
14+
ENV TOOLCHAIN_URL=https://github.com/themactep/thingino-firmware/releases/download/toolchain-x86_64/thingino-toolchain-x86_64_xburst1_4_4_musl_gcc14-linux-mipsel.tar.gz
15+
ENV TOOLCHAIN_DIR=/opt/mipsel-thingino-linux-musl_sdk-buildroot
16+
17+
RUN mkdir -p /opt && \
18+
cd /opt && \
19+
wget "$TOOLCHAIN_URL" -O thingino-toolchain.tar.gz && \
20+
tar -xf thingino-toolchain.tar.gz && \
21+
cd mipsel-thingino-linux-musl_sdk-buildroot && \
22+
./relocate-sdk.sh
23+
24+
ENV PATH="${TOOLCHAIN_DIR}/bin:${PATH}"
25+
ENV CC="${TOOLCHAIN_DIR}/bin/mipsel-linux-gcc"
26+
ENV CXX="${TOOLCHAIN_DIR}/bin/mipsel-linux-g++"
27+
28+
ARG TARGET=T31
29+
ARG BUILD_TYPE=static
30+
31+
ENV TARGET=${TARGET}
32+
ENV BUILD_TYPE=${BUILD_TYPE}
33+
34+
COPY . /deps
35+
36+
RUN bash -c 'case "$BUILD_TYPE" in \
37+
static) \
38+
SUFFIX="-static";; \
39+
hybrid) \
40+
SUFFIX="-hybrid";; \
41+
*) \
42+
SUFFIX="";; \
43+
esac && export SUFFIX'
44+
45+
RUN cd /deps && PRUDYNT_CROSS="mipsel-linux-" ./build.sh deps $TARGET $SUFFIX
46+
47+
CMD cp -r /deps/3rdparty /src && \
48+
PRUDYNT_CROSS="mipsel-linux-" ./build.sh prudynt $TARGET $SUFFIX && \
49+
mv bin/prudynt "bin/prudynt-${TARGET}-${BUILD_TYPE}"

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,28 @@
99
- **Expanded Configuration**: Integrated support for **[libimp_control](https://github.com/gtxaspec/libimp_control)**.
1010
- **Thingino Integration**: Seamlessly integrates with **[thingino](https://github.com/themactep/thingino-firmware)**, enhancing connectivity and control options.
1111

12+
## Building
13+
14+
The best and most binary-compatible way to build prudynt-t is by using `buildroot_dev.sh` within the [Thingino buildroot](https://github.com/themactep/thingino-firmware/wiki/Development) environment. Alternatively, you can use the following Docker image for a more isolated setup:
15+
```
16+
# Clone the repo
17+
git clone https://github.com/your-user/prudynt-t.git
18+
cd prudynt-t
19+
20+
# Update submodules
21+
git submodule update --init
22+
23+
# Build for a specific target and build type
24+
docker build \
25+
--build-arg TARGET=T31 \
26+
--build-arg BUILD_TYPE=dynamic \
27+
-t prudynt-builder .
28+
29+
docker run --rm -v "$(pwd):/src" prudynt-builder
30+
31+
# You will find the resulting binary at: bin/
32+
```
33+
1234
## Contributing
1335

1436
Contributions to prudynt-t are welcome! If you have improvements, bug fixes, or new features, please feel free to submit a pull request or open an issue.

build.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ deps() {
3838

3939
echo "Build libhelix-aac"
4040
cd 3rdparty
41-
if [[ "$2" == "-static" ]]; then
41+
if [[ "$2" == "-static" || "$2" == "-hybrid" ]]; then
4242
PRUDYNT_CROSS=$PRUDYNT_CROSS ../scripts/make_libhelixaac_deps.sh -static
4343
else
4444
PRUDYNT_CROSS=$PRUDYNT_CROSS ../scripts/make_libhelixaac_deps.sh
@@ -56,7 +56,7 @@ deps() {
5656

5757
echo "Build opus"
5858
cd 3rdparty
59-
if [[ "$2" == "-static" ]]; then
59+
if [[ "$2" == "-static" || "$2" == "-hybrid" ]]; then
6060
PRUDYNT_CROSS=$PRUDYNT_CROSS ../scripts/make_opus_deps.sh -static
6161
else
6262
PRUDYNT_CROSS=$PRUDYNT_CROSS ../scripts/make_opus_deps.sh
@@ -71,7 +71,7 @@ deps() {
7171
git apply ../../res/libschrift.patch
7272
mkdir -p $TOP/3rdparty/install/lib
7373
mkdir -p $TOP/3rdparty/install/include
74-
if [[ "$2" == "-static" ]]; then
74+
if [[ "$2" == "-static" || "$2" == "-hybrid" ]]; then
7575
${PRUDYNT_CROSS}gcc -std=c99 -pedantic -Wall -Wextra -Wconversion -c -o schrift.o schrift.c
7676
${PRUDYNT_CROSS}ar rc libschrift.a schrift.o
7777
${PRUDYNT_CROSS}ranlib libschrift.a
@@ -108,7 +108,7 @@ deps() {
108108
make distclean
109109
fi
110110

111-
if [[ "$2" == "-static" ]]; then
111+
if [[ "$2" == "-static" || "$2" == "-hybrid" ]]; then
112112
echo "STATIC LIVE555"
113113
cp ../../res/live555-config.prudynt-static ./config.prudynt-static
114114
./genMakefiles prudynt-static
@@ -203,7 +203,7 @@ deps() {
203203
cd faac
204204
sed -i 's/^#define MAX_CHANNELS 64/#define MAX_CHANNELS 2/' libfaac/coder.h
205205
./bootstrap
206-
if [[ "$2" == "-static" ]]; then
206+
if [[ "$2" == "-static" || "$2" == "-hybrid" ]]; then
207207
CC="${PRUDYNT_CROSS}gcc" ./configure --host mipsel-linux-gnu --prefix="$TOP/3rdparty/install" --enable-static --disable-shared
208208
else
209209
CC="${PRUDYNT_CROSS}gcc" ./configure --host mipsel-linux-gnu --prefix="$TOP/3rdparty/install" --disable-static --enable-shared

0 commit comments

Comments
 (0)