From c2c42ce14fb6b54c491f9be9c60c5b34aeeac8a0 Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Tue, 17 Sep 2019 09:31:26 -0700 Subject: [PATCH 1/7] Update meson.build Cleaned up compiler flags in root meson.build, renamed a variable and removed 'c_std=' because Meson sets C standard flag to C11 by default. --- meson.build | 87 ++++++++++++++++++++++++----------------------------- 1 file changed, 40 insertions(+), 47 deletions(-) diff --git a/meson.build b/meson.build index 7b9732a..6d1ee3d 100644 --- a/meson.build +++ b/meson.build @@ -15,61 +15,54 @@ project('unity', 'c', version : '2.4.3', license : 'MIT', meson_version : '>=0.50.0', - default_options : - [ - 'werror=true', + default_options: [ + 'buildtype=minsize', 'optimization=3', - 'warning_level=3', - 'b_sanitize=address,undefined', - 'b_lto=true', - 'b_lundef=true' - ]) -cc = meson.get_compiler('c') -args_for_langs = 'c' + 'warning_level=3', + 'werror=true', + ] +) +lang = 'c' +cc = meson.get_compiler(lang) + +## +# +# Meson: Add compiler flags +# +## if cc.get_id() == 'clang' - add_project_arguments( - '-Wweak-vtables', - '-Wexit-time-destructors', - '-Wglobal-constructors', - '-Wmissing-noreturn', language: args_for_langs) + add_project_arguments(cc.get_supported_arguments( + [ + '-Wweak-vtables', '-Wexit-time-destructors', + '-Wglobal-constructors', '-Wmissing-noreturn' + ] + ), language: lang) endif if cc.get_argument_syntax() == 'gcc' - add_project_arguments( - '-Wall', - '-Wextra', - '-Wunreachable-code', - '-Wmissing-declarations', - '-Wmissing-prototypes', - '-Wredundant-decls', - '-Wundef', - '-Wwrite-strings', - '-Wformat', - '-Wformat-nonliteral', - '-Wformat-security', - '-Wold-style-definition', - '-Winit-self', - '-Wmissing-include-dirs', - '-Waddress', - '-Waggregate-return', - '-Wno-multichar', - '-Wdeclaration-after-statement', - '-Wvla', - '-Wpointer-arith',language: args_for_langs) + add_project_arguments(cc.get_supported_arguments( + [ + '-Wformat', '-Waddress', '-Winit-self', '-Wno-multichar', + '-Wpointer-arith' , '-Wwrite-strings' , + '-Wno-parentheses' , '-Wno-type-limits' , + '-Wformat-security' , '-Wunreachable-code' , + '-Waggregate-return' , '-Wformat-nonliteral' , + '-Wmissing-prototypes' , '-Wold-style-definition' , + '-Wmissing-declarations', '-Wmissing-include-dirs' , + '-Wno-unused-parameter' , '-Wdeclaration-after-statement' + ] + ), language: lang) endif if cc.get_id() == 'msvc' - add_project_arguments( - '/W4', - '/w44265', - '/w44061', - '/w44062', - '/wd4018', # implicit signed/unsigned conversion - '/wd4146', # unary minus on unsigned (beware INT_MIN) - '/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) + add_project_arguments(cc.get_supported_arguments( + [ + '/w44265', '/w44061', '/w44062', + '/wd4018', '/wd4146', '/wd4244', + '/wd4305', + ] + ), language: lang) endif subdir('src') @@ -77,4 +70,4 @@ subdir('src') unity_dep = declare_dependency( version: meson.project_version(), link_with: unity_lib, - include_directories: unity_dir) \ No newline at end of file + include_directories: unity_dir) From 822e244bd4a950038c65feb2e76f7301bc7d8129 Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Tue, 17 Sep 2019 09:37:41 -0700 Subject: [PATCH 2/7] Update source meson.build Removed 'unity_src' variable because Unity only one source file, changed library method to static only because there was some issues with using Unity as a shared library, cleaned sub meson.build script and fixed comment in sub source root. --- src/meson.build | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/meson.build b/src/meson.build index 5d8c452..f5e0146 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,6 +1,6 @@ ################################################################################### # # -# NAME: src/meson.build # +# NAME: meson.build # # # # AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # # WRITTEN BY: Michael Brockus. # @@ -9,12 +9,8 @@ # # ################################################################################### - - -unity_src = files('unity.c') - unity_dir = include_directories('.') -unity_lib = library(meson.project_name(), - sources: unity_src, - include_directories: unity_dir) \ No newline at end of file +unity_lib = static_library(meson.project_name(), + sources: ['unity.c'], + include_directories: unity_dir) From f2711a87a63efe7fbbee5178cfacfbdb1a7615b9 Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Tue, 17 Sep 2019 11:25:17 -0700 Subject: [PATCH 3/7] Update meson.build Moved example dir variable into source meson.build script, fixed comment. --- examples/example_4/meson.build | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/examples/example_4/meson.build b/examples/example_4/meson.build index ffa2f5e..4bf968c 100644 --- a/examples/example_4/meson.build +++ b/examples/example_4/meson.build @@ -1,6 +1,6 @@ ################################################################################### # # -# NAME: examples/example_4/meson.build # +# NAME: meson.build # # # # AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # # WRITTEN BY: Michael Brockus. # @@ -9,12 +9,9 @@ # # ################################################################################### - project('example-4', 'c') unity_dep = dependency('unity', fallback : ['unity', 'unity_dep']) -example_dir = include_directories('.', join_paths('.', 'src')) - subdir('src') -subdir('test') \ No newline at end of file +subdir('test') From 964a58c0534df65eec430f38c1d470cf1c707149 Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Tue, 17 Sep 2019 11:28:47 -0700 Subject: [PATCH 4/7] Updated sub meson script in example src. Added foreach loop to avoid DRY, Put source files in map structors, fixed comment. --- examples/example_4/src/meson.build | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/examples/example_4/src/meson.build b/examples/example_4/src/meson.build index 5f7e5da..8fac6c4 100644 --- a/examples/example_4/src/meson.build +++ b/examples/example_4/src/meson.build @@ -1,6 +1,6 @@ ################################################################################### # # -# NAME: examples/example_4/src/meson.build # +# NAME: meson.build # # # # AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # # 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( - 'production-code-1', - '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) \ No newline at end of file +a_dep = declare_dependency(link_with: a_lib, include_directories: inc_dir) +b_dep = declare_dependency(link_with: b_lib, include_directories: inc_dir) From 29af4c0e0d05c69d93bcc909defef8ee871eaeee Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Tue, 17 Sep 2019 11:30:07 -0700 Subject: [PATCH 5/7] Updated sub meson.build in example test dir. Removed newlines and fixed comment. --- examples/example_4/test/meson.build | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/example_4/test/meson.build b/examples/example_4/test/meson.build index d551df9..876a78c 100644 --- a/examples/example_4/test/meson.build +++ b/examples/example_4/test/meson.build @@ -1,6 +1,6 @@ ################################################################################### # # -# NAME: examples/example_4/test/meson.build # +# NAME: meson.build # # # # AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # # WRITTEN BY: Michael Brockus. # @@ -9,6 +9,4 @@ # # ################################################################################### - - -subdir('test_runners') \ No newline at end of file +subdir('test_runners') From 31ab99b860eb884b44879750215573154250dc0a Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Tue, 17 Sep 2019 11:33:31 -0700 Subject: [PATCH 6/7] Update sub meson.build in test runner dir. Put source in an array, cleaned up script and fixed comment. --- .../example_4/test/test_runners/meson.build | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/examples/example_4/test/test_runners/meson.build b/examples/example_4/test/test_runners/meson.build index 005ca67..33c105f 100644 --- a/examples/example_4/test/test_runners/meson.build +++ b/examples/example_4/test/test_runners/meson.build @@ -1,6 +1,6 @@ ################################################################################### # # -# NAME: examples/example_4/test/test_runners/meson.build # +# NAME: meson.build # # # # AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # # WRITTEN BY: Michael Brockus. # @@ -9,16 +9,8 @@ # # ################################################################################### +cases = [['TestProductionCode_Runner.c', join_paths('..' ,'TestProductionCode.c')], + ['TestProductionCode2_Runner.c', join_paths('..' ,'TestProductionCode2.c')]] - -test_src_1 = [ - '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 ])) \ No newline at end of file +test('Running: 01-test-case', executable('01-test-case', cases[0], dependencies: [ a_dep, unity_dep ])) +test('Running: 02-test-case', executable('02-test-case', cases[1], dependencies: [ b_dep, unity_dep ])) From f4251bf87db984222b7c3818767cd6a81a8e7c47 Mon Sep 17 00:00:00 2001 From: Michael Brockus <55331536+michaelbadcrumble@users.noreply.github.com> Date: Tue, 17 Sep 2019 12:23:28 -0700 Subject: [PATCH 7/7] Remove Unity version number. Removed Unity version number from Meson build scripts so there is one less thing to change when doing updates to this script. --- meson.build | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 6d1ee3d..a2c0a15 100644 --- a/meson.build +++ b/meson.build @@ -12,7 +12,6 @@ project('unity', 'c', - version : '2.4.3', license : 'MIT', meson_version : '>=0.50.0', default_options: [ @@ -67,7 +66,4 @@ endif subdir('src') -unity_dep = declare_dependency( - version: meson.project_version(), - link_with: unity_lib, - include_directories: unity_dir) +unity_dep = declare_dependency(link_with: unity_lib, include_directories: unity_dir)