diff --git a/lib/ceedling/configurator_builder.rb b/lib/ceedling/configurator_builder.rb index 6d3a5758..d23d698d 100644 --- a/lib/ceedling/configurator_builder.rb +++ b/lib/ceedling/configurator_builder.rb @@ -311,9 +311,10 @@ def collect_tests(in_hash) all_tests.include( File.join(path, "#{in_hash[:project_test_file_prefix]}*#{in_hash[:extension_source]}") ) end - @file_path_collection_utils.revise_filelist( all_tests, in_hash[:files_test] ) - - return {:collection_all_tests => all_tests} + return { + # Add / subtract files via :files ↳ :test + :collection_all_tests => @file_path_collection_utils.revise_filelist( all_tests, in_hash[:files_test] ) + } end @@ -332,10 +333,11 @@ def collect_assembly(in_hash) all_assembly.include( File.join(path, "*#{in_hash[:extension_assembly]}") ) end - # Also add files that we are explicitly adding via :files:assembly: section - @file_path_collection_utils.revise_filelist( all_assembly, in_hash[:files_assembly] ) + return { + # Add / subtract files via :files ↳ :assembly + :collection_all_assembly => @file_path_collection_utils.revise_filelist( all_assembly, in_hash[:files_assembly] ) + } - return {:collection_all_assembly => all_assembly} end @@ -346,9 +348,10 @@ def collect_source(in_hash) all_source.include( File.join(path, "*#{in_hash[:extension_source]}") ) end - @file_path_collection_utils.revise_filelist( all_source, in_hash[:files_source] ) - - return {:collection_all_source => all_source} + return { + # Add / subtract files via :files ↳ :source + :collection_all_source => @file_path_collection_utils.revise_filelist( all_source, in_hash[:files_source] ) + } end @@ -364,9 +367,10 @@ def collect_headers(in_hash) all_headers.include( File.join(path, "*#{in_hash[:extension_header]}") ) end - @file_path_collection_utils.revise_filelist( all_headers, in_hash[:files_include] ) - - return {:collection_all_headers => all_headers} + return { + # Add / subtract files via :files ↳ :include + :collection_all_headers => @file_path_collection_utils.revise_filelist( all_headers, in_hash[:files_include] ) + } end @@ -387,10 +391,13 @@ def collect_release_build_input(in_hash) release_input.include( File.join(path, "*#{in_hash[:extension_assembly]}") ) if in_hash[:release_build_use_assembly] end - @file_path_collection_utils.revise_filelist( release_input, in_hash[:files_source] ) - @file_path_collection_utils.revise_filelist( release_input, in_hash[:files_assembly] ) if in_hash[:release_build_use_assembly] + # Add / subtract files via :files ↳ :source & :files ↳ :assembly + revisions = in_hash[:files_source] + revisions += in_hash[:files_assembly] if in_hash[:release_build_use_assembly] - return {:collection_release_build_input => release_input} + return { + :collection_release_build_input => @file_path_collection_utils.revise_filelist( release_input, revisions ) + } end @@ -420,12 +427,15 @@ def collect_existing_test_build_input(in_hash) all_input.include( File.join(path, "*#{in_hash[:extension_assembly]}") ) if in_hash[:test_build_use_assembly] end - @file_path_collection_utils.revise_filelist( all_input, in_hash[:files_test] ) - @file_path_collection_utils.revise_filelist( all_input, in_hash[:files_support] ) - @file_path_collection_utils.revise_filelist( all_input, in_hash[:files_source] ) - @file_path_collection_utils.revise_filelist( all_input, in_hash[:files_assembly] ) if in_hash[:test_build_use_assembly] + # Add / subtract files via :files entries + revisions = in_hash[:files_test] + revisions += in_hash[:files_support] + revisions += in_hash[:files_source] + revisions += in_hash[:files_assembly] if in_hash[:test_build_use_assembly] - return {:collection_existing_test_build_input => all_input} + return { + :collection_existing_test_build_input => @file_path_collection_utils.revise_filelist( all_input, revisions ) + } end @@ -451,10 +461,7 @@ def collect_test_fixture_extra_link_objects(in_hash) support.include( File.join(path, "*#{in_hash[:extension_assembly]}") ) if in_hash[:test_build_use_assembly] end - @file_path_collection_utils.revise_filelist( support, in_hash[:files_support] ) - - # Ensure FileList patterns & revisions are resolved into full list of filepaths - support.resolve() + support = @file_path_collection_utils.revise_filelist( support, in_hash[:files_support] ) support.each { |file| sources << file } @@ -464,9 +471,10 @@ def collect_test_fixture_extra_link_objects(in_hash) # No build paths here so plugins can remap if necessary (i.e. path mapping happens at runtime) objects.map! { |object| object.ext(in_hash[:extension_object]) } - return { :collection_all_support => sources, - :collection_test_fixture_extra_link_objects => objects - } + return { + :collection_all_support => sources, + :collection_test_fixture_extra_link_objects => objects + } end @@ -476,10 +484,7 @@ def collect_vendor_framework_sources(in_hash) filelist = @file_wrapper.instantiate_file_list() # Vendor paths for frameworks - paths = [] - paths << in_hash[:project_build_vendor_unity_path] - paths << in_hash[:project_build_vendor_cexception_path] if (in_hash[:project_use_exceptions]) - paths << in_hash[:project_build_vendor_cmock_path] if (in_hash[:project_use_mocks]) + paths = get_vendor_paths(in_hash) # Collect vendor framework code files paths.each do |path| @@ -489,6 +494,8 @@ def collect_vendor_framework_sources(in_hash) # Ensure FileList patterns & revisions are resolved into full list of filepaths filelist.resolve() + puts(filelist) + # Extract just source file names filelist.each do |filepath| sources << File.basename(filepath) diff --git a/lib/ceedling/configurator_setup.rb b/lib/ceedling/configurator_setup.rb index a7b15524..2ec29328 100644 --- a/lib/ceedling/configurator_setup.rb +++ b/lib/ceedling/configurator_setup.rb @@ -72,6 +72,7 @@ def validate_required_sections(config) return true end + def validate_required_section_values(config) validation = [] validation << @configurator_validator.exists?(config, :project, :build_root) @@ -82,6 +83,7 @@ def validate_required_section_values(config) return true end + def validate_paths(config) valid = true diff --git a/lib/ceedling/constants.rb b/lib/ceedling/constants.rb index c8977f12..cec326bb 100644 --- a/lib/ceedling/constants.rb +++ b/lib/ceedling/constants.rb @@ -23,7 +23,6 @@ class TestResultsSanityChecks THOROUGH = 2 # perform checks that require inside knowledge of system workings end - class StdErrRedirect NONE = :none AUTO = :auto @@ -32,7 +31,6 @@ class StdErrRedirect TCSH = :tcsh end - unless defined?(PROJECT_ROOT) PROJECT_ROOT = Dir.pwd() end diff --git a/lib/ceedling/file_path_collection_utils.rb b/lib/ceedling/file_path_collection_utils.rb index 7ca8c8f7..7d3e5a9c 100644 --- a/lib/ceedling/file_path_collection_utils.rb +++ b/lib/ceedling/file_path_collection_utils.rb @@ -1,7 +1,6 @@ require 'set' require 'pathname' require 'fileutils' -require 'rake' require 'ceedling/file_path_utils' require 'ceedling/exceptions' @@ -81,18 +80,49 @@ def collect_paths(paths) end - # Given a file list, add to it or remove from it considering (+:/-:) aggregation operators + # Given a file list, add to it or remove from it considering (+:/-:) aggregation operators. + # Rake's FileList does not robustly handle relative filepaths and patterns. + # So, we rebuild the FileList ourselves and return it. + # TODO: Replace FileList with our own, better version. def revise_filelist(list, revisions) + plus = Set.new # All real, expanded directory paths to add + minus = Set.new # All real, expanded paths to exclude + + # Build base plus set for revised path + list.each do |path| + # Start with expanding all list entries to absolute paths + plus << File.expand_path( path ) + end + revisions.each do |revision| - # Include or exclude revision in file list + # Include or exclude revisions in file list path = FilePathUtils.no_aggregation_decorators( revision ) + # Working list of revisions + filepaths = [] + + # Expand path by pattern as needed and add only filepaths to working list + @file_wrapper.directory_listing( path ).each do |entry| + filepaths << File.expand_path( entry ) if !@file_wrapper.directory?( entry ) + end + + # Handle +: / -: revisions if FilePathUtils.add_path?( revision ) - list.include(path) + plus.merge( filepaths ) else - list.exclude(path) + minus.merge( filepaths ) end end + + # Use Set subtraction operator to remove any excluded paths + paths = (plus - minus).to_a + + paths.map! do |path| + # Reform path from full absolute to nice, neat relative path instead + (Pathname.new( path ).relative_path_from( @working_dir_path )).to_s() + end + + return FileList.new( paths ) end end