提交 8a00d4bc 编写于 作者: P pilipala195 提交者: Gitee

hb build supports --gn-args parameters

上级 51ecd13a
......@@ -21,6 +21,7 @@ from collections import defaultdict
from hb.build.build_process import Build
from hb.set.set import set_product
from hb.common.utils import get_current_time
from hb.common.utils import OHOSException
def add_options(parser):
......@@ -51,6 +52,9 @@ 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('--gn-args', nargs=1, default='',
help='specifies gn build arguments, '
'eg: --gn-args="foo="bar" enable=true blah=7"')
def exec_command(args):
......@@ -98,4 +102,12 @@ def exec_command(args):
'true',
quota=False)
if len(args.gn_args):
for gn_arg in args.gn_args[0].split(' '):
try:
variable, value = gn_arg.split('=')
build.register_args(variable, value)
except ValueError:
raise OHOSException(f'Invalid gn args: {gn_arg}')
return build.build(args.full, patch=args.patch, cmd_args=cmd_args)
......@@ -103,6 +103,7 @@ class Build():
raise OHOSException('Error: wrong input of test')
def register_args(self, args_name, args_value, quota=True):
quota = False if args_value in ['true', 'false'] else quota
if quota:
if isinstance(args_value, list):
self._args_list += ['{}="{}"'.format(args_name,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册