mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-05-21 01:16:39 +08:00
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@ build/
|
|||||||
builddir/
|
builddir/
|
||||||
test/sandbox
|
test/sandbox
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
examples/example_1/subprojects/unity
|
||||||
examples/example_1/test1.exe
|
examples/example_1/test1.exe
|
||||||
examples/example_1/test2.exe
|
examples/example_1/test2.exe
|
||||||
examples/example_2/all_tests.exe
|
examples/example_2/all_tests.exe
|
||||||
|
15
auto/extract_version.py
Executable file
15
auto/extract_version.py
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
ver_re = re.compile(r"^#define\s+UNITY_VERSION_(?:MAJOR|MINOR|BUILD)\s+(\d+)$")
|
||||||
|
version = []
|
||||||
|
|
||||||
|
with open(sys.argv[1], "r") as f:
|
||||||
|
for line in f:
|
||||||
|
m = ver_re.match(line)
|
||||||
|
if m:
|
||||||
|
version.append(m.group(1))
|
||||||
|
|
||||||
|
print(".".join(version))
|
||||||
|
|
48
examples/example_1/meson.build
Normal file
48
examples/example_1/meson.build
Normal file
@ -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)
|
||||||
|
|
@ -2,4 +2,11 @@ Example 1
|
|||||||
=========
|
=========
|
||||||
|
|
||||||
Close to the simplest possible example of Unity, using only basic features.
|
Close to the simplest possible example of Unity, using only basic features.
|
||||||
Run make to build & run the example tests.
|
|
||||||
|
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.
|
||||||
|
3
examples/example_1/subprojects/unity.wrap
Normal file
3
examples/example_1/subprojects/unity.wrap
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[wrap-git]
|
||||||
|
url = https://github.com/ThrowTheSwitch/Unity.git
|
||||||
|
revision = head
|
8
extras/fixture/src/meson.build
Normal file
8
extras/fixture/src/meson.build
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
unity_inc += include_directories('.')
|
||||||
|
unity_src += files('unity_fixture.c')
|
||||||
|
|
||||||
|
install_headers(
|
||||||
|
'unity_fixture.h',
|
||||||
|
'unity_fixture_internals.h',
|
||||||
|
subdir: meson.project_name()
|
||||||
|
)
|
7
extras/memory/src/meson.build
Normal file
7
extras/memory/src/meson.build
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
unity_inc += include_directories('.')
|
||||||
|
unity_src += files('unity_memory.c')
|
||||||
|
|
||||||
|
install_headers(
|
||||||
|
'unity_memory.h',
|
||||||
|
subdir: meson.project_name()
|
||||||
|
)
|
72
meson.build
72
meson.build
@ -5,21 +5,67 @@
|
|||||||
# license: MIT
|
# license: MIT
|
||||||
#
|
#
|
||||||
project('unity', 'c',
|
project('unity', 'c',
|
||||||
license: 'MIT',
|
license: 'MIT',
|
||||||
meson_version: '>=0.37.0',
|
|
||||||
default_options: ['werror=true', 'c_std=c11'])
|
# Set project version to value extracted from unity.h header
|
||||||
|
version: run_command(
|
||||||
|
[
|
||||||
|
'auto/extract_version.py',
|
||||||
|
'src/unity.h'
|
||||||
|
],
|
||||||
|
check: true
|
||||||
|
).stdout().strip(),
|
||||||
|
|
||||||
|
meson_version: '>=0.47.0',
|
||||||
|
default_options: [
|
||||||
|
'werror=true',
|
||||||
|
'c_std=c11'
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
build_fixture = get_option('extension_fixture')
|
||||||
|
build_memory = get_option('extension_memory')
|
||||||
|
|
||||||
|
unity_src = []
|
||||||
|
unity_inc = []
|
||||||
|
|
||||||
subdir('src')
|
subdir('src')
|
||||||
unity_dep = declare_dependency(link_with: unity_lib, include_directories: unity_dir)
|
|
||||||
|
|
||||||
|
if build_fixture
|
||||||
# Get the generate_test_runner script relative to itself or the parent project if it is being used as a subproject
|
# Building the fixture extension implies building the memory
|
||||||
# NOTE: This could be (and probably is) a complete hack - but I haven't yet been able to find a better way....
|
# extension.
|
||||||
if meson.is_subproject()
|
build_memory = true
|
||||||
gen_test_runner_path = find_program(meson.source_root() / 'subprojects/unity/auto/generate_test_runner.rb')
|
subdir('extras/fixture/src')
|
||||||
else
|
|
||||||
gen_test_runner_path = find_program('subprojects/unity/auto/generate_test_runner.rb')
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Create a generator that we can access from the parent project
|
if build_memory
|
||||||
gen_test_runner = generator(gen_test_runner_path, output: '@BASENAME@_Runner.c', arguments: ['@INPUT@', '@OUTPUT@'] )
|
subdir('extras/memory/src')
|
||||||
|
endif
|
||||||
|
|
||||||
|
unity_lib = static_library(meson.project_name(),
|
||||||
|
sources: unity_src,
|
||||||
|
include_directories: unity_inc,
|
||||||
|
install: true
|
||||||
|
)
|
||||||
|
|
||||||
|
unity_dep = declare_dependency(
|
||||||
|
link_with: unity_lib,
|
||||||
|
include_directories: unity_inc
|
||||||
|
)
|
||||||
|
|
||||||
|
# Generate pkg-config file.
|
||||||
|
pkg = import('pkgconfig')
|
||||||
|
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('auto/generate_test_runner.rb'),
|
||||||
|
output: '@BASENAME@_Runner.c',
|
||||||
|
arguments: ['@INPUT@', '@OUTPUT@']
|
||||||
|
)
|
||||||
|
2
meson_options.txt
Normal file
2
meson_options.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
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.')
|
@ -4,10 +4,12 @@
|
|||||||
#
|
#
|
||||||
# license: MIT
|
# license: MIT
|
||||||
#
|
#
|
||||||
unity_dir = include_directories('.')
|
|
||||||
|
|
||||||
unity_lib = static_library(meson.project_name(),
|
unity_inc += include_directories('.')
|
||||||
'unity.c',
|
unity_src += files('unity.c')
|
||||||
include_directories: unity_dir,
|
|
||||||
native: true
|
install_headers(
|
||||||
|
'unity.h',
|
||||||
|
'unity_internals.h',
|
||||||
|
subdir: meson.project_name()
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user