Skip to content

Commit 49f6ef2

Browse files
committed
meta: support headers-only mode and C++ with freestanding headers
1 parent 310ee00 commit 49f6ef2

File tree

4 files changed

+42
-11
lines changed

4 files changed

+42
-11
lines changed

.github/workflows/ci.cross-file

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[binaries]
2+
c = ['gcc-13']
3+
cpp = ['g++-13']
4+
5+
[host_machine]
6+
system = 'linux'
7+
cpu_family = 'x86_64'
8+
cpu = 'x86_64'
9+
endian = 'little'

.github/workflows/ci.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,29 @@ on: [push, pull_request]
55
jobs:
66
build-lil:
77
name: Build lil
8-
runs-on: ubuntu-20.04
8+
runs-on: ubuntu-22.04
99
steps:
1010
- name: Install prerequisites
1111
run: |
1212
set -x
1313
sudo apt-get update
14-
sudo apt-get install meson
14+
sudo apt-get install gcc-13 ninja-build
15+
pip3 install meson
1516
- name: Checkout lil
1617
uses: actions/checkout@v2
1718
- name: Prepare build
1819
run: |
1920
set -x
20-
mkdir -p build/
21-
meson setup --buildtype=debugoptimized build/
21+
mkdir -p build build-util
22+
meson setup --buildtype=debugoptimized --cross-file=.github/workflows/ci.cross-file build/
23+
meson setup --buildtype=debugoptimized --native-file=.github/workflows/ci.cross-file -Dbuild_utils=true build-util/
2224
- name: Build lil
2325
run: |
2426
set -x
2527
ninja
2628
working-directory: build/
29+
- name: Build lil-utils
30+
run: |
31+
set -x
32+
ninja
33+
working-directory: build-util/

meson.build

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
project('lil', ['c'], default_options: ['warning_level=2'])
1+
project('lil', ['c', 'cpp'],
2+
default_options: ['warning_level=2', 'c_std=gnu2x', 'cpp_std=gnu++23'],
3+
meson_version: '>=1.3.0',
4+
)
5+
6+
header_only = get_option('header_only')
7+
build_utils = get_option('build_utils')
28

3-
add_project_arguments(['-Wno-unused-function', '-Wno-unused-variable', '-Wno-unused-parameter', '-Wimplicit-fallthrough'], language: 'c')
9+
if not header_only and (meson.get_compiler('cpp').get_id() != 'gcc' or meson.get_compiler('cpp').version().version_compare('<13'))
10+
error('At least GCC g++ 13 is needed to compile lil.')
11+
endif
412

5-
c_std = 'gnu2x'
13+
add_project_arguments(['-Wno-unused-function', '-Wno-unused-variable', '-Wno-unused-parameter', '-Wimplicit-fallthrough'], language: ['c', 'cpp'])
14+
add_project_arguments(['-Werror=incompatible-pointer-types'], language: ['c'])
615

716
sources = files(
817
'src/edid.c',
@@ -32,9 +41,14 @@ util_vbt_sources = files(
3241
)
3342

3443
include_directories = include_directories('include')
35-
library = static_library('lil', sources, include_directories: include_directories, pic: false)
36-
dependency = declare_dependency(link_with: library, include_directories: include_directories)
3744

38-
if get_option('build_utils')
39-
util_vbt = executable('vbt', util_vbt_sources, dependencies: dependency, native: true)
45+
if header_only
46+
lil_dep = declare_dependency(include_directories: include_directories)
47+
else
48+
library = static_library('lil', sources, include_directories: include_directories, pic: false, install: not header_only)
49+
lil_dep = declare_dependency(link_with: library, include_directories: include_directories)
50+
endif
51+
52+
if build_utils
53+
util_vbt = executable('vbt', util_vbt_sources, dependencies: lil_dep, native: true, install: true)
4054
endif

meson_options.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
option('build_utils', type : 'boolean', value : false)
2+
option('header_only', type : 'boolean', value : false)

0 commit comments

Comments
 (0)