Skip to content

Commit

Permalink
Merge pull request #133 from espressif/feat/support_ignore_app_depend…
Browse files Browse the repository at this point in the history
…ency_components
  • Loading branch information
hfudev authored Mar 20, 2024
2 parents a964216 + 446546b commit c5a1048
Showing 1 changed file with 48 additions and 9 deletions.
57 changes: 48 additions & 9 deletions idf_build_apps/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,34 @@ def _check_app_dependency(
manifest_rootpath: t.Optional[str] = None,
modified_components: t.Optional[t.List[str]] = None,
modified_files: t.Optional[t.List[str]] = None,
ignore_app_dependencies_components: t.Optional[t.List[str]] = None,
ignore_app_dependencies_filepatterns: t.Optional[t.List[str]] = None,
) -> bool:
# not check since modified_components and modified_files are not passed
if modified_components is None and modified_files is None:
return False

# not check since ignore_app_dependencies_components is passed and matched
if (
ignore_app_dependencies_components
and modified_components is not None
and set(modified_components).intersection(ignore_app_dependencies_components)
):
LOGGER.info(
'Build all apps since modified components %s matches ignored components %s',
', '.join(modified_components),
', '.join(ignore_app_dependencies_components),
)
return False

# not check since ignore_app_dependencies_filepatterns is passed and matched
if (
ignore_app_dependencies_filepatterns
and modified_files is not None
and files_matches_patterns(modified_files, ignore_app_dependencies_filepatterns, manifest_rootpath)
):
LOGGER.info(
'Build all apps since patterns %s matches modified files %s',
'Build all apps since modified files %s matches ignored file patterns %s',
', '.join(modified_files),
', '.join(ignore_app_dependencies_filepatterns),
)
Expand Down Expand Up @@ -108,6 +122,7 @@ def find_apps(
default_build_targets: t.Optional[t.Union[t.List[str], str]] = None,
modified_components: t.Optional[t.Union[t.List[str], str]] = None,
modified_files: t.Optional[t.Union[t.List[str], str]] = None,
ignore_app_dependencies_components: t.Optional[t.Union[t.List[str], str]] = None,
ignore_app_dependencies_filepatterns: t.Optional[t.Union[t.List[str], str]] = None,
sdkconfig_defaults: t.Optional[str] = None,
include_skipped_apps: bool = False,
Expand Down Expand Up @@ -137,8 +152,8 @@ def find_apps(
:param default_build_targets: default build targets used in manifest files
:param modified_components: modified components
:param modified_files: modified files
:param ignore_app_dependencies_filepatterns: file patterns that used for ignoring checking the component
dependencies
:param ignore_app_dependencies_components: components used for ignoring checking the app dependencies
:param ignore_app_dependencies_filepatterns: file patterns used for ignoring checking the app dependencies
:param sdkconfig_defaults: semicolon-separated string, pass to idf.py -DSDKCONFIG_DEFAULTS if specified,
also could be set via environment variables "SDKCONFIG_DEFAULTS"
:param include_skipped_apps: include skipped apps or not
Expand Down Expand Up @@ -168,6 +183,7 @@ def find_apps(

modified_components = to_list(modified_components)
modified_files = to_list(modified_files)
ignore_app_dependencies_components = to_list(ignore_app_dependencies_components)
ignore_app_dependencies_filepatterns = to_list(ignore_app_dependencies_filepatterns)
config_rules_str = to_list(config_rules_str)

Expand Down Expand Up @@ -199,6 +215,7 @@ def find_apps(
manifest_rootpath=manifest_rootpath,
modified_components=modified_components,
modified_files=modified_files,
ignore_app_dependencies_components=ignore_app_dependencies_components,
ignore_app_dependencies_filepatterns=ignore_app_dependencies_filepatterns,
),
modified_components=modified_components,
Expand All @@ -225,6 +242,7 @@ def build_apps(
manifest_rootpath: t.Optional[str] = None,
modified_components: t.Optional[t.Union[t.List[str], str]] = None,
modified_files: t.Optional[t.Union[t.List[str], str]] = None,
ignore_app_dependencies_components: t.Optional[t.Union[t.List[str], str]] = None,
ignore_app_dependencies_filepatterns: t.Optional[t.Union[t.List[str], str]] = None,
check_app_dependencies: t.Optional[bool] = None,
# BuildAppsArgs
Expand All @@ -249,8 +267,8 @@ def build_apps(
are relative paths. Use the current directory if not specified
:param modified_components: modified components
:param modified_files: modified files
:param ignore_app_dependencies_filepatterns: file patterns that used for ignoring checking the component
dependencies
:param ignore_app_dependencies_components: components used for ignoring checking the app dependencies
:param ignore_app_dependencies_filepatterns: file patterns used for ignoring checking the app dependencies
:param check_app_dependencies: check app dependencies or not. if not set, will be calculated by modified_components,
modified_files, and ignore_app_dependencies_filepatterns
:param parallel_count: number of parallel tasks to run
Expand All @@ -263,6 +281,7 @@ def build_apps(
apps = to_list(apps)
modified_components = to_list(modified_components)
modified_files = to_list(modified_files)
ignore_app_dependencies_components = to_list(ignore_app_dependencies_components)
ignore_app_dependencies_filepatterns = to_list(ignore_app_dependencies_filepatterns)

test_suite = TestSuite('build_apps')
Expand Down Expand Up @@ -313,7 +332,11 @@ def build_apps(
modified_components=modified_components,
modified_files=modified_files,
check_app_dependencies=_check_app_dependency(
manifest_rootpath, modified_components, modified_files, ignore_app_dependencies_filepatterns
manifest_rootpath=manifest_rootpath,
modified_components=modified_components,
modified_files=modified_files,
ignore_app_dependencies_components=ignore_app_dependencies_components,
ignore_app_dependencies_filepatterns=ignore_app_dependencies_filepatterns,
)
if check_app_dependencies is None
else check_app_dependencies,
Expand Down Expand Up @@ -563,6 +586,18 @@ def get_parser() -> argparse.ArgumentParser:
'If set to "", the value would be considered as None. '
'If set to ";", the value would be considered as an empty list',
)
common_args.add_argument(
'-ic',
'--ignore-app-dependencies-components',
type=semicolon_separated_str_to_list,
help='semicolon-separated string which specifies the modified components used for '
'ignoring checking the app dependencies. '
'The `depends_components` and `depends_filepatterns` set in the manifest files will be ignored when any of the '
'specified components matches any of the modified components. '
'Must be used together with --modified-components. '
'If set to "", the value would be considered as None. '
'If set to ";", the value would be considered as an empty list',
)
common_args.add_argument(
'-if',
'--ignore-app-dependencies-filepatterns',
Expand Down Expand Up @@ -683,11 +718,13 @@ def validate_args(parser: argparse.ArgumentParser, args: argparse.Namespace) ->
default_build_targets.append(target)
args.default_build_targets = default_build_targets

if args.ignore_app_dependencies_components is not None:
if args.modified_components is None:
raise InvalidCommand('Must specify "--ignore-app-dependencies-components" with "--modified-components", ')

if args.ignore_app_dependencies_filepatterns is not None:
if args.modified_files is None:
raise InvalidCommand(
'Must specify "--ignore-component-dependencies-file-patterns" with "--modified-files", '
)
raise InvalidCommand('Must specify "--ignore-app-dependencies-filepatterns" with "--modified-files", ')


def apply_config_args(args: argparse.Namespace) -> None:
Expand Down Expand Up @@ -731,6 +768,7 @@ def main():
default_build_targets=args.default_build_targets,
modified_components=args.modified_components,
modified_files=args.modified_files,
ignore_app_dependencies_components=args.ignore_app_dependencies_components,
ignore_app_dependencies_filepatterns=args.ignore_app_dependencies_filepatterns,
sdkconfig_defaults=args.sdkconfig_defaults,
)
Expand Down Expand Up @@ -766,6 +804,7 @@ def main():
manifest_rootpath=args.manifest_rootpath,
modified_components=args.modified_components,
modified_files=args.modified_files,
ignore_app_dependencies_components=args.ignore_app_dependencies_components,
ignore_app_dependencies_filepatterns=args.ignore_app_dependencies_filepatterns,
junitxml=args.junitxml,
)
Expand Down

0 comments on commit c5a1048

Please sign in to comment.