Skip to content

Commit

Permalink
Added option for parallel cloning of submodules (#31196)
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamdp authored and pull[bot] committed Feb 13, 2024
1 parent ec5dfb3 commit 5b6ae78
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/checkout_submodules.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,15 @@ def make_chip_root_safe_directory() -> None:
subprocess.check_call(['git', 'config', '--global', '--add', 'safe.directory', CHIP_ROOT])


def checkout_modules(modules: list, shallow: bool, force: bool, recursive: bool) -> None:
def checkout_modules(modules: list, shallow: bool, force: bool, recursive: bool, jobs: int) -> None:
names = ', '.join([module.name for module in modules])
logging.info(f'Checking out: {names}')

cmd = ['git', '-C', CHIP_ROOT, 'submodule', '--quiet', 'update', '--init']
cmd += ['--depth', '1'] if shallow else []
cmd += ['--force'] if force else []
cmd += ['--recursive'] if recursive else []
cmd += ['--jobs', f'{jobs}'] if jobs else []
cmd += [module.path for module in modules]

subprocess.check_call(cmd)
Expand Down Expand Up @@ -128,6 +129,7 @@ def main():
parser.add_argument('--deinit-unmatched', action='store_true',
help='Deinitialize submodules for non-matching platforms')
parser.add_argument('--recursive', action='store_true', help='Recursive init of the listed submodules')
parser.add_argument('--jobs', type=int, metavar='N', help='Clone new submodules in parallel with N jobs')
args = parser.parse_args()

modules = list(load_module_info())
Expand All @@ -138,7 +140,7 @@ def main():

if args.allow_changing_global_git_config:
make_chip_root_safe_directory() # ignore directory ownership issues for sub-modules
checkout_modules(selected_modules, args.shallow, args.force, args.recursive)
checkout_modules(selected_modules, args.shallow, args.force, args.recursive, args.jobs)

if args.deinit_unmatched and unmatched_modules:
deinit_modules(unmatched_modules, args.force)
Expand Down

0 comments on commit 5b6ae78

Please sign in to comment.