]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
build: Use containers with matrix build
authorDaniel Wagner <dwagner@suse.de>
Mon, 26 Jun 2023 11:44:21 +0000 (13:44 +0200)
committerDaniel Wagner <wagi@monom.org>
Wed, 28 Jun 2023 10:56:31 +0000 (12:56 +0200)
Use a matrix build approach and a base container which already contains
all the libraries installed.

.github/cross/clang.txt [deleted file]
.github/cross/ubuntu-cross-armhf.txt [moved from .github/cross/ubuntu-armhf.txt with 100% similarity]
.github/cross/ubuntu-cross-ppc64le.txt [moved from .github/cross/ubuntu-ppc64le.txt with 100% similarity]
.github/cross/ubuntu-cross-s390x.txt [moved from .github/cross/ubuntu-s390x.txt with 100% similarity]
.github/cross/ubuntu-static.txt [deleted file]
.github/workflows/build.yml
scripts/build.sh

diff --git a/.github/cross/clang.txt b/.github/cross/clang.txt
deleted file mode 100644 (file)
index 1484a3e..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-[binaries]
-c = 'clang'
-cpp = 'clang++'
-strip = 'strip'
-pkgconfig = 'pkg-config'
diff --git a/.github/cross/ubuntu-static.txt b/.github/cross/ubuntu-static.txt
deleted file mode 100644 (file)
index d4d6c9a..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-[properties]
-c_args = '-static'
-cpp_args = c_args
-
-[binaries]
-c = '/usr/bin/gcc'
index 8110ee9146fb5731cfc86d60af66404d06d9b941..0a9a369c29289b3dec748d7ac7151cb50b96a2d9 100644 (file)
@@ -10,19 +10,22 @@ on:
   workflow_dispatch:
 
 jobs:
-  gcc-debug:
-    name: gcc debug
+  default:
     runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        compiler: [gcc, clang]
+        buildtype: [debug, release]
+    container:
+      image: ghcr.io/igaw/linux-nvme/debian:0.30
     steps:
-      - name: install libraries
-        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'
       - name: build
         run: |
-          scripts/build.sh -b debug -c gcc
+          scripts/build.sh -b ${{ matrix.buildtype }} -c ${{ matrix.compiler }}
       - uses: actions/upload-artifact@v3
         name: upload logs
         if: failure()
@@ -31,61 +34,39 @@ jobs:
           path: |
             .build-ci/meson-logs/*.txt
 
-  gcc-release:
-    name: gcc release
+  cross:
     runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        include:
+          - arch: armhf
+            port: armhf
+            compiler: gcc-arm-linux-gnueabihf
+            packages:
+          - arch: s390x
+            port: s390x
+            compiler: gcc-s390x-linux-gnu
+            packages: libgcc-s1:s390x
+          - arch: ppc64le
+            port: ppc64el
+            compiler: gcc-powerpc64le-linux-gnu
+            packges:
     steps:
-      - name: install libraries
-        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'
-      - 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-ci/meson-logs/*.txt
-
-  gcc-release-static:
-    name: gcc release static
-    runs-on: ubuntu-latest
-    steps:
-      - name: install libraries
-        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'
-      - name: build
+      - name: set up arm architecture
         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-ci/meson-logs/*.txt
-
-  clang-debug:
-    name: clang debug
-    runs-on: ubuntu-latest
-    steps:
-      - name: install libraries
-        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'
+          export release=$(lsb_release -c -s)
+          sudo dpkg --add-architecture ${{ matrix.port }}
+          sudo sed -i -e 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list
+          sudo dd of=/etc/apt/sources.list.d/${{ matrix.arch }}.list <<EOF
+          deb [arch=${{ matrix.port }}] http://ports.ubuntu.com/ $release main universe restricted"
+          deb [arch=${{ matrix.port }}] http://ports.ubuntu.com/ $release-updates main universe restricted"
+          EOF
+          sudo apt update
+          sudo apt install -y meson pkg-config qemu-user-static ${{ matrix.compiler}} libjson-c-dev:${{ matrix.port }} ${{ matrix.packages }}
       - name: build
         run: |
-          scripts/build.sh -b debug -c clang libdbus
+          scripts/build.sh -b release -c gcc -t ${{ matrix.arch }} cross
       - uses: actions/upload-artifact@v3
         name: upload logs
         if: failure()
@@ -94,19 +75,19 @@ jobs:
           path: |
             .build-ci/meson-logs/*.txt
 
-  clang-release:
-    name: clang release
+  libdbus:
+    name: libdbus
     runs-on: ubuntu-latest
+    container:
+      image: ghcr.io/igaw/linux-nvme/debian:0.30
     steps:
-      - name: install libraries
-        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'
       - name: build
         run: |
-          scripts/build.sh -b release -c clang libdbus
+          scripts/build.sh -b release -c gcc libdbus
       - uses: actions/upload-artifact@v3
         name: upload logs
         if: failure()
@@ -118,9 +99,10 @@ jobs:
   fallback-shared-libraries:
     name: fallback shared libraries
     runs-on: ubuntu-latest
+    container:
+      image: ghcr.io/igaw/linux-nvme/debian:0.30
+    if: github.ref == 'refs/heads/master'
     steps:
-      - name: install libraries
-        run: sudo apt-get install meson gcc pkg-config libpam-dev libcap-ng-dev
       - uses: actions/checkout@v3
       - uses: actions/setup-python@v4
         with:
@@ -135,99 +117,11 @@ jobs:
           path: |
             .build-ci/meson-logs/*.txt
 
-  cross-armhf:
-    name: cross armhf
-    runs-on: ubuntu-latest
-    steps:
-      - name: set up arm architecture
-        run: |
-          export release=$(lsb_release -c -s)
-          sudo dpkg --add-architecture armhf
-          sudo sed -i -e 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list
-          sudo dd of=/etc/apt/sources.list.d/armhf.list <<EOF
-          deb [arch=armhf] http://ports.ubuntu.com/ $release main universe restricted"
-          deb [arch=armhf] http://ports.ubuntu.com/ $release-updates main universe restricted"
-          EOF
-          sudo apt update
-      - name: install armhf compiler
-        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
-      - 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-ci/meson-logs/*.txt
-
-  cross-ppc64le:
-    name: cross ppc64le
-    runs-on: ubuntu-latest
-    steps:
-      - name: set up ppc64le architecture
-        run: |
-          export release=$(lsb_release -c -s)
-          sudo dpkg --add-architecture ppc64el
-          sudo sed -i -e 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list
-          sudo dd of=/etc/apt/sources.list.d/ppc64el.list <<EOF
-          deb [arch=ppc64el] http://ports.ubuntu.com/ $release main universe restricted"
-          deb [arch=ppc64el] http://ports.ubuntu.com/ $release-updates main universe restricted"
-          EOF
-          sudo apt update
-      - name: install powerpc64le compiler
-        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
-      - 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-ci/meson-logs/*.txt
-
-  cross-s390x:
-    name: cross s390x
-    runs-on: ubuntu-latest
-    steps:
-      - name: set up s390x architecture
-        run: |
-          export release=$(lsb_release -c -s)
-          sudo dpkg --add-architecture s390x
-          sudo sed -i -e 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list
-          sudo dd of=/etc/apt/sources.list.d/s390x.list <<EOF
-          deb [arch=s390x] http://ports.ubuntu.com/ $release main universe restricted"
-          deb [arch=s390x] http://ports.ubuntu.com/ $release-updates main universe restricted"
-          EOF
-          sudo apt update
-      - name: install s390x compiler
-        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
-      - 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-ci/meson-logs/*.txt
-
   build-muon:
-    name: muon minimal
+    name: muon minimal static
     runs-on: ubuntu-latest
+    container:
+      image: ghcr.io/igaw/linux-nvme/debian:0.30
     steps:
       - uses: actions/checkout@v3
       - name: build
index bd038b05a0e163ff8345fc4c4c15f3f1eb75cf78..851fcbdf023315125a4aa334a0920e02811c1661 100755 (executable)
@@ -11,27 +11,26 @@ usage() {
     echo " -b [release]|debug   build type"
     echo " -c [gcc]|clang       compiler to use"
     echo " -m [meson]|muon      use meson or muon"
+    echo " -t [arm]|ppc64le|s390x  cross compile target"
     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 "  cross               use cross toolchain to build"
     echo ""
     echo "configs with muon:"
-    echo "  [default]           minimal build"
+    echo "  [default]           minimal static build"
 }
 
 BUILDTOOL=meson
 MESON=meson
 BUILDTYPE=release
+CROSS_TARGET=arm
 CC=${CC:-"gcc"}
 
-while getopts "b:c:m:" o; do
+while getopts "b:c:m:t:" o; do
     case "${o}" in
         b)
             BUILDTYPE="${OPTARG}"
@@ -42,6 +41,9 @@ while getopts "b:c:m:" o; do
         m)
             BUILDTOOL="${OPTARG}"
             ;;
+        t)
+            CROSS_TARGET="${OPTARG}"
+            ;;
         *)
             usage
             exit 1
@@ -72,19 +74,6 @@ config_meson_libdbus() {
         "${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                                \
@@ -96,32 +85,16 @@ config_meson_fallback() {
         "${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() {
+config_meson_cross() {
     CC="${CC}" "${MESON}" setup                 \
         --werror                                \
         --buildtype="${BUILDTYPE}"              \
-        --cross-file=.github/cross/ubuntu-ppc64le.txt \
+        --cross-file=.github/cross/ubuntu-cross-"${CROSS_TARGET}".txt \
         -Dpython=disabled                       \
+        -Dopenssl=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}"
@@ -129,39 +102,54 @@ build_meson() {
 
 test_meson() {
     "${MESON}" test                             \
+        --verbose                               \
         -C "${BUILDDIR}"
 }
 
+tools_build_samurai() {
+    mkdir -p "${BUILDDIR}"/build-tools
+    git clone --depth 1 https://github.com/michaelforney/samurai.git \
+        "${BUILDDIR}/build-tools/samurai"
+    pushd "${BUILDDIR}/build-tools/samurai" || exit 1
+
+    CC="${CC}" make
+    SAMU="${BUILDDIR}/build-tools/samurai/samu"
+
+    popd || exit 1
+}
+
 tools_build_muon() {
     mkdir -p "${BUILDDIR}"/build-tools
-    git clone --depth 1 https://git.sr.ht/~lattis/muon "${BUILDDIR}/build-tools/muon"
+    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.sh stage1
 
-    CC="${CC}" ninja="${SAMU}" ${BOOTSTRAP_MUON} setup  \
-        -Dlibcurl=disabled                              \
-        -Dlibarchive=disabled                           \
+    CC="${CC}" ninja="${SAMU}" stage1/muon setup        \
+        -Dprefix="${BUILDDIR}/build-tools"              \
+        -Dlibcurl=enabled                               \
+        -Dlibarchive=enabled                            \
+        -Dlibpkgconf=enabled                            \
         -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
+        "${BUILDDIR}/build-tools/.build-muon"
+    "${SAMU}" -C "${BUILDDIR}/build-tools/.build-muon"
+    MUON="${BUILDDIR}/build-tools/.build-muon/muon"
 
-    MUON="${BUILDDIR}/build-tools/muon-bin/muon"
+    # "${MUON}" -C "${BUILDDIR}/build-tools/.build-muon" test
 
     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                     \
+    CC="${CC}" CFLAGS="${CFLAGS} -static"               \
+        ninja="${SAMU}" "${MUON}" setup                 \
+        -Ddefault_library=static                        \
+        -Djson-c=disabled                               \
+        -Dopenssl=disabled                              \
+        -Dkeyutils=disabled                             \
+        -Dpython=disabled                               \
         -Dpython=disabled                               \
         "${BUILDDIR}"
 }
@@ -177,10 +165,15 @@ test_muon() {
 rm -rf "${BUILDDIR}"
 
 if [[ "${BUILDTOOL}" == "muon" ]]; then
-    if ! which samu || ! which muon ; then
-        tools_build_muon
+    if ! which samu ; then
+        tools_build_samurai
     else
         SAMU="$(which samu)"
+    fi
+
+    if ! which muon ; then
+        tools_build_muon
+    else
         MUON="$(which muon)"
     fi
 fi