@@ -297,25 +297,36 @@ class Savi::Compiler::SourceService
297
297
def get_sources_for_manifest (ctx, manifest : Packaging ::Manifest )
298
298
package = Source ::Package .for_manifest(manifest)
299
299
300
- manifest.sources_paths.flat_map { |sources_path , exclusions |
301
- sources = [] of Source
300
+ sources = [] of Source
301
+
302
+ manifest.sources_paths.each { |sources_path , exclusions |
303
+ glob_sources = [] of Source
302
304
absolute_glob = File .join(package.path, sources_path.value)
303
305
exclusion_paths = exclusions.map { |e | File .join(package.path, e.value) }
304
306
305
307
prior_source_size = sources.size
308
+ found_at_least_one = false
306
309
each_savi_file_in_glob(absolute_glob) { |name , content |
307
310
# Skip this source file if it is excluded.
308
311
next if exclusion_paths.any? { |e | File .match?(e, name) }
309
312
310
- # Otherwise add it to the list.
313
+ # Note that we found at least one source file in this glob.
314
+ found_at_least_one = true
315
+
316
+ # Split the file path into its two parts.
311
317
dirname = File .dirname(name)
312
- basename = File .basename(name)
313
- sources << Source .new(dirname, basename, content, package)
318
+ filename = File .basename(name)
319
+
320
+ # Skip this source file if it already is included.
321
+ next if sources.any? { |s | s.filename == filename && s.dirname == dirname }
322
+
323
+ # Otherwise add it to the list.
324
+ glob_sources << Source .new(dirname, filename, content, package)
314
325
}
315
326
316
327
ctx.error_at sources_path,
317
- " No '.savi' source files found in #{ absolute_glob.inspect } " \
318
- if sources.empty?
328
+ " No new '.savi' source files found in #{ absolute_glob.inspect } " \
329
+ unless found_at_least_one
319
330
320
331
# Sort the sources by case-insensitive name, so that they always get loaded
321
332
# in a repeatable order regardless of platform implementation details, or
@@ -324,10 +335,14 @@ class Savi::Compiler::SourceService
324
335
# Note that we sort each group (from each glob) separately,
325
336
# and concatenate them in order of the globs declaration order, so that
326
337
# the declaration order can be meaningful if desired.
327
- sources .sort_by!(& .filename.downcase)
338
+ glob_sources .sort_by!(& .filename.downcase)
328
339
329
- sources
340
+ # Finally, add the glob sources to the total sources list.
341
+ sources.concat(glob_sources)
330
342
}
343
+
344
+
345
+ sources
331
346
end
332
347
333
348
# Given a directory name, load source objects for all the source files in
0 commit comments