Skip to content

Commit

Permalink
Implement review feedback for Meson updates.
Browse files Browse the repository at this point in the history
1. Call the version extraction script directly instead
   of through a Python returned from `find_program()`.

2. We don't need to use `meson.project_source_root()` as
   `find_program()` will search relative to the current meson.build
   script.

3. Lower the required version back to `>= 0.37.0`, and modify
   some things to get rid of warnings with this version selected.
   The use of `summary()`, `dict`, and positional arguments in
   `pkgconfig.generate()` generate warnings with this version so
   remove `summary()` and dict()`, also pass keyword arguments to
   `pkgconfig.generate()`.
  • Loading branch information
amcnulty-fermat committed Feb 14, 2023
1 parent 44bc9e6 commit 43378c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
29 changes: 10 additions & 19 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,21 @@ project('unity', 'c',
# Set project version to value extracted from unity.h header
version: run_command(
[
find_program('python', 'python3'),
'auto' / 'extract_version.py',
'src' / 'unity.h'
'auto/extract_version.py',
'src/unity.h'
],
check: true
).stdout().strip(),

# `meson.project_source_root()` introduced in 0.56.0
meson_version: '>=0.56.0',
meson_version: '>=0.37.0',
default_options: [
'werror=true',
'c_std=c11'
]
)

build_fixture = get_option('extension_fixture').enabled()
build_memory = get_option('extension_memory').enabled()
build_fixture = get_option('extension_fixture')
build_memory = get_option('extension_memory')

unity_src = []
unity_inc = []
Expand Down Expand Up @@ -57,24 +55,17 @@ unity_dep = declare_dependency(

# Generate pkg-config file.
pkg = import('pkgconfig')
pkg.generate(unity_lib,
pkg.generate(
name: meson.project_name(),
version: meson.project_version(),
libraries: [ unity_lib ],
description: 'C Unit testing framework.'
)

# Create a generator that can be used by consumers of our build system to generate
# test runners.
gen_test_runner = generator(
find_program(meson.project_source_root() / 'auto' / 'generate_test_runner.rb'),
find_program('auto/generate_test_runner.rb'),
output: '@BASENAME@_Runner.c',
arguments: ['@INPUT@', '@OUTPUT@']
)

# Summarize.
summary(
{
'Fixture extension': build_fixture,
'Memory extension': build_memory,
},
section: 'Extensions',
bool_yn: true
)
4 changes: 2 additions & 2 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
option('extension_fixture', type: 'feature', value: 'disabled', description: 'Whether to use the fixture extension.')
option('extension_memory', type: 'feature', value: 'disabled', description: 'Whether to use the memory extension.')
option('extension_fixture', type: 'boolean', value: 'false', description: 'Whether to enable the fixture extension.')
option('extension_memory', type: 'boolean', value: 'false', description: 'Whether to enable the memory extension.')

0 comments on commit 43378c4

Please sign in to comment.