diff --git a/examples/gcc.yml b/examples/gcc.yml index 13b4391..d3f08db 100644 --- a/examples/gcc.yml +++ b/examples/gcc.yml @@ -11,7 +11,7 @@ compiler: - 'src/' - '../src/' - '../vendor/unity/src/' - - '../vendor/unity/examples/helper/' + - '../vendor/unity/examples/example_3/helper/' - 'mocks/' - *unit_tests_path defines: @@ -40,4 +40,4 @@ linker: :includes: - Types.h -colour: true \ No newline at end of file +colour: true diff --git a/examples/iar_v4.yml b/examples/iar_v4.yml index 78a7c7b..a61a38a 100644 --- a/examples/iar_v4.yml +++ b/examples/iar_v4.yml @@ -14,7 +14,7 @@ compiler: - --no_code_motion - --no_tbaa - --no_clustering - - --no_scheduling + - --no_scheduling - --debug - --cpu_mode thumb - --endian little @@ -32,7 +32,7 @@ compiler: - 'src/' - '../src/' - '../vendor/unity/src/' - - '../vendor/unity/examples/helper/' + - '../vendor/unity/examples/example_3/helper/' - 'mocks/' - [*tools_root, 'arm\inc\'] - *unit_tests_path @@ -88,4 +88,4 @@ simulator: :plugins: [] :includes: - Types.h - \ No newline at end of file + diff --git a/examples/iar_v5.yml b/examples/iar_v5.yml index 663251f..fb3bd16 100644 --- a/examples/iar_v5.yml +++ b/examples/iar_v5.yml @@ -13,7 +13,7 @@ compiler: - --no_code_motion - --no_tbaa - --no_clustering - - --no_scheduling + - --no_scheduling - --debug - --cpu_mode thumb - --endian=little @@ -31,7 +31,7 @@ compiler: - 'src/' - '../src/' - '../vendor/unity/src/' - - '../vendor/unity/examples/helper/' + - '../vendor/unity/examples/example_3/helper/' - 'mocks/' - [*tools_root, 'arm\inc\'] - *unit_tests_path @@ -77,4 +77,4 @@ simulator: :plugins: [] :includes: - Types.h - \ No newline at end of file + diff --git a/examples/rakefile_helper.rb b/examples/rakefile_helper.rb index 3c52353..dfee555 100644 --- a/examples/rakefile_helper.rb +++ b/examples/rakefile_helper.rb @@ -7,29 +7,29 @@ require '../vendor/unity/auto/colour_reporter' module RakefileHelpers C_EXTENSION = '.c' - + def load_configuration(config_file) $cfg_file = config_file $cfg = YAML.load(File.read($cfg_file)) $colour_output = false unless $cfg['colour'] end - + def configure_clean CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil? end - + def configure_toolchain(config_file=DEFAULT_CONFIG_FILE) config_file += '.yml' unless config_file =~ /\.yml$/ load_configuration(config_file) configure_clean end - + def get_unit_test_files path = $cfg['compiler']['unit_tests_path'] + 'Test*' + C_EXTENSION path.gsub!(/\\/, '/') FileList.new(path) end - + def get_local_include_dirs include_dirs = $cfg['compiler']['includes']['items'].dup include_dirs.delete_if {|dir| dir.is_a?(Array)} @@ -57,7 +57,7 @@ module RakefileHelpers end return nil end - + def tackit(strings) case(strings) when Array @@ -70,7 +70,7 @@ module RakefileHelpers strings end end - + def squash(prefix, items) result = '' items.each { |item| result += " #{prefix}#{tackit(item)}" } @@ -98,7 +98,7 @@ module RakefileHelpers execute(cmd_str + obj_file) return obj_file end - + def build_linker_fields command = tackit($cfg['linker']['path']) if $cfg['linker']['options'].nil? @@ -114,17 +114,17 @@ module RakefileHelpers includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) return {:command => command, :options => options, :includes => includes} end - + def link_it(exe_name, obj_list) linker = build_linker_fields - cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " + + cmd_str = "#{linker[:command]}#{linker[:includes]} " + (obj_list.map{|obj|"#{$cfg['linker']['object_files']['path']}#{obj} "}).join + $cfg['linker']['bin_files']['prefix'] + ' ' + $cfg['linker']['bin_files']['destination'] + - exe_name + $cfg['linker']['bin_files']['extension'] + exe_name + $cfg['linker']['bin_files']['extension'] + " #{linker[:options]}" execute(cmd_str) end - + def build_simulator_fields return nil if $cfg['simulator'].nil? if $cfg['simulator']['path'].nil? @@ -144,7 +144,7 @@ module RakefileHelpers end return {:command => command, :pre_support => pre_support, :post_support => post_support} end - + def execute(command_string, verbose=true) report command_string output = `#{command_string}`.chomp @@ -154,7 +154,7 @@ module RakefileHelpers end return output end - + def report_summary summary = UnityTestSummary.new summary.set_root_path(HERE) @@ -165,34 +165,34 @@ module RakefileHelpers report summary.run raise "There were failures" if (summary.failures > 0) end - + def run_tests(test_files) - + report 'Running system tests...' - + # Tack on TEST define for compiling unit tests load_configuration($cfg_file) test_defines = ['TEST'] $cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil? $cfg['compiler']['defines']['items'] << 'TEST' - + include_dirs = get_local_include_dirs - + # Build and execute each unit test test_files.each do |test| obj_list = [] - + # Detect dependencies and build required required modules header_list = extract_headers(test) + ['cmock.h'] header_list.each do |header| - + #create mocks if needed - if (header =~ /Mock/) - require "../lib/cmock.rb" - @cmock ||= CMock.new($cfg_file) + if (header =~ /Mock/) + require "../lib/cmock.rb" + @cmock ||= CMock.new($cfg_file) @cmock.setup_mocks([$cfg['compiler']['source_path']+header.gsub('Mock','')]) end - + end #compile all mocks @@ -203,7 +203,7 @@ module RakefileHelpers obj_list << compile(src_file, test_defines) end end - + # Build the test runner (generate if configured to do so) test_base = File.basename(test, C_EXTENSION) runner_name = test_base + '_Runner.c' @@ -216,13 +216,13 @@ module RakefileHelpers end obj_list << compile(runner_path, test_defines) - + # Build the test module obj_list << compile(test, test_defines) - + # Link the test executable link_it(test_base, obj_list) - + # Execute unit test and generate results file simulator = build_simulator_fields executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension'] @@ -241,11 +241,11 @@ module RakefileHelpers File.open(test_results, 'w') { |f| f.print output } end end - + def build_application(main) - + report "Building application..." - + obj_list = [] load_configuration($cfg_file) main_path = $cfg['compiler']['source_path'] + main + C_EXTENSION @@ -258,13 +258,13 @@ module RakefileHelpers obj_list << compile(src_file) end end - + # Build the main source file main_base = File.basename(main_path, C_EXTENSION) obj_list << compile(main_path) - + # Create the executable link_it(main_base, obj_list) end - + end