From 97456a410e32d001a1d8ff59a1810968e5d68f1f Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Fri, 23 Jun 2023 15:29:15 +0200 Subject: [PATCH] build: Move CI build steps into a scripts Move the build instruction into a script. This allows to run these steps also locally. Also disable the fallback static library build as it is clearly not working because in the dependencies rely to link against a dynamic glibc. Instead just add a minimal static build without fallbacks. While we are at it, also add a debug clang build. Signed-off-by: Daniel Wagner --- .github/workflows/build.yml | 258 ++++++++---------------------------- scripts/build.sh | 190 ++++++++++++++++++++++++++ 2 files changed, 245 insertions(+), 203 deletions(-) create mode 100755 scripts/build.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 49c4383b..8110ee91 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,203 +15,125 @@ jobs: runs-on: ubuntu-latest steps: - name: install libraries - run: sudo apt-get install gcc pkg-config libjson-c-dev libssl-dev python3-dev + run: sudo apt-get install meson gcc pkg-config libjson-c-dev libssl-dev python3-dev - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: '3.x' - - uses: BSFishy/meson-build@v1.0.3 - name: build - with: - action: build - setup-options: > - --werror - --buildtype=debug - meson-version: 0.61.2 - - uses: BSFishy/meson-build@v1.0.3 - name: test - with: - action: test - meson-version: 0.61.2 + - name: build + run: | + scripts/build.sh -b debug -c gcc - uses: actions/upload-artifact@v3 name: upload logs if: failure() with: name: logs files path: | - build/meson-logs/*.txt + .build-ci/meson-logs/*.txt gcc-release: name: gcc release runs-on: ubuntu-latest steps: - name: install libraries - run: sudo apt-get install gcc pkg-config libjson-c-dev libdbus-1-dev python3-dev + run: sudo apt-get install meson gcc pkg-config libjson-c-dev libdbus-1-dev python3-dev - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: '3.x' - - uses: BSFishy/meson-build@v1.0.3 - name: build - with: - action: build - setup-options: > - --werror - --buildtype=release - -Dlibdbus=enabled - meson-version: 0.61.2 - - uses: BSFishy/meson-build@v1.0.3 - name: test - with: - action: test - meson-version: 0.61.2 + - name: build + run: | + scripts/build.sh -b release -c gcc libdbus - uses: actions/upload-artifact@v3 name: upload logs if: failure() with: name: log files path: | - build/meson-logs/*.txt + .build-ci/meson-logs/*.txt - clang-release: - name: clang release + gcc-release-static: + name: gcc release static runs-on: ubuntu-latest steps: - name: install libraries - run: sudo apt-get install clang pkg-config libjson-c-dev libdbus-1-dev python3-dev + run: sudo apt-get install meson gcc pkg-config libpam-dev libcap-ng-dev - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: '3.x' - - uses: BSFishy/meson-build@v1.0.3 - name: build - with: - action: build - setup-options: > - --werror - --buildtype=release - --cross-file=.github/cross/clang.txt - -Dlibdbus=enabled - meson-version: 0.61.2 - - uses: BSFishy/meson-build@v1.0.3 - name: test - with: - action: test - meson-version: 0.61.2 + - name: build + run: | + scripts/build.sh -b release -c gcc static - uses: actions/upload-artifact@v3 name: upload logs if: failure() with: name: log files path: | - build/meson-logs/*.txt + .build-ci/meson-logs/*.txt - fallback-shared-libraries: - name: fallback shared libraries + clang-debug: + name: clang debug runs-on: ubuntu-latest steps: - name: install libraries - run: sudo apt-get install libpam-dev libcap-ng-dev + run: sudo apt-get install meson clang pkg-config libjson-c-dev libdbus-1-dev python3-dev - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: '3.x' - - uses: BSFishy/meson-build@v1.0.3 - name: build - with: - action: build - setup-options: > - --werror - --buildtype=release - --wrap-mode=forcefallback - -Dlibdbus=enabled - -Ddbus:werror=false - -Dopenssl:werror=false - meson-version: 0.61.2 - - uses: BSFishy/meson-build@v1.0.3 - name: test - with: - action: test - meson-version: 0.61.2 + - name: build + run: | + scripts/build.sh -b debug -c clang libdbus - uses: actions/upload-artifact@v3 + name: upload logs if: failure() with: name: log files path: | - build/meson-logs/*.txt + .build-ci/meson-logs/*.txt - fallback-static-libraries: - name: fallback static libraries + clang-release: + name: clang release runs-on: ubuntu-latest steps: - name: install libraries - run: sudo apt-get install libpam-dev libcap-ng-dev + run: sudo apt-get install meson clang pkg-config libjson-c-dev libdbus-1-dev python3-dev - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: '3.x' - - uses: BSFishy/meson-build@v1.0.3 - name: build - with: - action: build - setup-options: > - --werror - --buildtype=release - --wrap-mode=forcefallback - --default-library=static - -Dlibdbus=enabled - -Ddbus:werror=false - -Dopenssl:werror=false - meson-version: 0.61.2 - - uses: BSFishy/meson-build@v1.0.3 - name: test - with: - action: test - meson-version: 0.61.2 + - name: build + run: | + scripts/build.sh -b release -c clang libdbus - uses: actions/upload-artifact@v3 name: upload logs if: failure() with: name: log files path: | - build/meson-logs/*.txt + .build-ci/meson-logs/*.txt - fallback-all-static: - name: fallback all static + fallback-shared-libraries: + name: fallback shared libraries runs-on: ubuntu-latest steps: - name: install libraries - run: sudo apt-get install libpam-dev libcap-ng-dev + run: sudo apt-get install meson gcc pkg-config libpam-dev libcap-ng-dev - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: '3.x' - - uses: BSFishy/meson-build@v1.0.3 - name: build - with: - action: build - setup-options: > - --werror - --buildtype=release - --wrap-mode=forcefallback - --default-library=static - --cross-file=.github/cross/ubuntu-static.txt - -Dlibdbus=enabled - -Ddbus:werror=false - -Dopenssl:werror=false - meson-version: 0.61.2 - - uses: BSFishy/meson-build@v1.0.3 - name: test - with: - action: test - meson-version: 0.61.2 + - name: build + run: | + scripts/build.sh -b release -c gcc fallback - uses: actions/upload-artifact@v3 - name: upload logs if: failure() with: name: log files path: | - build/meson-logs/*.txt + .build-ci/meson-logs/*.txt cross-armhf: name: cross armhf @@ -228,32 +150,20 @@ jobs: EOF sudo apt update - name: install armhf compiler - run: sudo apt install gcc-arm-linux-gnueabihf pkg-config qemu-user-static + run: sudo apt install meson gcc-arm-linux-gnueabihf pkg-config qemu-user-static - name: install libraries run: sudo apt install libjson-c-dev:armhf - uses: actions/checkout@v3 - - uses: BSFishy/meson-build@v1.0.3 - name: build - with: - action: build - setup-options: > - --werror - --buildtype=release - --cross-file=.github/cross/ubuntu-armhf.txt - -Dpython=disabled - meson-version: 0.61.2 - - uses: BSFishy/meson-build@v1.0.3 - name: test - with: - action: test - meson-version: 0.61.2 + - name: build + run: | + scripts/build.sh -b release -c gcc cross_armhf - uses: actions/upload-artifact@v3 name: upload logs if: failure() with: name: log files path: | - build/meson-logs/*.txt + .build-ci/meson-logs/*.txt cross-ppc64le: name: cross ppc64le @@ -270,32 +180,20 @@ jobs: EOF sudo apt update - name: install powerpc64le compiler - run: sudo apt install gcc-powerpc64le-linux-gnu pkg-config qemu-user-static + run: sudo apt install meson gcc-powerpc64le-linux-gnu pkg-config qemu-user-static - name: install libraries run: sudo apt install libjson-c-dev:ppc64el - uses: actions/checkout@v3 - - uses: BSFishy/meson-build@v1.0.3 - name: build - with: - action: build - setup-options: > - --werror - --buildtype=release - --cross-file=.github/cross/ubuntu-ppc64le.txt - -Dpython=disabled - meson-version: 0.61.2 - - uses: BSFishy/meson-build@v1.0.3 - name: test - with: - action: test - meson-version: 0.61.2 + - name: build + run: | + scripts/build.sh -b release -c gcc cross_ppc64le - uses: actions/upload-artifact@v3 name: upload logs if: failure() with: name: log files path: | - build/meson-logs/*.txt + .build-ci/meson-logs/*.txt cross-s390x: name: cross s390x @@ -312,72 +210,26 @@ jobs: EOF sudo apt update - name: install s390x compiler - run: sudo apt install gcc-s390x-linux-gnu libgcc-s1:s390x pkg-config qemu-user-static + run: sudo apt install meson gcc-s390x-linux-gnu libgcc-s1:s390x pkg-config qemu-user-static - name: install libraries run: sudo apt install libjson-c-dev:s390x - uses: actions/checkout@v3 - - uses: BSFishy/meson-build@v1.0.3 - name: build - with: - action: build - setup-options: > - --werror - --buildtype=release - --cross-file=.github/cross/ubuntu-s390x.txt - -Dpython=disabled - meson-version: 0.61.2 - - uses: BSFishy/meson-build@v1.0.3 - name: test - with: - action: test - meson-version: 0.61.2 + - name: build + run: | + scripts/build.sh -b release -c gcc cross_s390x - uses: actions/upload-artifact@v3 name: upload logs if: failure() with: name: log files path: | - build/meson-logs/*.txt + .build-ci/meson-logs/*.txt build-muon: name: muon minimal runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: build muon and samurai build-tool - run: | - mkdir build-tools - cd build-tools - git clone --depth 1 https://git.sr.ht/~lattis/muon - cd muon - - export CC=gcc - export ninja=build/samu - - ./tools/bootstrap_ninja.sh build - ./bootstrap.sh build - - build/muon setup \ - -Dlibcurl=disabled \ - -Dlibarchive=disabled \ - -Ddocs=disabled \ - -Dsamurai=disabled \ - build - build/samu -C build - build/muon -C build test - name: build run: | - export PATH=$(pwd)/build-tools/muon/build:$PATH - - # Need to explicitly disable python as muon currently - # only partially supports the python module. It misses - # the dependency() implementation - muon setup \ - -Dpython=disabled \ - build - samu -C build - - name: test - run: | - export PATH=$(pwd)/build-tools/muon/build:$PATH - - muon -C build test + scripts/build.sh -m muon diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 00000000..40cb85a2 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,190 @@ +#!/bin/bash + +usage() { + echo "Usage: build.sh [-b [release|debug]] " + echo " [-c [gcc|clang]]" + echo " [-m [meson|muon]" + echo " [config]" + echo "" + echo "CI build script." + echo "" + echo " -b [release]|debug build type" + echo " -c [gcc]|clang compiler to use" + echo " -m [meson]|muon use meson or muon" + echo "" + echo "configs with meson:" + echo " [default] default settings" + echo " libdbus build with libdbus" + echo " static build without any depedencies and static" + echo " fallback download all dependencies" + echo " and build them as shared libaries" + echo " cross_armhf build armhf with a cross compiler" + echo " cross_ppc64le build ppc64le with a cross compiler" + echo " cross_s390x build s390x with a cross compiler" + echo "" + echo "configs with muon:" + echo " [default] minimal build" +} + +BUILDTOOL=meson +MESON=meson +BUILDTYPE=release +CC=${CC:-"gcc"} + +while getopts "b:c:m:" o; do + case "${o}" in + b) + BUILDTYPE="${OPTARG}" + ;; + c) + CC="${OPTARG}" + ;; + m) + BUILDTOOL="${OPTARG}" + ;; + *) + usage + exit 1 + ;; + esac +done +shift $((OPTIND-1)) + +CONFIG=${1:-"default"} + +cd "$(git rev-parse --show-toplevel)" || exit 1 + +BUILDDIR="$(pwd)/.build-ci" + +config_meson_default() { + CC="${CC}" "${MESON}" setup \ + --werror \ + --buildtype="${BUILDTYPE}" \ + "${BUILDDIR}" +} + +config_meson_libdbus() { + CC="${CC}" "${MESON}" setup \ + --werror \ + --buildtype="${BUILDTYPE}" \ + -Dlibdbus=enabled \ + --prefix=/ \ + "${BUILDDIR}" +} + +config_meson_static() { + CC="${CC}" CFLAGS="${CFLAGS} -static" \ + "${MESON}" setup \ + --werror \ + --buildtype="${BUILDTYPE}" \ + --default-library=static \ + -Dlibdbus=disabled \ + -Dopenssl=disabled \ + -Dkeyutils=disabled \ + -Dpython=disabled \ + "${BUILDDIR}" +} + +config_meson_fallback() { + CC="${CC}" "${MESON}" setup \ + --werror \ + --buildtype="${BUILDTYPE}" \ + --wrap-mode=forcefallback \ + -Dlibdbus=enabled \ + -Ddbus:werror=false \ + -Dopenssl:werror=false \ + "${BUILDDIR}" +} + +config_meson_cross_armhf() { + CC="${CC}" "${MESON}" setup \ + --werror \ + --buildtype="${BUILDTYPE}" \ + --cross-file=.github/cross/ubuntu-armhf.txt \ + -Dpython=disabled \ + "${BUILDDIR}" +} + +config_meson_cross_ppc64le() { + CC="${CC}" "${MESON}" setup \ + --werror \ + --buildtype="${BUILDTYPE}" \ + --cross-file=.github/cross/ubuntu-ppc64le.txt \ + -Dpython=disabled \ + "${BUILDDIR}" +} + +config_meson_cross_s390x() { + CC="${CC}" "${MESON}" setup \ + --werror \ + --buildtype="${BUILDTYPE}" \ + --cross-file=.github/cross/ubuntu-s390x.txt \ + -Dpython=disabled \ + "${BUILDDIR}" +} +build_meson() { + "${MESON}" compile \ + -C "${BUILDDIR}" +} + +test_meson() { + "${MESON}" test \ + -C "${BUILDDIR}" +} + +tools_build_muon() { + mkdir -p "${BUILDDIR}"/build-tools + git clone --depth 1 https://git.sr.ht/~lattis/muon "${BUILDDIR}/build-tools/muon" + pushd "${BUILDDIR}/build-tools/muon" || exit 1 + + CC="${CC}" ./tools/bootstrap_ninja.sh build + SAMU="${BUILDDIR}/build-tools/muon/build/samu" + + CC="${CC}" ninja="${SAMU}" ./bootstrap.sh build + BOOTSTRAP_MUON="${BUILDDIR}/build-tools/muon/build/muon" + + CC="${CC}" ninja="${SAMU}" ${BOOTSTRAP_MUON} setup \ + -Dlibcurl=disabled \ + -Dlibarchive=disabled \ + -Ddocs=disabled \ + -Dsamurai=disabled \ + "${BUILDDIR}/build-tools/muon-bin" + "${SAMU}" -C "${BUILDDIR}/build-tools/muon-bin" + #"${BOOTSTRAP_MUON}" -C "${BUILDDIR}/build-tools/muon-bin" test + + MUON="${BUILDDIR}/build-tools/muon-bin/muon" + + popd || exit 1 +} + +config_muon_default() { + # Need to explicitly disable python as muon currently + # only partially supports the python module. It misses + # the dependency() implementation + ninja="${SAMU}" "${MUON}" setup \ + -Dpython=disabled \ + "${BUILDDIR}" +} + +build_muon() { + "${SAMU}" -C "${BUILDDIR}" +} + +test_muon() { + ninja="${SAMU}" "${MUON}" -C "${BUILDDIR}" test +} + +rm -rf "${BUILDDIR}" + +if [[ "${BUILDTOOL}" == "muon" ]]; then + if ! which samu || ! which muon ; then + tools_build_muon + else + SAMU="$(which samu)" + MUON="$(which muon)" + fi +fi + +config_"${BUILDTOOL}"_"${CONFIG}" +build_"${BUILDTOOL}" +test_"${BUILDTOOL}" -- 2.49.0