diff --git a/Tools/scripts/allowed_subsystems.py b/Tools/scripts/allowed_subsystems.py index 06f68790c5d..5032123592d 100755 --- a/Tools/scripts/allowed_subsystems.py +++ b/Tools/scripts/allowed_subsystems.py @@ -70,11 +70,6 @@ class AllowedSubsystems(object): 'Replay', 'AP_Periph', 'AP_Bootloader', - # class / sub-library prefixes in common use that are not their own - # libraries/ directory - 'AC_PosControl', - 'AC_Circle', - 'AP_MotorsHeli', 'mavlink', } @@ -102,6 +97,14 @@ class AllowedSubsystems(object): ('Tools/Replay/', ['Replay']), ] + # prefixes that are used but do not match the directory they are in + # list includes the directory name and alternative prefixes that may be used + SPECIAL_SUBSYSTEMS = { + 'AC_AttitudeControl': ['AC_PosControl'], + 'AC_WPNav': ['AC_Circle'], + 'AP_Motors': ['AP_MotorsHeli'], + } + # Top-level directory (other than vehicles, libraries and the special cases # above) -> ordered candidate subsystems. TOPLEVEL_DIR_SUBSYSTEMS = { @@ -171,8 +174,14 @@ class AllowedSubsystems(object): created_dirs is an iterable of libraries/ subdirectory names that a commit creates; they are allowed even if they do not yet exist on disk. ''' + special_subsystems = { + sub_prefix + for sub_prefixes in self.SPECIAL_SUBSYSTEMS.values() + for sub_prefix in sub_prefixes + } return (self.library_dirs() | set(self.CURATED_SUBSYSTEMS) + | special_subsystems | set(created_dirs)) def subsystems_for_path(self, path): @@ -203,6 +212,11 @@ class AllowedSubsystems(object): # libraries//hwdef/... belongs to hwdef as well as the HAL if len(parts) >= 4 and parts[2] == 'hwdef': return [lib, 'hwdef'] + # allow special prefixes from SPECIAL_SUBSYSTEMS + filename = parts[-1] + for sub_prefix in self.SPECIAL_SUBSYSTEMS.get(lib, []): + if filename.startswith(sub_prefix): + return [lib, sub_prefix] return [lib] # most-specific-first special directory rules