327 lines
12 KiB
YAML
327 lines
12 KiB
YAML
stages:
|
|
- validate
|
|
- build
|
|
- test
|
|
- package
|
|
- release
|
|
|
|
variables:
|
|
DEBIAN_FRONTEND: noninteractive
|
|
PKG_CHANNEL: voidlibc
|
|
ZIG_VERSION: "0.13.0"
|
|
|
|
# Heavy jobs (build, test, package) share this default.
|
|
# validate and release override before_script themselves.
|
|
default:
|
|
image: ubuntu:24.04
|
|
before_script:
|
|
- apt-get update -qq
|
|
- apt-get install -y --no-install-recommends
|
|
clang-18 lld-18 cmake ninja-build python3 curl ca-certificates xz-utils zip
|
|
- ln -sf /usr/bin/clang-18 /usr/local/bin/clang
|
|
- ln -sf /usr/bin/clang++-18 /usr/local/bin/clang++
|
|
- ln -sf /usr/bin/lld-18 /usr/local/bin/lld
|
|
- |
|
|
curl -sSL \
|
|
"https://ziglang.org/download/${ZIG_VERSION}/zig-linux-x86_64-${ZIG_VERSION}.tar.xz" \
|
|
| tar -xJ -C /opt/
|
|
ln -sf "/opt/zig-linux-x86_64-${ZIG_VERSION}/zig" /usr/local/bin/zig
|
|
|
|
# =============================================================================
|
|
# validate
|
|
# =============================================================================
|
|
|
|
validate:symlib:
|
|
stage: validate
|
|
before_script:
|
|
- apt-get update -qq
|
|
- apt-get install -y --no-install-recommends python3
|
|
script:
|
|
- python3 tools/gen_symlib_table.py --check
|
|
|
|
# =============================================================================
|
|
# build (Linux, full; artifact consumed by test and package:linux)
|
|
# =============================================================================
|
|
|
|
build:release:
|
|
stage: build
|
|
script:
|
|
- |
|
|
cmake -B build -G Ninja \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_C_COMPILER=clang \
|
|
-DCMAKE_CXX_COMPILER=clang++ \
|
|
-DVOIDLIBC_BUILD_VOIDLINK=ON \
|
|
-DVOIDLIBC_BUILD_LOADER=ON \
|
|
-DVOIDLIBC_BUILD_TESTS=ON
|
|
- cmake --build build
|
|
artifacts:
|
|
paths:
|
|
- build/
|
|
expire_in: 2h
|
|
|
|
# =============================================================================
|
|
# test (parallel, Linux only — runtime validation requires Linux binfmt/dlopen)
|
|
# =============================================================================
|
|
|
|
test:unit:
|
|
stage: test
|
|
needs: [build:release]
|
|
script:
|
|
- ctest --test-dir build -L "format|synth" --output-on-failure -j "$(nproc)"
|
|
|
|
test:e2e:
|
|
stage: test
|
|
needs: [build:release]
|
|
script:
|
|
- ctest --test-dir build -L e2e --output-on-failure -j "$(nproc)"
|
|
|
|
# Fuzz smoke test: build the three reader harnesses and run each for 30 s.
|
|
# A crash here means the parser has undefined behaviour on malformed input.
|
|
# Runs independently of the main build artifact (own fresh build).
|
|
test:fuzz:
|
|
stage: test
|
|
needs:
|
|
- job: build:release
|
|
artifacts: false
|
|
script:
|
|
- |
|
|
cmake -B build-fuzz -G Ninja \
|
|
-DCMAKE_BUILD_TYPE=Debug \
|
|
-DCMAKE_C_COMPILER=clang \
|
|
-DCMAKE_CXX_COMPILER=clang++ \
|
|
-DVOIDLIBC_BUILD_VOIDLINK=ON \
|
|
-DVOIDLIBC_BUILD_LOADER=OFF \
|
|
-DVOIDLIBC_BUILD_TESTS=ON \
|
|
-DVOIDLIBC_BUILD_FUZZ=ON
|
|
- cmake --build build-fuzz
|
|
- |
|
|
for fuzzer in fuzz_elf_reader fuzz_coff_reader fuzz_macho_reader; do
|
|
echo "--- $fuzzer (30 s smoke run) ---"
|
|
build-fuzz/tests/fuzz/$fuzzer \
|
|
-max_total_time=30 \
|
|
-rss_limit_mb=512 \
|
|
-print_final_stats=1 \
|
|
2>&1 | tail -8
|
|
done
|
|
|
|
# =============================================================================
|
|
# package (one job per platform, all tags-only)
|
|
# =============================================================================
|
|
|
|
# ── Linux ─────────────────────────────────────────────────────────────────────
|
|
# Full install: voidlink + voidloader + libvoid.a + headers + CMake config.
|
|
# Uses DESTDIR staging so the absolute /etc/binfmt.d destination is safe.
|
|
|
|
package:linux:
|
|
stage: package
|
|
needs: [build:release, test:unit, test:e2e]
|
|
rules:
|
|
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/
|
|
script:
|
|
- STAGING="$(pwd)/staging-linux"
|
|
- ARTIFACT="voidlibc-${CI_COMMIT_TAG}-linux-x86_64.tar.gz"
|
|
- DESTDIR="$STAGING" cmake --install build --strip
|
|
- tar -czf "$ARTIFACT" -C "$STAGING" .
|
|
- |
|
|
URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic"
|
|
URL="${URL}/${PKG_CHANNEL}/${CI_COMMIT_TAG}/${ARTIFACT}"
|
|
curl --fail --silent --show-error \
|
|
--header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
|
|
--upload-file "$ARTIFACT" "$URL"
|
|
echo "LINUX_ARTIFACT_URL=${URL}" >> release.env
|
|
echo "LINUX_ARTIFACT_NAME=${ARTIFACT}" >> release.env
|
|
artifacts:
|
|
paths: ["voidlibc-*-linux-*.tar.gz"]
|
|
reports:
|
|
dotenv: release.env
|
|
expire_in: 30d
|
|
|
|
# ── Windows ───────────────────────────────────────────────────────────────────
|
|
# Full Windows package: voidlink.exe + voidloader.exe + libvoid.a + headers
|
|
# + CMake config + installer/, cross-compiled with zig targeting x86_64-windows-gnu.
|
|
# Statically linked so no mingw DLLs are required.
|
|
|
|
package:windows:
|
|
stage: package
|
|
needs:
|
|
- job: build:release
|
|
artifacts: false # don't transfer the Linux build/ tree
|
|
- job: test:unit
|
|
artifacts: false
|
|
- job: test:e2e
|
|
artifacts: false
|
|
rules:
|
|
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/
|
|
script:
|
|
# Create zig wrapper scripts for the cmake toolchain.
|
|
- |
|
|
printf '#!/bin/sh\nexec zig cc -target x86_64-windows-gnu "$@"\n' \
|
|
> /usr/local/bin/zig-cc-win
|
|
printf '#!/bin/sh\nexec zig c++ -target x86_64-windows-gnu "$@"\n' \
|
|
> /usr/local/bin/zig-cxx-win
|
|
chmod +x /usr/local/bin/zig-cc-win /usr/local/bin/zig-cxx-win
|
|
- |
|
|
cmake -B build-win -G Ninja \
|
|
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/host-windows.cmake \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DVOIDLIBC_BUILD_VOIDLINK=ON \
|
|
-DVOIDLIBC_BUILD_LOADER=ON \
|
|
-DVOIDLIBC_BUILD_TESTS=OFF
|
|
- cmake --build build-win
|
|
- |
|
|
STAGING="$(pwd)/staging-win"
|
|
DESTDIR="$STAGING" cmake --install build-win --strip
|
|
# Linux-specific binfmt.d install rules do not fire for Windows targets,
|
|
# but guard explicitly in case.
|
|
rm -rf "$STAGING/etc"
|
|
# Add installer scripts under installer/ so the .ps1 finds bin/ via
|
|
# the package-layout path ($PSScriptRoot\..\bin\).
|
|
mkdir -p "$STAGING/installer"
|
|
cp installer/windows/install.ps1 "$STAGING/installer/"
|
|
cp installer/windows/uninstall.ps1 "$STAGING/installer/"
|
|
- ARTIFACT="voidlibc-${CI_COMMIT_TAG}-windows-x86_64.zip"
|
|
- zip -r "$ARTIFACT" staging-win/
|
|
- |
|
|
URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic"
|
|
URL="${URL}/${PKG_CHANNEL}/${CI_COMMIT_TAG}/${ARTIFACT}"
|
|
curl --fail --silent --show-error \
|
|
--header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
|
|
--upload-file "$ARTIFACT" "$URL"
|
|
echo "WIN_ARTIFACT_URL=${URL}" >> release.env
|
|
echo "WIN_ARTIFACT_NAME=${ARTIFACT}" >> release.env
|
|
artifacts:
|
|
paths: ["voidlibc-*-windows-*.zip"]
|
|
reports:
|
|
dotenv: release.env
|
|
expire_in: 30d
|
|
|
|
# ── macOS ─────────────────────────────────────────────────────────────────────
|
|
# Full macOS package: voidlink + voidloader + libvoid.a + headers + CMake config
|
|
# + installer/, cross-compiled with zig targeting x86_64-apple-macos12.
|
|
# zig 0.13 bundles macOS libc headers (no separate SDK required).
|
|
|
|
package:macos:
|
|
stage: package
|
|
needs:
|
|
- job: build:release
|
|
artifacts: false
|
|
- job: test:unit
|
|
artifacts: false
|
|
- job: test:e2e
|
|
artifacts: false
|
|
rules:
|
|
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/
|
|
script:
|
|
- |
|
|
printf '#!/bin/sh\nexec zig cc -target x86_64-macos12 "$@"\n' \
|
|
> /usr/local/bin/zig-cc-mac
|
|
printf '#!/bin/sh\nexec zig c++ -target x86_64-macos12 "$@"\n' \
|
|
> /usr/local/bin/zig-cxx-mac
|
|
chmod +x /usr/local/bin/zig-cc-mac /usr/local/bin/zig-cxx-mac
|
|
- |
|
|
cmake -B build-mac -G Ninja \
|
|
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/host-macos.cmake \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DVOIDLIBC_BUILD_VOIDLINK=ON \
|
|
-DVOIDLIBC_BUILD_LOADER=ON \
|
|
-DVOIDLIBC_BUILD_TESTS=OFF
|
|
- cmake --build build-mac
|
|
- |
|
|
STAGING="$(pwd)/staging-mac"
|
|
DESTDIR="$STAGING" cmake --install build-mac --strip
|
|
rm -rf "$STAGING/etc"
|
|
# Add installer scripts so install.sh finds bin/ via the package-layout
|
|
# path (${SCRIPT_DIR}/../bin/).
|
|
mkdir -p "$STAGING/installer"
|
|
cp installer/macos/install.sh "$STAGING/installer/"
|
|
cp installer/macos/uninstall.sh "$STAGING/installer/"
|
|
- ARTIFACT="voidlibc-${CI_COMMIT_TAG}-macos-x86_64.tar.gz"
|
|
- tar -czf "$ARTIFACT" -C staging-mac .
|
|
- |
|
|
URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic"
|
|
URL="${URL}/${PKG_CHANNEL}/${CI_COMMIT_TAG}/${ARTIFACT}"
|
|
curl --fail --silent --show-error \
|
|
--header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
|
|
--upload-file "$ARTIFACT" "$URL"
|
|
echo "MAC_ARTIFACT_URL=${URL}" >> release.env
|
|
echo "MAC_ARTIFACT_NAME=${ARTIFACT}" >> release.env
|
|
artifacts:
|
|
paths: ["voidlibc-*-macos-*.tar.gz"]
|
|
reports:
|
|
dotenv: release.env
|
|
expire_in: 30d
|
|
|
|
# =============================================================================
|
|
# release (tags only — assembles GitLab Release from all three packages)
|
|
# =============================================================================
|
|
|
|
release:
|
|
stage: release
|
|
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
needs:
|
|
- job: package:linux
|
|
artifacts: true # provides LINUX_ARTIFACT_URL / LINUX_ARTIFACT_NAME
|
|
- job: package:windows
|
|
artifacts: true # provides WIN_ARTIFACT_URL / WIN_ARTIFACT_NAME
|
|
- job: package:macos
|
|
artifacts: true # provides MAC_ARTIFACT_URL / MAC_ARTIFACT_NAME
|
|
rules:
|
|
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/
|
|
before_script: [] # release-cli image has no apt
|
|
script:
|
|
- echo "Creating release ${CI_COMMIT_TAG}"
|
|
release:
|
|
name: "VoidLibC ${CI_COMMIT_TAG}"
|
|
tag_name: "${CI_COMMIT_TAG}"
|
|
description: |
|
|
## VoidLibC ${CI_COMMIT_TAG}
|
|
|
|
Universal x86-64 fat-binary format (`.vlc` / `.vls` / `.vle`) with host-libc delegation.
|
|
A single `.vlc` library bundles ELF, PE, and Mach-O blobs; voidloader selects the right
|
|
one at runtime and resolves symbols against the host libc automatically.
|
|
|
|
### Assets
|
|
|
|
| File | Platform | Contents |
|
|
|------|----------|----------|
|
|
| `${LINUX_ARTIFACT_NAME}` | Linux x86-64 | voidlink, voidloader, libvoid.a, headers, CMake config, binfmt.d, installer/ |
|
|
| `${WIN_ARTIFACT_NAME}` | Windows x86-64 | voidlink.exe, voidloader.exe, libvoid.a, headers, CMake config, installer/ |
|
|
| `${MAC_ARTIFACT_NAME}` | macOS x86-64 | voidlink, voidloader, libvoid.a, headers, CMake config, installer/ |
|
|
|
|
### Install (Linux)
|
|
|
|
```sh
|
|
tar -xzf ${LINUX_ARTIFACT_NAME}
|
|
cd voidlibc-*-linux-x86_64
|
|
sudo bash installer/linux/install.sh # copies binaries + registers binfmt_misc
|
|
```
|
|
|
|
### Install (Windows)
|
|
|
|
```powershell
|
|
Expand-Archive ${WIN_ARTIFACT_NAME} -DestinationPath voidlibc
|
|
cd voidlibc
|
|
powershell -ExecutionPolicy Bypass -File installer\install.ps1
|
|
# Registers .vle file association and adds bin\ to user PATH
|
|
```
|
|
|
|
### Install (macOS)
|
|
|
|
```sh
|
|
tar -xzf ${MAC_ARTIFACT_NAME}
|
|
cd voidlibc-*-macos-x86_64
|
|
bash installer/install.sh # copies voidlink + voidloader to /usr/local/bin
|
|
```
|
|
assets:
|
|
links:
|
|
- name: "${LINUX_ARTIFACT_NAME}"
|
|
url: "${LINUX_ARTIFACT_URL}"
|
|
link_type: package
|
|
- name: "${WIN_ARTIFACT_NAME}"
|
|
url: "${WIN_ARTIFACT_URL}"
|
|
link_type: package
|
|
- name: "${MAC_ARTIFACT_NAME}"
|
|
url: "${MAC_ARTIFACT_URL}"
|
|
link_type: package
|