Skip to content

Commit

Permalink
Merge PR #545
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandervoord committed Feb 6, 2023
1 parent 5e4c587 commit 36259d4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions auto/generate_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
require 'pathname'

# TEMPLATE_TST
TEMPLATE_TST ||= '#ifdef TEST
TEMPLATE_TST ||= '#ifdef %5$s
#include "unity.h"
Expand All @@ -32,7 +32,7 @@
TEST_IGNORE_MESSAGE("Need to Implement %1$s");
}
#endif // TEST
#endif // %5$s
'.freeze

# TEMPLATE_SRC
Expand Down Expand Up @@ -108,7 +108,8 @@ def self.default_options
update_svn: false,
boilerplates: {},
test_prefix: 'Test',
mock_prefix: 'Mock'
mock_prefix: 'Mock',
test_define: 'TEST'
}
end

Expand All @@ -134,7 +135,7 @@ def files_to_operate_on(module_name, pattern = nil)
prefix = @options[:test_prefix] || 'Test'
triad = [{ ext: '.c', path: @options[:path_src], prefix: '', template: TEMPLATE_SRC, inc: :src, boilerplate: @options[:boilerplates][:src] },
{ ext: '.h', path: @options[:path_inc], prefix: '', template: TEMPLATE_INC, inc: :inc, boilerplate: @options[:boilerplates][:inc] },
{ ext: '.c', path: @options[:path_tst], prefix: prefix, template: TEMPLATE_TST, inc: :tst, boilerplate: @options[:boilerplates][:tst] }]
{ ext: '.c', path: @options[:path_tst], prefix: prefix, template: TEMPLATE_TST, inc: :tst, boilerplate: @options[:boilerplates][:tst], test_define: @options[:test_define] }]

# prepare the pattern for use
pattern = (pattern || @options[:pattern] || 'src').downcase
Expand All @@ -154,6 +155,7 @@ def files_to_operate_on(module_name, pattern = nil)
path: (Pathname.new("#{cfg[:path]}#{subfolder}") + filename).cleanpath,
name: submodule_name,
template: cfg[:template],
test_define: cfg[:test_define]
boilerplate: cfg[:boilerplate],
includes: case (cfg[:inc])
when :src then (@options[:includes][:src] || []) | (pattern_traits[:inc].map { |f| format(f, module_name) })
Expand Down Expand Up @@ -212,7 +214,8 @@ def generate(module_name, pattern = nil)
f.write(file[:template] % [file[:name],
file[:includes].map { |ff| "#include \"#{ff}\"\n" }.join,
file[:name].upcase.tr('-', '_'),
file[:name].tr('-', '_')])
file[:name].tr('-', '_'),
file[:test_define]])
end
if @options[:update_svn]
`svn add \"#{file[:path]}\"`
Expand Down

0 comments on commit 36259d4

Please sign in to comment.