Added support to inject "extern C" into runners when generated.

This commit is contained in:
Mark VanderVoord
2018-08-09 08:48:08 -04:00
parent 031f3bbe45
commit 9987824da7
2 changed files with 9 additions and 0 deletions

View File

@ -197,9 +197,11 @@ class UnityTestRunnerGenerator
output.puts("\n/*=======External Functions This Runner Calls=====*/")
output.puts("extern void #{@options[:setup_name]}(void);")
output.puts("extern void #{@options[:teardown_name]}(void);")
output.puts("\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif") if @options[:externc]
tests.each do |test|
output.puts("extern void #{test[:test]}(#{test[:call] || 'void'});")
end
output.puts("#ifdef __cplusplus\n}\n#endif") if @options[:externc]
output.puts('')
end
@ -439,6 +441,7 @@ if $0 == __FILE__
' *.h - header files are added as #includes in runner',
' options:',
' -cexception - include cexception support',
' -externc - add extern "C" for cpp support',
' --setup_name="" - redefine setUp func name to something else',
' --teardown_name="" - redefine tearDown func name to something else',
' --main_name="" - redefine main func name to something else',

View File

@ -159,6 +159,12 @@ CMock (see CMock documentation). This generates extra variables required for
everything to run smoothly. If you provide the same YAML to the generator as
used in CMock's configuration, you've already configured the generator properly.
##### `:externc`
This option should be defined if you are mixing C and CPP and want your test
runners to automatically include extern "C" support when they are generated.
##### `:mock_prefix` and `:mock_suffix`
Unity automatically generates calls to Init, Verify and Destroy for every file