@@ -512,6 +512,13 @@ def is_ignored(self, file_path):
512
512
return True
513
513
return False
514
514
515
+ def add_ignore_patterns (self , root , base_path , patterns ):
516
+ real_base = relpath (root , base_path )
517
+ if real_base == "." :
518
+ self .ignore_patterns .extend (patterns )
519
+ else :
520
+ self .ignore_patterns .extend (join (real_base , pat ) for pat in patterns )
521
+
515
522
# Create a Resources object from the path pointed to by *path* by either traversing a
516
523
# a directory structure, when *path* is a directory, or adding *path* to the resources,
517
524
# when *path* is a file.
@@ -559,10 +566,11 @@ def _add_dir(self, path, resources, base_path, exclude_paths=None):
559
566
lines = [l for l in lines if l != "" ] # Strip empty lines
560
567
lines = [l for l in lines if not re .match ("^#" ,l )] # Strip comment lines
561
568
# Append root path to glob patterns and append patterns to ignore_patterns
562
- self .ignore_patterns . extend ([ join ( root ,line . strip ()) for line in lines ] )
569
+ self .add_ignore_patterns ( root , base_path , lines )
563
570
564
571
# Skip the whole folder if ignored, e.g. .mbedignore containing '*'
565
- if self .is_ignored (join (root ,"" )):
572
+ if self .is_ignored (join (relpath (root , base_path ),"" )):
573
+ dirs [:] = []
566
574
continue
567
575
568
576
for d in copy (dirs ):
@@ -577,7 +585,7 @@ def _add_dir(self, path, resources, base_path, exclude_paths=None):
577
585
# Ignore toolchain that do not match the current TOOLCHAIN
578
586
(d .startswith ('TOOLCHAIN_' ) and d [10 :] not in labels ['TOOLCHAIN' ]) or
579
587
# Ignore .mbedignore files
580
- self .is_ignored (join (dir_path ,"" )) or
588
+ self .is_ignored (join (relpath ( root , base_path ), d ,"" )) or
581
589
# Ignore TESTS dir
582
590
(d == 'TESTS' )):
583
591
dirs .remove (d )
@@ -606,7 +614,7 @@ def _add_dir(self, path, resources, base_path, exclude_paths=None):
606
614
def _add_file (self , file_path , resources , base_path , exclude_paths = None ):
607
615
resources .file_basepath [file_path ] = base_path
608
616
609
- if self .is_ignored (file_path ):
617
+ if self .is_ignored (relpath ( file_path , base_path ) ):
610
618
return
611
619
612
620
_ , ext = splitext (file_path )
0 commit comments