提交 245c7149 编写于 作者: O openharmony_ci 提交者: Gitee

!283 add compact_mode for hb build

Merge pull request !283 from yaoxiaoyu_903c/master
......@@ -52,6 +52,10 @@ def add_options(parser):
help='sign haps by server', action='store_true')
parser.add_argument('--patch', help='apply product patch before compiling',
action='store_true')
parser.add_argument('--compact-mode',
help='compactiable with standard build system'
'set to true if we use build.sh as build entrance',
action='store_true', default=False)
parser.add_argument('--gn-args', nargs=1, default='',
help='specifies gn build arguments, '
'eg: --gn-args="foo="bar" enable=true blah=7"')
......@@ -62,7 +66,7 @@ def exec_command(args):
product, company = args.product[0].split('@')
set_product(product_name=product, company=company)
build = Build(args.component)
build = Build(args.component, args.compact_mode)
cmd_args = defaultdict(list)
build.register_args('ohos_build_type', args.build_type[0])
......@@ -87,7 +91,8 @@ def exec_command(args):
if args.ndk:
build.register_args('ohos_build_ndk', 'true', quota=False)
if hasattr(args, 'target') and len(args.target):
if args.compact_mode is False and hasattr(args, 'target') and len(
args.target):
build.register_args('ohos_build_target', args.target)
if hasattr(args, 'verbose') and args.verbose:
......@@ -110,4 +115,11 @@ def exec_command(args):
except ValueError:
raise OHOSException(f'Invalid gn args: {gn_arg}')
# Add build target, order is important
if args.compact_mode:
if hasattr(args, 'target') and len(args.target):
cmd_args['ninja'].extend(args.target)
else:
cmd_args['ninja'].append('packages')
return build.build(args.full, patch=args.patch, cmd_args=cmd_args)
......@@ -37,7 +37,7 @@ from distutils.spawn import find_executable
class Build():
def __init__(self, component=None):
def __init__(self, component=None, compact_mode=False):
self.config = Config()
# Get gn args ready
......@@ -45,6 +45,7 @@ class Build():
self._target = None
self._compiler = None
self._test = None
self._compact_mode = compact_mode
self.target = component
self.start_time = get_current_time()
......@@ -181,10 +182,13 @@ class Build():
gn_cmd = [gn_path,
'gen',
self.config.out_path,
'--root={}'.format(self.config.root_path),
'--dotfile={}/.gn'.format(self.config.build_path),
f'--script-executable={sys.executable}',
'--args={}'.format(" ".join(self._args_list))] + gn_args
if self._compact_mode is False:
gn_cmd += [
'--root={}'.format(self.config.root_path),
'--dotfile={}/.gn'.format(self.config.build_path),
]
exec_command(gn_cmd, log_path=self.config.log_path)
def gn_clean(self, out_path=None):
......@@ -204,10 +208,13 @@ class Build():
return
gn_cmd = [gn_path,
'--root={}'.format(self.config.root_path),
'--dotfile={}/.gn'.format(self.config.build_path),
'clean',
self.config.out_path]
if self._compact_mode is False:
gn_cmd += [
'--root={}'.format(self.config.root_path),
'--dotfile={}/.gn'.format(self.config.build_path),
]
exec_command(gn_cmd, log_path=self.config.log_path)
def ninja_build(self, cmd_args):
......@@ -246,6 +253,8 @@ class Build():
# Compile product in "hb set"
self.compiler = Device.get_compiler(self.config.device_path)
self.register_args('product_path', self.config.product_path)
if self._compact_mode:
self.register_args('product_name', self.config.product)
self.register_args('device_path', self.config.device_path)
self.register_args('ohos_kernel_type', self.config.kernel)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册