diff --git a/hb/resolver/indep_build_args_resolver.py b/hb/resolver/indep_build_args_resolver.py index e09b3aa4f79771d04ea547b3452b09dba04d4501..8318c08e230ea814bb01e0aea9ec7ff415cc391d 100644 --- a/hb/resolver/indep_build_args_resolver.py +++ b/hb/resolver/indep_build_args_resolver.py @@ -18,10 +18,11 @@ import os import sys - +import xml.etree.ElementTree as ET from containers.arg import Arg from containers.arg import ModuleType from resolver.interface.args_resolver_interface import ArgsResolverInterface +from resources.global_var import CURRENT_OHOS_ROOT from modules.interface.indep_build_module_interface import IndepBuildModuleInterface from util.component_util import ComponentUtil from exceptions.ohos_exception import OHOSException @@ -29,7 +30,7 @@ from exceptions.ohos_exception import OHOSException def get_part_name(): part_name_list = [] - if len(sys.argv) > 2 and not sys.argv[2].startswith("-"): + if len(sys.argv) > 2 and not sys.argv[2].startswith("-"): for name in sys.argv[2:]: if not name.startswith('-'): part_name_list.append(name) @@ -38,6 +39,17 @@ def get_part_name(): return part_name_list +def get_bundle_path(part_name): + tree = ET.parse(os.path.join(CURRENT_OHOS_ROOT, ".repo", "manifests", "ohos", "ohos.xml")) + root = tree.getroot() + for project in root.findall('project'): + path = project.get('path') + if part_name == path.split('/')[-1]: + return os.path.join(CURRENT_OHOS_ROOT, path) + else: + return ComponentUtil.search_bundle_file(part_name) + + class IndepBuildArgsResolver(ArgsResolverInterface): def __init__(self, args_dict: dict): @@ -73,17 +85,17 @@ class IndepBuildArgsResolver(ArgsResolverInterface): if target_arg.arg_value_list: bundle_path_list = [] + print("collecting bundle.json, please wait") for path in target_arg.arg_value_list: try: - print("collecting bundle.json, please wait") - bundle_path = ComponentUtil.search_bundle_file(path) - print("collect done") + bundle_path = get_bundle_path(path) bundle_path_list.append(bundle_path) except Exception as e: raise OHOSException('Please check the bundle.json file of {} : {}'.format(path, e)) if not bundle_path: print('ERROR argument "hb build ": Invalid part_name "{}". '.format(path)) sys.exit(1) + print("collect done") build_executor.regist_flag('path', ','.join(bundle_path_list)) elif ComponentUtil.is_in_component_dir(os.getcwd()): part_name, bundle_path = ComponentUtil.get_component(os.getcwd())