From f7d705493376e53e0fbc3a82149b7e313740cfbb Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Thu, 21 Sep 2023 09:46:23 +0200 Subject: [PATCH] Add meson build to CI Add x86_64 only meson build for now, meson requires some cross-compile files to be passed. Signed-off-by: Neil Armstrong --- .github/workflows/ci.yml | 10 +++++++ ci/archlinux.sh | 1 + ci/debian.sh | 1 + ci/fedora.sh | 1 + meson.build | 61 +++++++++++++++++++--------------------- 5 files changed, 42 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4cffdb6..9ee6df7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -187,6 +187,16 @@ jobs: echo "############################################" printenv + - name: Meson init + if: ${{ matrix.arch == 'x86-64' && matrix.container != 'ubuntu:xenial' }} + run: | + mkdir build + meson . build + + - name: Ninja build + if: ${{ matrix.arch == 'x86-64' && matrix.container != 'ubuntu:xenial' }} + run: ninja -C build + - name: Compile run: make -j$(nproc) diff --git a/ci/archlinux.sh b/ci/archlinux.sh index d128922..3e7b7e4 100755 --- a/ci/archlinux.sh +++ b/ci/archlinux.sh @@ -22,6 +22,7 @@ pacman -Syu --noconfirm \ systemd-libs \ make \ pkgconf \ + meson \ $PKGS_CC echo "Install finished: $0" diff --git a/ci/debian.sh b/ci/debian.sh index 58ebdff..0b66de9 100755 --- a/ci/debian.sh +++ b/ci/debian.sh @@ -33,6 +33,7 @@ apt install -y --no-install-recommends \ libudev-dev \ libyaml-dev \ make \ + meson \ $PKGS_CC echo "Install finished: $0" diff --git a/ci/fedora.sh b/ci/fedora.sh index d6292bc..4bd34c5 100755 --- a/ci/fedora.sh +++ b/ci/fedora.sh @@ -21,6 +21,7 @@ dnf -y install \ libudev-devel \ libyaml-devel \ make \ + meson \ $PKGS_CC echo "Install finished: $0" diff --git a/meson.build b/meson.build index 2a261fa..0392b0e 100644 --- a/meson.build +++ b/meson.build @@ -2,48 +2,45 @@ project('cdba', 'c', + license : [ 'BSD-3-Clause'], + meson_version : '>= 0.43.0', # for compiler.get_supported_arguments() default_options: [ 'warning_level=2', # sets -Wextra 'buildtype=release', ]) +# Set advanced compiler flags compiler = meson.get_compiler('c') -# If compiler variables are detectable, add some selected ones -if meson.version().version_compare('>=0.43.0') - base_cflags = ['-Wno-unused-parameter', - '-Wno-unused-result', - '-Wno-missing-field-initializers', - '-Wno-sign-compare', - '-Wundef', - '-Wnull-dereference', - '-Wdouble-promotion', - '-Wshadow', - '-Wpointer-arith', - '-Wwrite-strings', - '-Wstrict-overflow=4'] +compiler_cflags = ['-Wno-unused-parameter', + '-Wno-unused-result', + '-Wno-missing-field-initializers', + '-Wno-sign-compare', + '-Wundef', + '-Wnull-dereference', + '-Wdouble-promotion', + '-Wshadow', + '-Wpointer-arith', + '-Wwrite-strings', + '-Wstrict-overflow=4'] - if compiler.get_id() == 'gcc' - compiler_cflags = ['-Werror', # Only set it on GCC - '-Wformat-signedness', - '-Wduplicated-cond', - '-Wduplicated-branches', - '-Wvla-larger-than=1', - '-Walloc-zero', - '-Wunsafe-loop-optimizations', - '-Wcast-align', - '-Wlogical-op', - '-Wjump-misses-init'] - elif compiler.get_id() == 'clang' - # TODO add clang specific options - compiler_cflags = [] - endif - - add_global_arguments(compiler.get_supported_arguments(base_cflags), - compiler.get_supported_arguments(compiler_cflags), - language: 'c') +# TODO add clang specific options +if compiler.get_id() == 'gcc' + compiler_cflags += ['-Werror', # Only set it on GCC + '-Wformat-signedness', + '-Wduplicated-cond', + '-Wduplicated-branches', + '-Wvla-larger-than=1', + '-Walloc-zero', + '-Wunsafe-loop-optimizations', + '-Wcast-align', + '-Wlogical-op', + '-Wjump-misses-init'] endif +add_global_arguments(compiler.get_supported_arguments(compiler_cflags), + language: 'c') + client_srcs = ['cdba.c', 'circ_buf.c'] executable('cdba',