diff --git a/examples/rakefile_helper.rb b/examples/rakefile_helper.rb index 3ca9123..3c52353 100644 --- a/examples/rakefile_helper.rb +++ b/examples/rakefile_helper.rb @@ -92,10 +92,11 @@ module RakefileHelpers def compile(file, defines=[]) compiler = build_compiler_fields - cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " + - "#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" + - "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}" - execute(cmd_str) + cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " + + "#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" + obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}" + execute(cmd_str + obj_file) + return obj_file end def build_linker_fields @@ -199,8 +200,7 @@ module RakefileHelpers #compile source file header if it exists src_file = find_source_file(header, include_dirs) if !src_file.nil? - compile(src_file, test_defines) - obj_list << header.ext($cfg['compiler']['object_files']['extension']) + obj_list << compile(src_file, test_defines) end end @@ -215,12 +215,10 @@ module RakefileHelpers runner_path = $cfg['compiler']['runner_path'] + runner_name end - compile(runner_path, test_defines) - obj_list << runner_name.ext($cfg['compiler']['object_files']['extension']) + obj_list << compile(runner_path, test_defines) # Build the test module - compile(test, test_defines) - obj_list << test_base.ext($cfg['compiler']['object_files']['extension']) + obj_list << compile(test, test_defines) # Link the test executable link_it(test_base, obj_list) @@ -257,15 +255,13 @@ module RakefileHelpers extract_headers(main_path).each do |header| src_file = find_source_file(header, include_dirs) if !src_file.nil? - compile(src_file) - obj_list << header.ext($cfg['compiler']['object_files']['extension']) + obj_list << compile(src_file) end end # Build the main source file main_base = File.basename(main_path, C_EXTENSION) - compile(main_path) - obj_list << main_base.ext($cfg['compiler']['object_files']['extension']) + obj_list << compile(main_path) # Create the executable link_it(main_base, obj_list) diff --git a/rakefile_helper.rb b/rakefile_helper.rb index 5cd6923..3714d60 100644 --- a/rakefile_helper.rb +++ b/rakefile_helper.rb @@ -85,9 +85,10 @@ module RakefileHelpers def compile(file, defines=[]) compiler = build_compiler_fields cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{defines.inject(''){|all, a| ' -D'+a+all }}#{compiler[:options]}#{compiler[:includes]} #{file} " + - "#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" + - "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}" - execute(cmd_str) + "#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" + obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}" + execute(cmd_str + obj_file) + return obj_file end def build_linker_fields @@ -203,8 +204,7 @@ module RakefileHelpers # Compile corresponding source file if it exists src_file = find_source_file(header, include_dirs) if !src_file.nil? - compile(src_file) - obj_list << header.ext($cfg['compiler']['object_files']['extension']) + obj_list << compile(src_file) end end @@ -212,12 +212,10 @@ module RakefileHelpers runner_name = test_base + '_runner.c' runner_path = $cfg['compiler']['source_path'] + runner_name UnityTestRunnerGenerator.new(SYSTEST_GENERATED_FILES_PATH + cmock_config).run(test, runner_path) - compile(runner_path) - obj_list << runner_name.ext($cfg['compiler']['object_files']['extension']) + obj_list << compile(runner_path) # Build the test module - compile(test) - obj_list << test_base.ext($cfg['compiler']['object_files']['extension']) + obj_list << compile(test) # Link the test executable link_it(test_base, obj_list)