From cd80a79db525d3456ae7a80c3252b314119536fd Mon Sep 17 00:00:00 2001 From: Andrew McNulty Date: Mon, 13 Feb 2023 16:19:39 +0100 Subject: [PATCH] Add Meson example based on Owen Torres' example. --- .gitignore | 1 + examples/example_1/meson.build | 48 +++++++++++++++++++++++ examples/example_1/readme.txt | 9 ++++- examples/example_1/subprojects/unity.wrap | 3 ++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 examples/example_1/meson.build create mode 100644 examples/example_1/subprojects/unity.wrap diff --git a/.gitignore b/.gitignore index 7500c74..211683a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ build/ builddir/ test/sandbox .DS_Store +examples/example_1/subprojects/unity examples/example_1/test1.exe examples/example_1/test2.exe examples/example_2/all_tests.exe diff --git a/examples/example_1/meson.build b/examples/example_1/meson.build new file mode 100644 index 0000000..645eeb9 --- /dev/null +++ b/examples/example_1/meson.build @@ -0,0 +1,48 @@ +project('Unity example', 'c', + license: 'MIT', + default_options: [ + 'c_std=c99', + 'warning_level=3', + ], + meson_version: '>= 0.49.0' +) + +unity_subproject = subproject('unity') +unity_dependency = unity_subproject.get_variable('unity_dep') +unity_gen_runner = unity_subproject.get_variable('gen_test_runner') + +src1 = files([ + 'src' / 'ProductionCode.c', + 'test' / 'TestProductionCode.c', +]) + +src2 = files([ + 'src' / 'ProductionCode2.c', + 'test' / 'TestProductionCode2.c', +]) + +inc = include_directories('src') + +test1 = executable('test1', + sources: [ + src1, + unity_gen_runner.process('test' / 'TestProductionCode.c') + ], + include_directories: [ inc ], + dependencies: [ unity_dependency ], +) + +test('test1', test1, + should_fail: true) + +test2 = executable('test2', + sources: [ + src2, + unity_gen_runner.process('test' / 'TestProductionCode2.c') + ], + include_directories: [ inc ], + dependencies: [ unity_dependency ], +) + +test('test2', test2) + diff --git a/examples/example_1/readme.txt b/examples/example_1/readme.txt index dfed815..ddddd36 100644 --- a/examples/example_1/readme.txt +++ b/examples/example_1/readme.txt @@ -2,4 +2,11 @@ Example 1 ========= Close to the simplest possible example of Unity, using only basic features. -Run make to build & run the example tests. \ No newline at end of file + +Build and run with Make +--- +Just run `make`. + +Build and run with Meson +--- +Run `meson setup build` to create the build directory, and then `meson test -C build` to build and run the tests. diff --git a/examples/example_1/subprojects/unity.wrap b/examples/example_1/subprojects/unity.wrap new file mode 100644 index 0000000..6df241b --- /dev/null +++ b/examples/example_1/subprojects/unity.wrap @@ -0,0 +1,3 @@ +[wrap-git] +url = https://github.com/ThrowTheSwitch/Unity.git +revision = head