Update zig. #302
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) Markus Franz Xaver Johannes Oberhumer | |
# see also: zig targets | jq '.["libc"]' | |
# 100 build-on-linux targets (jobs) | |
# 4 build-on-macos targets (jobs) | |
# | |
# All linux-musl targets also perform some basic runtime tests using QEMU. | |
# All i386-windows and x86_64-windows targets also perform some basic | |
# runtime tests using Wine. | |
name: 'Build UPX with zig cc' | |
on: [push, workflow_dispatch] | |
env: | |
CMAKE_REQUIRED_QUIET: "OFF" | |
CTEST_OUTPUT_ON_FAILURE: "ON" | |
DEBIAN_FRONTEND: noninteractive | |
NO_COLOR: 1 | |
UPX_CMAKE_BUILD_FLAGS: --verbose | |
# 2024-02-12 | |
ZIG_DIST_VERSION: 0.12.0-dev.2705+320c4d68f | |
# NOTE: we could work-around some failing builds by adding extra compilation | |
# flags, but the point of this test repository is to ensure that zig-cc | |
# just works "out of the box". | |
jobs: | |
job-build-on-linux: | |
if: github.repository_owner == 'upx' | |
name: ${{ format('{0} {1}', matrix.zig_target, matrix.zig_pic) }} | |
runs-on: ubuntu-latest | |
container: 'alpine:edge' | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# linux-musl (statically linked, can use qemu-user for testing) | |
- { zig_target: aarch64-linux-musl, qemu: qemu-aarch64 } | |
- { zig_target: aarch64-linux-musl, qemu: qemu-aarch64, zig_pic: -fPIE } | |
- { zig_target: aarch64_be-linux-musl, qemu: qemu-aarch64_be, tt: UPX-UNSUPPORTED } | |
- { zig_target: aarch64_be-linux-musl, qemu: qemu-aarch64_be, tt: UPX-UNSUPPORTED, zig_pic: -fPIE } | |
- { zig_target: arm-linux-musleabi, qemu: qemu-arm } | |
- { zig_target: arm-linux-musleabi, qemu: qemu-arm, zig_pic: -fPIE } | |
- { zig_target: arm-linux-musleabihf, qemu: qemu-arm } | |
- { zig_target: arm-linux-musleabihf, qemu: qemu-arm, zig_pic: -fPIE } | |
- { zig_target: armeb-linux-musleabi, qemu: qemu-armeb } | |
- { zig_target: armeb-linux-musleabi, qemu: qemu-armeb, zig_pic: -fPIE } | |
- { zig_target: armeb-linux-musleabihf, qemu: qemu-armeb } | |
- { zig_target: armeb-linux-musleabihf, qemu: qemu-armeb, zig_pic: -fPIE } | |
- { zig_target: i386-linux-musl, qemu: qemu-i386 } | |
- { zig_target: i386-linux-musl, qemu: qemu-i386, zig_pic: -fPIE } | |
- { zig_target: m68k-linux-musl, qemu: qemu-m68k, tt: UPX-UNSUPPORTED } | |
- { zig_target: m68k-linux-musl, qemu: qemu-m68k, tt: UPX-UNSUPPORTED, zig_pic: -fPIE } | |
- { zig_target: mips-linux-musl, qemu: qemu-mips } | |
- { zig_target: mips-linux-musl, qemu: qemu-mips, zig_pic: -fPIE } | |
- { zig_target: mipsel-linux-musl, qemu: qemu-mipsel } | |
- { zig_target: mipsel-linux-musl, qemu: qemu-mipsel, zig_pic: -fPIE } | |
- { zig_target: mips64-linux-musl, qemu: qemu-mips64, tt: UPX-UNSUPPORTED } | |
- { zig_target: mips64-linux-musl, qemu: qemu-mips64, tt: UPX-UNSUPPORTED, zig_pic: -fPIE } | |
- { zig_target: mips64el-linux-musl, qemu: qemu-mips64el, tt: UPX-UNSUPPORTED } | |
- { zig_target: mips64el-linux-musl, qemu: qemu-mips64el, tt: UPX-UNSUPPORTED, zig_pic: -fPIE } | |
- { zig_target: powerpc-linux-musl, qemu: qemu-ppc } | |
- { zig_target: powerpc-linux-musl, qemu: qemu-ppc, zig_pic: -fPIE } | |
- { zig_target: powerpc64-linux-musl, qemu: qemu-ppc64 } | |
- { zig_target: powerpc64-linux-musl, qemu: qemu-ppc64, zig_pic: -fPIE } | |
- { zig_target: powerpc64le-linux-musl, qemu: qemu-ppc64le } | |
- { zig_target: powerpc64le-linux-musl, qemu: qemu-ppc64le, zig_pic: -fPIE } | |
- { zig_target: riscv64-linux-musl, qemu: qemu-riscv64, tt: UPX-UNSUPPORTED } | |
- { zig_target: riscv64-linux-musl, qemu: qemu-riscv64, tt: UPX-UNSUPPORTED, zig_pic: -fPIE } | |
- { zig_target: s390x-linux-musl, qemu: qemu-s390x, tt: UPX-UNSUPPORTED } | |
- { zig_target: s390x-linux-musl, qemu: qemu-s390x, tt: UPX-UNSUPPORTED, zig_pic: -fPIE } | |
- { zig_target: thumb-linux-musleabi, qemu: qemu-arm } | |
- { zig_target: thumb-linux-musleabi, qemu: qemu-arm, zig_pic: -fPIE } | |
- { zig_target: thumb-linux-musleabihf, qemu: qemu-arm } | |
- { zig_target: thumb-linux-musleabihf, qemu: qemu-arm, zig_pic: -fPIE } | |
- { zig_target: x86_64-linux-musl, qemu: qemu-x86_64, qemu_flags: -cpu Nehalem } | |
- { zig_target: x86_64-linux-musl, qemu: qemu-x86_64, qemu_flags: -cpu Nehalem, zig_pic: -fPIE } | |
# other | |
- { zig_target: aarch64-linux-gnu } | |
- { zig_target: aarch64-macos-none } | |
- { zig_target: aarch64-macos.11.0-none } | |
- { zig_target: aarch64-macos.12.0-none } | |
- { zig_target: aarch64-macos.13.0-none } | |
- { zig_target: aarch64-windows-gnu } | |
- { zig_target: aarch64_be-linux-gnu } | |
- { zig_target: arm-linux-gnueabi } | |
- { zig_target: arm-linux-gnueabihf } | |
- { zig_target: arm-windows-gnu } | |
- { zig_target: armeb-linux-gnueabi } | |
- { zig_target: armeb-linux-gnueabihf } | |
- { zig_target: csky-linux-gnueabi } | |
- { zig_target: csky-linux-gnueabihf } | |
- { zig_target: i386-linux-gnu } | |
- { zig_target: i386-linux-gnu.2.3.4 } # RHEL 4 | |
- { zig_target: i386-linux-gnu.2.5 } # RHEL 5 | |
- { zig_target: i386-linux-gnu.2.7 } # Ubuntu 8.04 | |
- { zig_target: i386-linux-gnu.2.11 } # SLES 11 | |
- { zig_target: i386-linux-gnu.2.17 } # RHEL 7 | |
- { zig_target: i386-linux-gnu.2.38 } # latest glibc version supported by zig | |
- { zig_target: i386-windows-gnu, wine: wine32 } | |
- { zig_target: i386-windows.win7-gnu, wine: wine32 } | |
- { zig_target: i386-windows.win8-gnu, wine: wine32 } | |
- { zig_target: i386-windows.win10-gnu, wine: wine32 } | |
- { zig_target: m68k-linux-gnu } | |
- { zig_target: mips-linux-gnueabi } | |
- { zig_target: mips-linux-gnueabihf } | |
- { zig_target: mipsel-linux-gnueabi } | |
- { zig_target: mipsel-linux-gnueabihf } | |
- { zig_target: mips64-linux-gnuabi64 } | |
- { zig_target: mips64el-linux-gnuabi64 } | |
- { zig_target: powerpc-linux-gnueabi } | |
- { zig_target: powerpc64-linux-gnu } | |
- { zig_target: powerpc64le-linux-gnu } | |
- { zig_target: riscv64-linux-gnu } | |
- { zig_target: s390x-linux-gnu } | |
- { zig_target: sparc-linux-gnu } | |
- { zig_target: sparc64-linux-gnu } | |
- { zig_target: thumb-linux-gnueabi } | |
- { zig_target: thumb-linux-gnueabihf } | |
- { zig_target: x86_64-linux-gnu } | |
- { zig_target: x86_64-linux-gnu.2.3.4 } # RHEL 4 | |
- { zig_target: x86_64-linux-gnu.2.5 } # RHEL 5 | |
- { zig_target: x86_64-linux-gnu.2.7 } # Ubuntu 8.04 | |
- { zig_target: x86_64-linux-gnu.2.11 } # SLES 11 | |
# { zig_target: x86_64-linux-gnu.2.12 } # RHEL 6 | |
- { zig_target: x86_64-linux-gnu.2.17 } # RHEL 7 | |
# { zig_target: x86_64-linux-gnu.2.23 } # Ubuntu 16.04 | |
# { zig_target: x86_64-linux-gnu.2.27 } # Ubuntu 18.04 | |
# { zig_target: x86_64-linux-gnu.2.31 } # Ubuntu 18.04 | |
# { zig_target: x86_64-linux-gnu.2.34 } # RHEL 9 | |
# { zig_target: x86_64-linux-gnu.2.35 } # Ubuntu 22.04 | |
- { zig_target: x86_64-linux-gnu.2.38 } # latest glibc version supported by zig | |
- { zig_target: x86_64-macos-none } | |
- { zig_target: x86_64-macos.11.0-none } | |
- { zig_target: x86_64-macos.12.0-none } | |
- { zig_target: x86_64-macos.13.0-none } | |
- { zig_target: x86_64-windows-gnu, wine: wine64 } | |
- { zig_target: x86_64-windows.win7-gnu, wine: wine64 } | |
- { zig_target: x86_64-windows.win8-gnu, wine: wine64 } | |
- { zig_target: x86_64-windows.win10-gnu, wine: wine64 } | |
# ILP32 on 64-bit archs | |
- { zig_target: mips64-linux-gnuabin32 } | |
- { zig_target: mips64el-linux-gnuabin32 } | |
- { zig_target: x86_64-linux-gnux32 } | |
- { zig_target: x86_64-linux-muslx32 } # not supported by Zig ?? | |
- { zig_target: x86_64-linux-muslx32, zig_pic: -fPIE } | |
# special | |
- { zig_target: wasm32-wasi-musl, zig_flags: -Wno-macro-redefined -DDOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS -DDOCTEST_CONFIG_NO_POSIX_SIGNALS -DHAVE_SETJMP_H=0 -DHAVE_SIGNAL_H=0 -DHAVE_CHMOD=0 -DHAVE_CHOWN=0 -DHAVE_DUP=0, cmake: -DUPX_CONFIG_DISABLE_SANITIZE=1 } | |
env: | |
# for zig-cc wrapper scripts (see below): | |
##ZIG_CPPFLAGS: -DUPX_DOCTEST_CONFIG_MULTITHREADING # TODO: enable this once other issues are fixed | |
ZIG_FLAGS: ${{ matrix.zig_flags }} | |
ZIG_PIC: ${{ matrix.zig_pic }} | |
ZIG_TARGET: ${{ matrix.zig_target }} | |
# for upx.git cloning: | |
UPX_REF_NAME: devel | |
# for cmake: | |
EXTRA_CMAKE_CONFIG_FLAGS_DEBUG: ${{ matrix.cmake }} ${{ matrix.cmake_debug }} | |
EXTRA_CMAKE_CONFIG_FLAGS_RELEASE: ${{ matrix.cmake }} ${{ matrix.cmake_release }} | |
# for running the basic tests under QEMU/Wine: | |
UPX: --no-color --no-progress | |
UPX_DEBUG_DISABLE_GITREV_WARNING: 1 | |
UPX_DEBUG_DOCTEST_VERBOSE: 0 | |
steps: | |
- name: ${{ format('Install packages {0}', 'alpine:edge') }} | |
if: ${{ job.container }} | |
shell: sh | |
run: | | |
apk update && apk upgrade && apk add bash cmake coreutils file git make tar xz | |
if test '${{ matrix.zig_target }}' = 'x86_64-linux-gnu'; then # only do this once per Action | |
apk add clang g++ | |
fi | |
# set PATH like in Ubuntu | |
echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV | |
# this seems to be needed when running in a container (beause of UID mismatch??) | |
git config --global --add safe.directory '*' | |
# this seems to be needed for Wine when running in a container (beause of UID mismatch??) | |
mkdir -p -v ~/.wine | |
# note that ~/.local/bin is included in the default $PATH on Ubuntu | |
- name: ${{ format('Install Zig {0}', env.ZIG_DIST_VERSION) }} | |
shell: bash | |
run: | | |
mkdir -p -v ~/.local/bin | |
cd ~/.local/bin | |
ZIG_DIST_NAME=zig-linux-x86_64-${ZIG_DIST_VERSION} | |
wget -q https://ziglang.org/builds/${ZIG_DIST_NAME}.tar.xz | |
ls -l ${ZIG_DIST_NAME}.tar.xz | |
tar -xoJf ${ZIG_DIST_NAME}.tar.xz | |
rm ${ZIG_DIST_NAME}.tar.xz | |
ln -s -v ${ZIG_DIST_NAME}/zig zig | |
#echo "PATH=$PATH" && which zig | |
echo -n 'zig version: '; zig version | |
# create wrapper scripts (needed for CMake) | |
log= | |
log='set -x\n' | |
echo -e '#!/bin/sh\n'$log'exec zig ar "$@"' > zig-ar | |
echo -e '#!/bin/sh\n'$log'exec zig cc -target $ZIG_TARGET $ZIG_PIC $ZIG_FLAGS $ZIG_CPPFLAGS $ZIG_CFLAGS "$@"' > zig-cc | |
echo -e '#!/bin/sh\n'$log'exec zig c++ -target $ZIG_TARGET $ZIG_PIC $ZIG_FLAGS $ZIG_CPPFLAGS $ZIG_CXXFLAGS "$@"' > zig-cxx | |
echo -e '#!/bin/sh\n'$log'exec zig ranlib "$@"' > zig-ranlib | |
chmod +x zig-ar zig-cc zig-cxx zig-ranlib | |
ls -la; head zig-ar zig-cc zig-cxx zig-ranlib | |
# update ZIG_TARGET (i386 => x86) | |
ZIG_TARGET=${ZIG_TARGET/i386-/x86-} | |
echo "ZIG_TARGET=$ZIG_TARGET" >> $GITHUB_ENV | |
- name: ${{ format('Check out UPX {0} source code', env.UPX_REF_NAME) }} | |
run: | | |
git clone --branch $UPX_REF_NAME --depth 1 https://github.com/upx/upx . | |
git submodule update --init | |
# GitHub Actions magic: set "UPX_GITREV_SHORT" environment value for use in steps below | |
rev=$(git rev-parse --short=7 HEAD) | |
echo "UPX_GITREV_SHORT=$rev" >> $GITHUB_ENV | |
- name: 'Build with local clang and gcc' | |
if: ${{ matrix.zig_target == 'x86_64-linux-gnu' }} # only do this once per Action | |
run: | | |
make build/extra/clang/release && make -C build/extra/clang/release test | |
make build/extra/clang/debug && make -C build/extra/clang/debug test | |
make build/extra/gcc/release && make -C build/extra/gcc/release test | |
make build/extra/gcc/debug && make -C build/extra/gcc/debug test | |
# CMAKE_AR needs to be an absolute file path; CMake bug? | |
- name: ${{ format('Build Release with zig-cc -target {0} {1}', env.ZIG_TARGET, env.ZIG_PIC) }} | |
run: | | |
mkdir -p build/zig/${ZIG_TARGET}${ZIG_PIC}/release | |
cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release | |
cmake ../../../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_AR=$HOME/.local/bin/zig-ar -DCMAKE_C_COMPILER=zig-cc -DCMAKE_CXX_COMPILER=zig-cxx -DCMAKE_RANLIB=$HOME/.local/bin/zig-ranlib $EXTRA_CMAKE_CONFIG_FLAGS_RELEASE | |
cmake --build . --config Release --parallel --verbose | |
file ./upx* | |
- name: ${{ format('Build Debug with zig-cc -target {0} {1}', env.ZIG_TARGET, env.ZIG_PIC) }} | |
run: | | |
mkdir -p build/zig/${ZIG_TARGET}${ZIG_PIC}/debug | |
cd build/zig/${ZIG_TARGET}${ZIG_PIC}/debug | |
cmake ../../../.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_AR=$HOME/.local/bin/zig-ar -DCMAKE_C_COMPILER=zig-cc -DCMAKE_CXX_COMPILER=zig-cxx -DCMAKE_RANLIB=$HOME/.local/bin/zig-ranlib $EXTRA_CMAKE_CONFIG_FLAGS_DEBUG | |
cmake --build . --config Debug --parallel --verbose | |
file ./upx* | |
- name: ${{ format('Make artifact from upx-{0}-{1}', env.UPX_REF_NAME, env.UPX_GITREV_SHORT) }} | |
shell: bash | |
run: | | |
N=upx-zigcc-linux-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.zig_target }}${ZIG_PIC} | |
xbuild=build-upx-${UPX_REF_NAME}-${UPX_GITREV_SHORT} | |
mkdir -p "tmp/artifact/$N/$xbuild" | |
(cd build && shopt -s nullglob && cp -ai --parents */upx* zig/*/*/upx* "../tmp/artifact/$N/$xbuild") | |
(cd tmp/artifact && tar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N") | |
# GitHub Actions magic: set "artifact_name" environment value for use in next step | |
echo "artifact_name=$N" >> $GITHUB_ENV | |
- name: ${{ format('Upload artifact {0}', env.artifact_name) }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.artifact_name }} | |
path: tmp/artifact | |
- name: 'Install QEMU' | |
if: ${{ matrix.qemu != '' }} | |
shell: bash | |
run: | | |
uname -a; pwd; id; umask | |
if test -f /etc/alpine-release; then | |
apk add '${{ matrix.qemu }}' | |
else | |
sudo apt-get update && sudo apt-get upgrade -y | |
sudo apt-get install -y --no-install-recommends qemu-user | |
fi | |
- name: 'Run basic tests under QEMU - Release' | |
if: ${{ matrix.qemu != '' }} | |
shell: bash | |
run: | | |
set -ex -o pipefail | |
cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release | |
file ./upx | |
qemu='${{ matrix.qemu }} ${{ matrix.qemu_flags }}' | |
tt='${{ matrix.tt }}' | |
[[ $tt == UPX-BUG ]] && tt=/bin/bash | |
[[ $tt == UPX-UNSUPPORTED ]] && tt=/bin/bash | |
[[ -z $tt ]] && tt=./upx | |
$qemu ./upx --version-short | |
$qemu ./upx -3 $tt -o tt.packed | |
$qemu ./upx -l tt.packed | |
$qemu ./upx -t tt.packed | |
$qemu ./upx -d tt.packed -o tt.unpacked | |
[[ $tt == ./upx ]] && $qemu ./tt.packed --version-short | |
[[ $tt == ./upx ]] && $qemu ./tt.unpacked --version-short | |
true | |
- name: 'Run basic tests under QEMU - Debug' | |
if: ${{ matrix.qemu != '' }} | |
shell: bash | |
run: | | |
set -ex -o pipefail | |
cd build/zig/${ZIG_TARGET}${ZIG_PIC}/debug | |
file ./upx | |
qemu='${{ matrix.qemu }} ${{ matrix.qemu_flags }}' | |
tt='${{ matrix.tt }}' | |
[[ $tt == UPX-BUG ]] && tt=/bin/bash | |
[[ $tt == UPX-UNSUPPORTED ]] && tt=/bin/bash | |
[[ -z $tt ]] && tt=./upx | |
$qemu ./upx --version-short | |
$qemu ./upx -3 $tt -o tt.packed | |
$qemu ./upx -l tt.packed | |
$qemu ./upx -t tt.packed | |
$qemu ./upx -d tt.packed -o tt.unpacked | |
[[ $tt == ./upx ]] && $qemu ./tt.packed --version-short | |
[[ $tt == ./upx ]] && $qemu ./tt.unpacked --version-short | |
true | |
- name: 'Install Wine' | |
if: ${{ matrix.wine != '' }} | |
shell: bash | |
run: | | |
uname -a; pwd; id; umask | |
if test -f /etc/alpine-release; then | |
# wine-8 can run win32 programs in wow64 mode under pure 64-bit Alpine Linux | |
apk add wine | |
else | |
[[ '${{ matrix.wine }}' == wine32 ]] && sudo dpkg --add-architecture i386 | |
sudo apt-get update && sudo apt-get upgrade -y | |
[[ '${{ matrix.wine }}' == wine32 ]] && sudo apt-get install -y wine wine32:i386 | |
[[ '${{ matrix.wine }}' == wine64 ]] && sudo apt-get install -y wine wine64 | |
fi | |
true | |
- name: 'Run basic tests under Wine - Release' | |
if: ${{ matrix.wine != '' }} | |
shell: bash | |
run: | | |
set -ex -o pipefail | |
cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release | |
[[ -f upx && ! -f upx.exe ]] && mv -i -v upx upx.exe | |
file ./upx.exe | |
wine=wine | |
tt='./upx.exe' | |
$wine ./upx.exe --version-short | |
$wine ./upx.exe -3 $tt -o tt.packed.exe | |
$wine ./upx.exe -l tt.packed.exe | |
$wine ./upx.exe -t tt.packed.exe | |
$wine ./upx.exe -d tt.packed.exe -o tt.unpacked.exe | |
$wine ./tt.packed.exe --version-short | |
$wine ./tt.unpacked.exe --version-short | |
- name: 'Run basic tests under Wine - Debug' | |
if: ${{ matrix.wine != '' }} | |
shell: bash | |
run: | | |
set -ex -o pipefail | |
cd build/zig/${ZIG_TARGET}${ZIG_PIC}/debug | |
[[ -f upx && ! -f upx.exe ]] && mv -i -v upx upx.exe | |
file ./upx.exe | |
wine=wine | |
tt='./upx.exe' | |
$wine ./upx.exe --version-short | |
$wine ./upx.exe -3 $tt -o tt.packed.exe | |
$wine ./upx.exe -l tt.packed.exe | |
$wine ./upx.exe -t tt.packed.exe | |
$wine ./upx.exe -d tt.packed.exe -o tt.unpacked.exe | |
$wine ./tt.packed.exe --version-short | |
$wine ./tt.unpacked.exe --version-short | |
job-build-on-macos: | |
if: github.repository_owner == 'upx' | |
name: ${{ format('macOS {0} {1}', matrix.zig_target, matrix.zig_pic) }} | |
runs-on: macos-12 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- { zig_target: x86_64-macos-none } | |
- { zig_target: x86_64-macos.11.0-none } | |
- { zig_target: x86_64-macos.12.0-none } | |
- { zig_target: x86_64-macos.13.0-none } | |
env: | |
# for zig-cc wrapper scripts (see below): | |
ZIG_CPPFLAGS: -DUPX_DOCTEST_CONFIG_MULTITHREADING # (enabled on macOS by default) | |
ZIG_FLAGS: ${{ matrix.zig_flags }} | |
ZIG_PIC: ${{ matrix.zig_pic }} | |
ZIG_TARGET: ${{ matrix.zig_target }} | |
# for upx.git cloning: | |
UPX_REF_NAME: devel | |
# for cmake: | |
EXTRA_CMAKE_CONFIG_FLAGS_DEBUG: ${{ matrix.cmake }} ${{ matrix.cmake_debug }} | |
EXTRA_CMAKE_CONFIG_FLAGS_RELEASE: ${{ matrix.cmake }} ${{ matrix.cmake_release }} | |
# for running the basic tests: | |
UPX: --no-color --no-progress | |
UPX_DEBUG_DISABLE_GITREV_WARNING: 1 | |
UPX_DEBUG_DOCTEST_VERBOSE: 0 | |
steps: | |
# note that ~/bin is included in the default $PATH on macOS-11 and macOS-12 | |
- name: ${{ format('Install Zig {0}', env.ZIG_DIST_VERSION) }} | |
run: | | |
mkdir -p -v ~/bin | |
cd ~/bin | |
ZIG_DIST_NAME=zig-macos-x86_64-${ZIG_DIST_VERSION} | |
wget -q https://ziglang.org/builds/${ZIG_DIST_NAME}.tar.xz | |
ls -l ${ZIG_DIST_NAME}.tar.xz | |
tar -xoJf ${ZIG_DIST_NAME}.tar.xz | |
rm ${ZIG_DIST_NAME}.tar.xz | |
ln -s -v ${ZIG_DIST_NAME}/zig zig | |
#echo "PATH=$PATH" && which zig | |
echo -n 'zig version: '; zig version | |
# create wrapper scripts (needed for CMake) | |
echo -e '#!/bin/sh\nexec zig ar "$@"' > zig-ar | |
echo -e '#!/bin/sh\nexec zig cc -target $ZIG_TARGET $ZIG_PIC $ZIG_FLAGS $ZIG_CPPFLAGS $ZIG_CFLAGS "$@"' > zig-cc | |
echo -e '#!/bin/sh\nexec zig c++ -target $ZIG_TARGET $ZIG_PIC $ZIG_FLAGS $ZIG_CPPFLAGS $ZIG_CXXFLAGS "$@"' > zig-cxx | |
echo -e '#!/bin/sh\nexec zig ranlib "$@"' > zig-ranlib | |
chmod +x zig-ar zig-cc zig-cxx zig-ranlib | |
ls -la; head zig-ar zig-cc zig-cxx zig-ranlib | |
- name: ${{ format('Check out UPX {0} source code', env.UPX_REF_NAME) }} | |
run: | | |
git clone --branch $UPX_REF_NAME --depth 1 https://github.com/upx/upx . | |
git submodule update --init | |
# GitHub Actions magic: set "UPX_GITREV_SHORT" environment value for use in steps below | |
rev=$(git rev-parse --short=7 HEAD) | |
echo "UPX_GITREV_SHORT=$rev" >> $GITHUB_ENV | |
- name: 'Build with local clang' | |
if: ${{ matrix.zig_target == 'x86_64-macos-none' }} # only do this once per Action | |
run: | | |
# disable packing macOS binaries for now (in Release mode) | |
make build/extra/clang/release ## && make -C build/extra/clang/release test | |
make build/extra/clang/debug && make -C build/extra/clang/debug test | |
# CMAKE_AR needs to be an absolute file path; CMake bug? | |
- name: ${{ format('Build Release with zig-cc -target {0} {1}', env.ZIG_TARGET, env.ZIG_PIC) }} | |
run: | | |
mkdir -p build/zig/${ZIG_TARGET}${ZIG_PIC}/release | |
cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release | |
cmake ../../../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_AR=$HOME/bin/zig-ar -DCMAKE_C_COMPILER=zig-cc -DCMAKE_CXX_COMPILER=zig-cxx -DCMAKE_RANLIB=$HOME/bin/zig-ranlib $EXTRA_CMAKE_CONFIG_FLAGS_RELEASE | |
cmake --build . --config Release --parallel --verbose | |
file ./upx* | |
- name: ${{ format('Build Debug with zig-cc -target {0} {1}', env.ZIG_TARGET, env.ZIG_PIC) }} | |
run: | | |
mkdir -p build/zig/${ZIG_TARGET}${ZIG_PIC}/debug | |
cd build/zig/${ZIG_TARGET}${ZIG_PIC}/debug | |
cmake ../../../.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_AR=$HOME/bin/zig-ar -DCMAKE_C_COMPILER=zig-cc -DCMAKE_CXX_COMPILER=zig-cxx -DCMAKE_RANLIB=$HOME/bin/zig-ranlib $EXTRA_CMAKE_CONFIG_FLAGS_DEBUG | |
cmake --build . --config Debug --parallel --verbose | |
file ./upx* | |
- name: ${{ format('Make artifact from upx-{0}-{1}', env.UPX_REF_NAME, env.UPX_GITREV_SHORT) }} | |
run: | | |
N=upx-zigcc-macos-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.zig_target }}${ZIG_PIC} | |
xbuild=build-upx-${UPX_REF_NAME}-${UPX_GITREV_SHORT} | |
mkdir -p "tmp/artifact/$N/$xbuild" | |
(cd build && shopt -s nullglob && rsync -R -a */upx* zig/*/*/upx* "../tmp/artifact/$N/$xbuild/") | |
(cd tmp/artifact && gtar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N") | |
# GitHub Actions magic: set "artifact_name" environment value for use in next step | |
echo "artifact_name=$N" >> $GITHUB_ENV | |
- name: ${{ format('Upload artifact {0}', env.artifact_name) }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.artifact_name }} | |
path: tmp/artifact | |
- name: 'Run basic tests - Release' | |
if: false # disable packing macOS binaries for now (in Release mode) | |
run: | | |
cmake --build build/zig/${ZIG_TARGET}${ZIG_PIC}/release --target test | |
- name: 'Run basic tests - Debug' | |
run: | | |
cmake --build build/zig/${ZIG_TARGET}${ZIG_PIC}/debug --target test |