From 10cabe69b80a1620ac64b7ef597e4abe163b3fbe Mon Sep 17 00:00:00 2001 From: Guilherme Janczak Date: Sat, 28 Dec 2024 01:22:10 +0000 Subject: [PATCH] sync github CI with libobsd Update the libobsd wrap so it doesn't fail CI. --- .github/workflows/build-and-test.yml | 302 ++++++++++++++----------- .github/workflows/meson-emscripten.txt | 21 ++ meson.build | 5 +- subprojects/libobsd.wrap | 9 +- 4 files changed, 194 insertions(+), 143 deletions(-) create mode 100644 .github/workflows/meson-emscripten.txt diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 63244ed..d0ab0c0 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Guilherme Janczak +# Copyright (c) 2022-2024 Guilherme Janczak # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -12,138 +12,95 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -name: Build and test +name: 'Build and Test' on: [push, pull_request] -# GitHub Actions doesn't support YAML anchors, so the bit of code below is -# copypasted between jobs: -# -# - uses: actions/checkout@v2.4.0 -# - name: build -# run: | -# meson setup build -# meson compile -C build -# - name: test -# run: meson test -C build -# - uses: actions/upload-artifact@v2.3.1 -# if: failure() -# with: -# name: meson-logs -# path: build/meson-logs - +# GitHub Actions doesn't support YAML anchors, so there's a lot of code +# copypasted between jobs. You'll probably want to read the 'glibc:' task first, +# it's the one that requires the least hacks. jobs: - glibc: + bionic: + # XXX: Checkout and upload actions don't work, work with termux to fix this + # and the need to run /entrypoint.sh ourselves. runs-on: ubuntu-latest + container: termux/termux-docker:x86_64 steps: - - uses: actions/setup-python@v2.3.1 - - run: | - pip install meson ninja - sudo apt update - sudo apt install -y libbsd-dev - - uses: actions/checkout@v2.4.0 + - name: setup + run: | + /entrypoint.sh pkg install -y ninja clang python git + /entrypoint.sh pip install meson + git clone --depth 1 -b $GITHUB_REF_NAME \ + https://github.com/$GITHUB_REPOSITORY - name: build run: | - meson setup build + meson setup build dictpw meson compile -C build - name: test run: meson test -C build - - uses: actions/upload-artifact@v2.3.1 - if: failure() - with: - name: meson-logs-glibc - path: build/meson-logs - macos: - runs-on: macos-latest + + dietlibc: + runs-on: ubuntu-latest steps: - - uses: actions/setup-python@v2.3.1 - - run: pip install meson ninja - - uses: actions/checkout@v2.4.0 + - uses: actions/setup-python@v5.3.0 + - name: setup + run: | + pip install meson ninja + sudo apt update + sudo apt install -y dietlibc-dev valgrind linux-headers-generic + - uses: actions/checkout@v4.2.2 - name: build run: | - meson setup build + CC='diet gcc' meson setup build -Ddefault_library=static meson compile -C build - name: test - run: meson test -C build - - uses: actions/upload-artifact@v2.3.1 - if: failure() + run: meson test -C build --wrapper valgrind + - uses: actions/upload-artifact@v4.5.0 + if: always() with: - name: meson-logs-macos + name: meson-logs-dietlibc path: build/meson-logs - msys2: - runs-on: windows-latest - defaults: - run: - shell: msys2 {0} - strategy: - matrix: - sys: [msys, clang64, mingw64, mingw32, ucrt64] + + emscripten: + runs-on: macos-latest steps: - - uses: msys2/setup-msys2@v2 - with: - msystem: ${{matrix.sys}} - install: git groff pactoys dos2unix - - uses: actions/checkout@v2.4.0 - - name: setup-msys - if: ${{matrix.sys == 'msys'}} - run: pacman -S --noconfirm --needed mingw-w64-x86_64-nsis meson gcc - - name: setup-no-nsis - if: ${{matrix.sys == 'clang64'}} + - name: setup run: | - pacboy -S --noconfirm --needed mingw-w64-x86_64-nsis meson:p clang:p - - name: setup-nsis - if: ${{matrix.sys != 'msys' && matrix.sys != 'clang64'}} - run: pacboy -S --noconfirm --needed -- nsis:p meson:p gcc:p + brew update + brew install meson samurai emscripten + - uses: actions/checkout@v4.2.2 - name: build run: | - meson setup build + meson setup build -Ddefault_library=static \ + --cross-file=.github/workflows/meson-emscripten.txt meson compile -C build - name: test run: meson test -C build - - name: installer - run: ./dictpw_installer.sh -o 'build\setup-dictpw-${{matrix.sys}}.exe' - - uses: actions/upload-artifact@v2.3.1 - if: failure() + - uses: actions/upload-artifact@v4.5.0 + if: always() with: - name: meson-logs-${{matrix.sys}} + name: meson-logs-emscripten path: build/meson-logs - - uses: actions/upload-artifact@v2.3.1 - if: success() - with: - name: setup-${{matrix.sys}} - path: build/setup-*.exe - cygwin: - runs-on: windows-latest - env: - CYGWIN_NOWINPATH: 1 # Removes non-Cygwin dirs from PATH. - CHERE_INVOKING: '' # Makes Cygwin's `bash.exe --login` not cd. - defaults: - run: - shell: C:\cygwin\bin\bash.exe --login -o igncr {0} + + glibc: + runs-on: ubuntu-latest steps: - - run: git config --global core.autocrlf input - # This is NOT the Cygwin bash, it's the Git for Windows bash from the - # default Github Actions Windows VM. This step tells git to translate - # Unix newlines to DOS newlines. - shell: bash - - uses: actions/checkout@v2.4.0 - - uses: cygwin/cygwin-install-action@master - with: - # git might be needed while working with git versions of libobsd - packages: gcc-core meson groff-perl git dos2unix + - uses: actions/setup-python@v5.3.0 + - name: setup + run: | + pip install meson ninja + - uses: actions/checkout@v4.2.2 - name: build run: | - cd ${GITHUB_WORKSPACE} meson setup build meson compile -C build - name: test - run: | - cd ${GITHUB_WORKSPACE} - meson test -C build - - uses: actions/upload-artifact@v2.3.1 - if: failure() + run: meson test -C build + - uses: actions/upload-artifact@v4.5.0 + if: always() with: - name: meson-logs-cygwin + name: meson-logs-glibc path: build/meson-logs + haiku: runs-on: ubuntu-22.04 container: 'docker.io/hectorm/qemu-haiku:latest' @@ -165,67 +122,140 @@ jobs: vmshell meson compile -C build - name: test run: vmshell meson test -C build - - name: copy failure logs - if: failure() + - name: copy falure logs + if: always() run: | vmshell tar -cf - build/meson-logs | tar -xf - - - uses: actions/upload-artifact@v2.3.1 - if: failure() + - uses: actions/upload-artifact@v4.5.0 + if: always() with: name: meson-logs-haiku path: build/meson-logs + + macos: + runs-on: macos-latest + steps: + - run: | + brew update + brew install meson samurai + - uses: actions/checkout@v4.2.2 + - name: build + run: | + meson setup build + meson compile -C build + - name: test + run: meson test -C build + - uses: actions/upload-artifact@v4.5.0 + if: always() + with: + name: meson-logs-macos + path: build/meson-logs + + msys2: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + strategy: + matrix: + # clang32 was broken last time I tried + sys: [msys, mingw64, mingw32, ucrt64, clang64] + steps: + - uses: msys2/setup-msys2@v2 + with: + msystem: ${{matrix.sys}} + path-type: strict + pacboy: | + gcc:p meson:p ninja:p dos2unix: git: groff: + - name: env-lacks-nsis + if: matrix.sys == 'msys' || matrix.sys == 'clang64' + run: pacman -S --noconfirm --needed mingw-w64-x86_64-nsis + - name: env-has-nsis + if: matrix.sys != 'msys' && matrix.sys != 'clang64' + run: pacboy -S --noconfirm --needed nsis:p + - uses: actions/checkout@v4.2.2 + - name: build + run: | + meson setup build + meson compile -C build + - name: test + run: meson test -C build + - name: installer + run: ./dictpw_installer.sh -o 'build\setup-dictpw-${{matrix.sys}}.exe' + - uses: actions/upload-artifact@v4.5.0 + if: always() + with: + name: meson-logs-${{matrix.sys}} + path: build/meson-logs + - uses: actions/upload-artifact@v4.5.0 + if: success() + with: + name: setup-${{matrix.sys}} + path: build/setup-*.exe + + netbsd: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.2.2 + - name: test on NetBSD + uses: cross-platform-actions/action@v0.26.0 + with: + operating_system: netbsd + version: '10.0' + run: | + sudo pkgin -y install meson git + meson setup build + meson compile -C build + meson test -C build + - uses: actions/upload-artifact@v4.5.0 + if: always() + with: + name: meson-logs-netbsd + path: build/meson-logs + vs: runs-on: windows-latest strategy: matrix: - cc: [clang, msvc] - arch: [aarch64, amd64] + cc: [cl, clang-cl] + cross: [amd64, amd64_arm64] steps: - - uses: actions/setup-python@v2.3.1 + - uses: actions/setup-python@v5.3.0 - run: | pip install meson - choco install groff dos2unix - - uses: actions/checkout@v2.4.0 + choco install nsis groff -y + # Chocolatey's /bin isn't in $Path, so we add it. + echo $($env:ChocolateyInstall)\bin >> $env:GITHUB_PATH + - uses: actions/checkout@v4.2.2 + - uses: ilammy/msvc-dev-cmd@v1.13.0 - name: build run: | - if ("${{matrix.arch}}" -eq "aarch64") { + if ("${{matrix.cross}}" -eq 'amd64_arm64') { $cross = "--cross-file=.github/workflows/meson-vs-aarch64.txt" } - if ("${{matrix.cc}}" -eq "msvc") { - # buildtype=plain because b_sanitize doesn't work with debug libs on - # VS. - # Also, asan doesn't seem to be working with clang. - $build = "-Dbuildtype=debug" - $asan = "-Db_sanitize=address" + pwsh -c { + $env:CC="${{ matrix.cc }}"; + # Don't do debug builds because that triggers a Windows bug: + # https://developercommunity.visualstudio.com/t/_setmaxstdio-hangs-the-program-if-the/10164855?space=62&q=setmaxstdio&viewtype=all + meson setup build -Db_vscrt=static_from_buildtype $cross } - meson setup -Db_vscrt=static_from_buildtype $cross $build $asan ` - --backend=vs ` - --cross-file=.github/workflows/meson-vs-${{matrix.cc}}.txt build meson compile -C build - name: test run: meson test -C build - - name: get 64-bit NSIS - run: | - # Reference: https://www.msys2.org/docs/ci/ - # Run for the first time - C:\msys64\usr\bin\bash -lc ' ' - # Update MSYS2 - C:\msys64\usr\bin\bash -lc 'pacman --noconfirm -Syuu' # Core update - C:\msys64\usr\bin\bash -lc ` - 'pacman --noconfirm -Syuu mingw-w64-x86_64-nsis' # Normal update - name: installer run: | - $out = "build\setup-dictpw-vs-${{matrix.cc}}-${{matrix.arch}}.exe" - $cmd = "makensis -DOUTFILE='" + "$out" + "' dictpw.nsi" - $env:CHERE_INVOKING = 'yes' # Preserve the current working directory - $env:MSYSTEM = 'MINGW64' # Start a 64 bit Mingw environment - C:\msys64\usr\bin\bash -lc "$cmd" - - uses: actions/upload-artifact@v2.3.1 - if: failure() + $arch = 'Arm64' + #if ("${{matrix.cross}}" -eq 'amd64') { + # $arch = 'x64' + #} + $out = "build\setup-dictpw-vs-${{matrix.cc}-" + $arch + ".exe" + makensis -DOUTFILE=$out dictpw.nsi + - uses: actions/upload-artifact@v4.5.0 + if: always() with: - name: meson-logs-vs-${{matrix.cc}}-${{matrix.arch}} + name: meson-logs-vs-${{matrix.cc}} path: build/meson-logs - - uses: actions/upload-artifact@v2.3.1 + - uses: actions/upload-artifact@v4.5.0 if: success() with: name: setup-vs-${{matrix.cc}}-${{matrix.arch}} diff --git a/.github/workflows/meson-emscripten.txt b/.github/workflows/meson-emscripten.txt new file mode 100644 index 0000000..7e4383e --- /dev/null +++ b/.github/workflows/meson-emscripten.txt @@ -0,0 +1,21 @@ +[binaries] +c = 'emcc' +cpp = 'em++' +ar = 'emar' +exe_wrapper = 'node' + +[properties] +sys_root = '/usr/share/emscripten/system' +shared_lib_suffix = 'js' +static_lib_suffix = 'js' +shared_module_suffix = 'js' +exe_suffix = 'js' + +[built-in options] +c_link_args = ['-s', 'EXPORTED_FUNCTIONS=_main,_malloc'] + +[host_machine] +system = 'emscripten' +cpu_family = 'x86' +cpu = 'x86_64' +endian = 'little' diff --git a/meson.build b/meson.build index b93a384..71683d8 100644 --- a/meson.build +++ b/meson.build @@ -13,7 +13,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. project('dictpw', 'c', version: '1.2.0', license: 'ISC', - default_options: ['c_std=c99', 'b_lto=true', 'warning_level=3']) + default_options: ['c_std=c99', 'warning_level=3']) # Makes all functions, including BSD functions, visible on GNU. args = ['-D_GNU_SOURCE'] @@ -41,7 +41,8 @@ funcs = { libbsd_dep = [] foreach func, header : funcs if not cc.has_function(func, prefix: header, args: args) - libbsd_dep = dependency('libbsd-overlay', static: get_option('static_deps')) + libbsd_dep = dependency('libbsd-overlay', + default_options: ['default_library=static']) break endif endforeach diff --git a/subprojects/libobsd.wrap b/subprojects/libobsd.wrap index cd64cf1..f13038d 100644 --- a/subprojects/libobsd.wrap +++ b/subprojects/libobsd.wrap @@ -1,8 +1,7 @@ -[wrap-file] -directory = libobsd-1.1.0 -source_url = https://github.com/guijan/libobsd/releases/download/v1.1.0/libobsd-1.1.0.tar.xz -source_filename = libobsd-1.1.0.tar.xz -source_hash = 64343ccdd3b7c479954d9806a4531091195d410cc54d0172018d959a61693c2c +[wrap-git] +url = https://github.com/guijan/libobsd +revision = 5d5a4bfc7860e894b031956767a9f59263847ebb +depth = 1 [provide] libbsd-overlay = libobsd_dep