Added -externcincludes option in order to build unit test executable in mixed C/C++ environment
@@ -212,8 +212,10 @@ class UnityTestRunnerGenerator
def create_header(output, mocks, testfile_includes = [])
output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */')
output.puts("\n/*=======Automagically Detected Files To Include=====*/")
+ output.puts('extern "C" {') if @options[:externcincludes]
output.puts("#include \"#{@options[:framework]}.h\"")
output.puts('#include "cmock.h"') unless mocks.empty?
+ output.puts('}') if @options[:externcincludes]
if @options[:defines] && !@options[:defines].empty?
@options[:defines].each { |d| output.puts("#ifndef #{d}\n#define #{d}\n#endif /* #{d} */") }
end
@@ -227,9 +229,11 @@ class UnityTestRunnerGenerator
output.puts("#include #{inc.include?('<') ? inc : "\"#{inc}\""}")
end
end
+ output.puts('extern "C" {') if @options[:externcincludes]
mocks.each do |mock|
output.puts("#include \"#{mock}\"")
end
+ output.puts('}') if @options[:externcincludes]
output.puts('#include "CException.h"') if @options[:plugins].include?(:cexception)
return unless @options[:enforce_strict_ordering]
@@ -465,6 +469,9 @@ if $0 == __FILE__
when '-cexception'
options[:plugins] = [:cexception]
true
+ when '-externcincludes'
+ options[:externcincludes] = true
+ true
when /\.*\.ya?ml$/
options = UnityTestRunnerGenerator.grab_config(arg)
true
