Skip to content

Commit 80ccf7d

Browse files
committed
Add Alpine Linux build support and musl libc detection
This commit adds support for building ring-ftp on Alpine Linux by: - Creating a new GitHub Actions workflow for Alpine builds using Docker - Adding musl libc auto-detection in CMakeLists.txt - Updating the main workflow to include Alpine builds in the pipeline
1 parent fc9fbaa commit 80ccf7d

3 files changed

Lines changed: 83 additions & 2 deletions

File tree

.github/workflows/alpine_build.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Alpine Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ring-version:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
build:
12+
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || 'ubuntu-24.04-arm' }}
13+
strategy:
14+
matrix:
15+
include:
16+
- arch: amd64
17+
name: alpine-amd64
18+
- arch: arm64
19+
name: alpine-arm64
20+
21+
steps:
22+
- name: Checkout ring-ftp
23+
uses: actions/checkout@v4
24+
with:
25+
submodules: recursive
26+
27+
- name: Build in Alpine container
28+
run: |
29+
docker run --rm \
30+
-v ${{ github.workspace }}:/workspace \
31+
-w /workspace \
32+
alpine:latest /bin/sh -c "
33+
apk add --no-cache cmake ninja gcc g++ musl-dev linux-headers git curl-dev
34+
35+
# Clone Ring Language
36+
git clone --branch ${{ inputs.ring-version }} --depth 1 https://github.com/ring-lang/ring.git ring
37+
38+
# Build Ring Language
39+
cd ring/language
40+
cmake . -DCMAKE_BUILD_TYPE=Release -GNinja
41+
ninja install
42+
cd /workspace
43+
44+
# Build ring-ftp lib
45+
rm -rf lib
46+
cmake . -DCMAKE_BUILD_TYPE=Release -DRING_ROOT=/workspace/ring -DMUSL=ON -GNinja
47+
ninja
48+
"
49+
50+
- name: Upload artifacts
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: ring-ftp-${{ matrix.name }}
54+
path: lib

.github/workflows/main.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ on:
2020
- 'src/c_src/ftpclient'
2121

2222
jobs:
23+
alpine:
24+
uses: ./.github/workflows/alpine_build.yml
25+
with:
26+
ring-version: v1.24
27+
2328
freebsd:
2429
uses: ./.github/workflows/freebsd_build.yml
2530
with:
@@ -42,7 +47,7 @@ jobs:
4247

4348
update-libs:
4449
runs-on: ubuntu-latest
45-
needs: [ freebsd, macos, ubuntu, windows ]
50+
needs: [ alpine, freebsd, macos, ubuntu, windows ]
4651
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
4752

4853
permissions:

CMakeLists.txt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,30 @@ if(NOT DEFINED ARCH_DIR)
6666
endif()
6767
endif()
6868

69+
# Detect musl libc
70+
option(MUSL "Build for musl libc" OFF)
71+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
72+
# Auto-detect musl if not explicitly set
73+
if(NOT MUSL)
74+
execute_process(
75+
COMMAND ldd --version
76+
OUTPUT_VARIABLE LDD_OUTPUT
77+
ERROR_VARIABLE LDD_OUTPUT
78+
OUTPUT_STRIP_TRAILING_WHITESPACE
79+
)
80+
if(LDD_OUTPUT MATCHES "musl")
81+
set(MUSL ON)
82+
message(STATUS "Detected musl libc")
83+
endif()
84+
endif()
85+
endif()
86+
6987
# Set the destination directory for the built library
70-
set(LIB_DEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/${OS_DIR}/${ARCH_DIR}")
88+
if(MUSL AND OS_DIR STREQUAL "linux")
89+
set(LIB_DEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/${OS_DIR}/musl/${ARCH_DIR}")
90+
else()
91+
set(LIB_DEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/${OS_DIR}/${ARCH_DIR}")
92+
endif()
7193

7294
# Find libcurl
7395
find_package(CURL REQUIRED)

0 commit comments

Comments
 (0)