Skip to content

Commit cd80a79

Browse files
Add Meson example based on Owen Torres' example.
1 parent 699a391 commit cd80a79

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ build/
22
builddir/
33
test/sandbox
44
.DS_Store
5+
examples/example_1/subprojects/unity
56
examples/example_1/test1.exe
67
examples/example_1/test2.exe
78
examples/example_2/all_tests.exe

examples/example_1/meson.build

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
project('Unity example', 'c',
2+
license: 'MIT',
3+
default_options: [
4+
'c_std=c99',
5+
'warning_level=3',
6+
],
7+
meson_version: '>= 0.49.0'
8+
)
9+
10+
unity_subproject = subproject('unity')
11+
unity_dependency = unity_subproject.get_variable('unity_dep')
12+
unity_gen_runner = unity_subproject.get_variable('gen_test_runner')
13+
14+
src1 = files([
15+
'src' / 'ProductionCode.c',
16+
'test' / 'TestProductionCode.c',
17+
])
18+
19+
src2 = files([
20+
'src' / 'ProductionCode2.c',
21+
'test' / 'TestProductionCode2.c',
22+
])
23+
24+
inc = include_directories('src')
25+
26+
test1 = executable('test1',
27+
sources: [
28+
src1,
29+
unity_gen_runner.process('test' / 'TestProductionCode.c')
30+
],
31+
include_directories: [ inc ],
32+
dependencies: [ unity_dependency ],
33+
)
34+
35+
test('test1', test1,
36+
should_fail: true)
37+
38+
test2 = executable('test2',
39+
sources: [
40+
src2,
41+
unity_gen_runner.process('test' / 'TestProductionCode2.c')
42+
],
43+
include_directories: [ inc ],
44+
dependencies: [ unity_dependency ],
45+
)
46+
47+
test('test2', test2)
48+

examples/example_1/readme.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,11 @@ Example 1
22
=========
33

44
Close to the simplest possible example of Unity, using only basic features.
5-
Run make to build & run the example tests.
5+
6+
Build and run with Make
7+
---
8+
Just run `make`.
9+
10+
Build and run with Meson
11+
---
12+
Run `meson setup build` to create the build directory, and then `meson test -C build` to build and run the tests.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[wrap-git]
2+
url = https://github.com/ThrowTheSwitch/Unity.git
3+
revision = head

0 commit comments

Comments
 (0)