Modernize C builds with offline dependencies and portable runtime helpers

This commit is contained in:
Max Lv
2026-09-11 00:00:40 +08:00
parent 8fe386b5c2
commit 4455d7f8f3
110 changed files with 4295 additions and 1480 deletions
+1 -5
View File
@@ -15,8 +15,6 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
@@ -31,7 +29,7 @@ jobs:
- name: Build
run: |
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake .. -DCMAKE_BUILD_TYPE=Release -DSS_DEPENDENCY_MODE=system -DWITH_STATIC=OFF
jobs="$(nproc 2>/dev/null || sysctl -n hw.ncpu)"
make -j"$jobs"
@@ -39,8 +37,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install dependencies
run: |
+104
View File
@@ -0,0 +1,104 @@
name: portability
on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:
jobs:
bundled:
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-latest]
minimal: ['OFF', 'ON']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Build without installed third-party development packages
run: |
cmake -S . -B build -DSS_MINIMAL=${{ matrix.minimal }}
cmake --build build --parallel 4
ctest --test-dir build -L 'unit|vendor' --output-on-failure --no-tests=error
- name: Real TCP and UDP relay
run: python3 tests/interop.py --self --bin build/bin
- name: SIP003 transport and child cleanup
if: matrix.minimal == 'OFF'
run: python3 tests/interop.py --self --bin build/bin --plugin tests/sip003_fixture.py
- name: Relocated installation and public API consumers
run: |
cmake --install build --prefix "$PWD/install"
mv install relocated
cmake -S tests/consumer -B consumer -DCMAKE_PREFIX_PATH="$PWD/relocated"
cmake --build consumer
./consumer/consumer_static
./consumer/consumer_shared
windows:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v6
- uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: true
install: >-
mingw-w64-ucrt-x86_64-gcc
mingw-w64-ucrt-x86_64-cmake
mingw-w64-ucrt-x86_64-ninja
mingw-w64-ucrt-x86_64-python
- name: Build and run native Windows binaries
run: |
cmake -S . -B build -G Ninja
cmake --build build --parallel 4
ctest --test-dir build -L 'unit|vendor' --output-on-failure --no-tests=error
python tests/interop.py --self --bin build/bin
- name: Installed consumers
run: |
cmake --install build --prefix "$PWD/install"
cmake -S tests/consumer -B consumer -G Ninja -DCMAKE_PREFIX_PATH="$PWD/install"
cmake --build consumer
export PATH="$PWD/install/bin:$PATH"
./consumer/consumer_static.exe
./consumer/consumer_shared.exe
freebsd:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: vmactions/freebsd-vm@v1
with:
release: '14.3'
usesh: true
prepare: pkg install -y cmake ninja python3
run: |
cmake -S . -B build -G Ninja
cmake --build build --parallel 4
ctest --test-dir build -L 'unit|vendor' --output-on-failure --no-tests=error
python3 tests/interop.py --self --bin build/bin
offline-musl:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Source archive
run: python3 scripts/source_archive.py release/shadowsocks-libev.tar.gz
- name: Prepare compiler image
run: |
printf 'FROM alpine:3.24\nRUN apk add --no-cache build-base cmake python3 linux-headers\n' > /tmp/ss-toolchain.Dockerfile
docker build -t ss-toolchain -f /tmp/ss-toolchain.Dockerfile /tmp
- name: Build release archive with network disabled
run: |
docker run --rm --network none -v "$PWD/release:/release:ro" ss-toolchain sh -ec '
mkdir /src
tar xzf /release/shadowsocks-libev.tar.gz -C /src --strip-components=1
cmake -S /src -B /build -DCMAKE_DISABLE_FIND_PACKAGE_Python3=TRUE
cmake --build /build --parallel 4
ctest --test-dir /build -L "unit|vendor" --output-on-failure --no-tests=error
python3 /src/tests/interop.py --self --bin /build/bin
'
+20 -12
View File
@@ -15,8 +15,6 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
@@ -47,21 +45,19 @@ jobs:
- name: Stress test
run: |
python3 tests/stress_test.py --bin build/shared/bin/ --size 10
python3 tests/stress_test.py --bin build/bin/ --size 10
- name: ss-redir transparent proxy test (QEMU)
if: runner.os == 'Linux'
run: |
sudo apt-get install -y qemu-system-x86
bash tests/test_redir_qemu.sh build/shared/bin/
bash tests/test_redir_qemu.sh build/bin/
timeout-minutes: 8
asan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install dependencies
run: |
@@ -78,7 +74,7 @@ jobs:
run: ctest --test-dir build -LE memcheck --output-on-failure --no-tests=error
- name: Stress test (ASan + UBSan)
run: python3 tests/stress_test.py --bin build/shared/bin/ --size 10
run: python3 tests/stress_test.py --bin build/bin/ --size 10
clang-tidy:
runs-on: ubuntu-latest
@@ -91,8 +87,6 @@ jobs:
MAX_WARNINGS: 0
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install dependencies
run: |
@@ -128,8 +122,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install dependencies
run: |
@@ -145,7 +137,7 @@ jobs:
- name: Run tests
run: |
ctest --test-dir build -LE memcheck --output-on-failure --no-tests=error
python3 tests/stress_test.py --bin build/shared/bin/ --size 10
python3 tests/stress_test.py --bin build/bin/ --size 10
- name: Generate coverage report
run: |
@@ -162,3 +154,19 @@ jobs:
with:
name: coverage-html
path: build/coverage-html/
interop:
runs-on: macos-latest
steps:
- uses: actions/checkout@v6
- name: Install dependencies and independent peer
run: brew install mbedtls@3 libsodium libev c-ares pcre2 shadowsocks-rust
- name: Build
run: |
cmake -S . -B build -DSS_DEPENDENCY_MODE=system -DWITH_STATIC=OFF
cmake --build build --parallel
- name: Required interoperability
env:
SS_REQUIRE_INTEROP: '1'
SS_BIN_DIR: build/bin
run: bash tests/test_interop_rust.sh