Merge pull request #445 from michaelbadcrumble/fix_meson_support

Fix Meson build system support.
This commit is contained in:
Mark VanderVoord
2019-09-30 05:58:47 -04:00
committed by GitHub
6 changed files with 62 additions and 100 deletions

View File

@ -1,6 +1,6 @@
################################################################################### ###################################################################################
# # # #
# NAME: examples/example_4/meson.build # # NAME: meson.build #
# # # #
# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # # AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. #
# WRITTEN BY: Michael Brockus. # # WRITTEN BY: Michael Brockus. #
@ -9,12 +9,9 @@
# # # #
################################################################################### ###################################################################################
project('example-4', 'c') project('example-4', 'c')
unity_dep = dependency('unity', fallback : ['unity', 'unity_dep']) unity_dep = dependency('unity', fallback : ['unity', 'unity_dep'])
example_dir = include_directories('.', join_paths('.', 'src'))
subdir('src') subdir('src')
subdir('test') subdir('test')

View File

@ -1,6 +1,6 @@
################################################################################### ###################################################################################
# # # #
# NAME: examples/example_4/src/meson.build # # NAME: meson.build #
# # # #
# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # # AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. #
# WRITTEN BY: Michael Brockus. # # WRITTEN BY: Michael Brockus. #
@ -9,23 +9,13 @@
# # # #
################################################################################### ###################################################################################
inc_dir = include_directories('.')
lib_list = {'a': ['ProductionCode.c' ], 'b': ['ProductionCode2.c']}
foreach lib, src : lib_list
set_variable(lib + '_lib',
static_library(lib + '_lib', sources: src, include_directories: inc_dir))
endforeach
a_lib = library( a_dep = declare_dependency(link_with: a_lib, include_directories: inc_dir)
'production-code-1', b_dep = declare_dependency(link_with: b_lib, include_directories: inc_dir)
'ProductionCode.c',
include_directories: example_dir)
b_lib = library(
'production-code-2',
'ProductionCode2.c',
include_directories: example_dir)
a_dep = declare_dependency(
link_with: a_lib,
include_directories: example_dir)
b_dep = declare_dependency(
link_with: b_lib,
include_directories: example_dir)

View File

@ -1,6 +1,6 @@
################################################################################### ###################################################################################
# # # #
# NAME: examples/example_4/test/meson.build # # NAME: meson.build #
# # # #
# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # # AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. #
# WRITTEN BY: Michael Brockus. # # WRITTEN BY: Michael Brockus. #
@ -9,6 +9,4 @@
# # # #
################################################################################### ###################################################################################
subdir('test_runners')
subdir('test_runners')

View File

@ -1,6 +1,6 @@
################################################################################### ###################################################################################
# # # #
# NAME: examples/example_4/test/test_runners/meson.build # # NAME: meson.build #
# # # #
# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # # AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. #
# WRITTEN BY: Michael Brockus. # # WRITTEN BY: Michael Brockus. #
@ -9,16 +9,8 @@
# # # #
################################################################################### ###################################################################################
cases = [['TestProductionCode_Runner.c', join_paths('..' ,'TestProductionCode.c')],
['TestProductionCode2_Runner.c', join_paths('..' ,'TestProductionCode2.c')]]
test('Running: 01-test-case', executable('01-test-case', cases[0], dependencies: [ a_dep, unity_dep ]))
test_src_1 = [ test('Running: 02-test-case', executable('02-test-case', cases[1], dependencies: [ b_dep, unity_dep ]))
'TestProductionCode_Runner.c',
join_paths('..' ,'TestProductionCode.c')
]
test_src_2 = [
'TestProductionCode2_Runner.c',
join_paths('..' ,'TestProductionCode2.c')
]
test('Test production code one', executable('test-1', test_src_1, dependencies: [ a_dep, unity_dep ]))
test('Test production code two', executable('test-2', test_src_2, dependencies: [ b_dep, unity_dep ]))

View File

@ -12,69 +12,58 @@
project('unity', 'c', project('unity', 'c',
version : '2.4.3',
license : 'MIT', license : 'MIT',
meson_version : '>=0.50.0', meson_version : '>=0.50.0',
default_options : default_options: [
[ 'buildtype=minsize',
'werror=true',
'optimization=3', 'optimization=3',
'warning_level=3', 'warning_level=3',
'b_sanitize=address,undefined', 'werror=true',
'b_lto=true', ]
'b_lundef=true' )
]) lang = 'c'
cc = meson.get_compiler('c') cc = meson.get_compiler(lang)
args_for_langs = 'c'
##
#
# Meson: Add compiler flags
#
##
if cc.get_id() == 'clang' if cc.get_id() == 'clang'
add_project_arguments( add_project_arguments(cc.get_supported_arguments(
'-Wweak-vtables', [
'-Wexit-time-destructors', '-Wweak-vtables', '-Wexit-time-destructors',
'-Wglobal-constructors', '-Wglobal-constructors', '-Wmissing-noreturn'
'-Wmissing-noreturn', language: args_for_langs) ]
), language: lang)
endif endif
if cc.get_argument_syntax() == 'gcc' if cc.get_argument_syntax() == 'gcc'
add_project_arguments( add_project_arguments(cc.get_supported_arguments(
'-Wall', [
'-Wextra', '-Wformat', '-Waddress', '-Winit-self', '-Wno-multichar',
'-Wunreachable-code', '-Wpointer-arith' , '-Wwrite-strings' ,
'-Wmissing-declarations', '-Wno-parentheses' , '-Wno-type-limits' ,
'-Wmissing-prototypes', '-Wformat-security' , '-Wunreachable-code' ,
'-Wredundant-decls', '-Waggregate-return' , '-Wformat-nonliteral' ,
'-Wundef', '-Wmissing-prototypes' , '-Wold-style-definition' ,
'-Wwrite-strings', '-Wmissing-declarations', '-Wmissing-include-dirs' ,
'-Wformat', '-Wno-unused-parameter' , '-Wdeclaration-after-statement'
'-Wformat-nonliteral', ]
'-Wformat-security', ), language: lang)
'-Wold-style-definition',
'-Winit-self',
'-Wmissing-include-dirs',
'-Waddress',
'-Waggregate-return',
'-Wno-multichar',
'-Wdeclaration-after-statement',
'-Wvla',
'-Wpointer-arith',language: args_for_langs)
endif endif
if cc.get_id() == 'msvc' if cc.get_id() == 'msvc'
add_project_arguments( add_project_arguments(cc.get_supported_arguments(
'/W4', [
'/w44265', '/w44265', '/w44061', '/w44062',
'/w44061', '/wd4018', '/wd4146', '/wd4244',
'/w44062', '/wd4305',
'/wd4018', # implicit signed/unsigned conversion ]
'/wd4146', # unary minus on unsigned (beware INT_MIN) ), language: lang)
'/wd4244', # lossy type conversion (e.g. double -> int)
'/wd4305', # truncating type conversion (e.g. double -> float)
mesno.get_supported_arguments(['/utf-8']), language: args_for_langs)
endif endif
subdir('src') subdir('src')
unity_dep = declare_dependency( unity_dep = declare_dependency(link_with: unity_lib, include_directories: unity_dir)
version: meson.project_version(),
link_with: unity_lib,
include_directories: unity_dir)

View File

@ -1,6 +1,6 @@
################################################################################### ###################################################################################
# # # #
# NAME: src/meson.build # # NAME: meson.build #
# # # #
# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # # AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. #
# WRITTEN BY: Michael Brockus. # # WRITTEN BY: Michael Brockus. #
@ -9,12 +9,8 @@
# # # #
################################################################################### ###################################################################################
unity_src = files('unity.c')
unity_dir = include_directories('.') unity_dir = include_directories('.')
unity_lib = library(meson.project_name(), unity_lib = static_library(meson.project_name(),
sources: unity_src, sources: ['unity.c'],
include_directories: unity_dir) include_directories: unity_dir)