From ae7370eda0b8a3959596734f1b056c76322dbb15 Mon Sep 17 00:00:00 2001 From: Firat17aze Date: Wed, 21 Oct 2026 15:43:49 -0400 Subject: [PATCH] :seedling: Expose Meson runner program Meson consumers could only use the fixed generator object. That prevented custom targets from choosing their own output name and full command line. Expose the already-discovered runner as a subproject variable and document direct custom-target usage. A downstream Meson consumer built and passed with the custom runner output. Resolves: #835 Signed-off-by: Firat17aze --- docs/MesonGeneratorRunner.md | 20 +++++++++++++++++++- docs/UnityChangeLog.md | 4 ++++ meson.build | 3 ++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/MesonGeneratorRunner.md b/docs/MesonGeneratorRunner.md index 3b81e3782..31e804f20 100644 --- a/docs/MesonGeneratorRunner.md +++ b/docs/MesonGeneratorRunner.md @@ -15,4 +15,22 @@ Once you have the generator you need to pass it the absolute path of your test f test_runner = meson.source_root() / 'test/test_example.c' -You can then include `test_runner` as a normal dependency to your builds. Meson will create the test runner in a private directory for each build target. It's only meant to be used as part of the build, so if you need to refer to the runner after the build, you won't be able to use the generator. \ No newline at end of file +You can then include `test_runner` as a normal dependency to your builds. Meson will create the test runner in a private directory for each build target. It's only meant to be used as part of the build, so if you need to refer to the runner after the build, you won't be able to use the generator. + +For cases where the generator's fixed output name is not suitable, the runner program is also available directly: + + runner_program = unity_proj.get_variable('gen_test_runner_exe') + +You can use it in a `custom_target()` to control the output name and pass any supported runner option: + + test_runner = custom_target( + 'test_example_runner', + input: 'test/test_example.c', + output: 'test_example_runner.c', + command: [ + runner_program, + '--use_param_tests=1', + '@INPUT@', + '@OUTPUT@', + ], + ) diff --git a/docs/UnityChangeLog.md b/docs/UnityChangeLog.md index 6e73e27c1..7e03d1284 100644 --- a/docs/UnityChangeLog.md +++ b/docs/UnityChangeLog.md @@ -15,6 +15,10 @@ Prior to 2008, the project was an internal project and not released to the publi ### Unity 2.7.2 +New Features: + + - Meson subprojects can access the test runner generator program directly for custom targets (#835). @Firat17aze + Significant Bugfixes: - Default `UNITY_INCLUDE_EXEC_TIME` macros compile as ISO C99, are statement-safe, and accept `-Wsign-conversion` (#838) diff --git a/meson.build b/meson.build index ddfc563b5..9d1182a1a 100644 --- a/meson.build +++ b/meson.build @@ -81,8 +81,9 @@ endif # Create a generator that can be used by consumers of our build system to generate # test runners. +gen_test_runner_exe = find_program('auto/generate_test_runner.rb') gen_test_runner = generator( - find_program('auto/generate_test_runner.rb'), + gen_test_runner_exe, output: '@BASENAME@_Runner.c', arguments: ['@EXTRA_ARGS@', '@INPUT@', '@OUTPUT@'] )