提交 20956521 编写于 作者: W weifulun

enable specifies device type and usermode by compilation options

Signed-off-by: 蜗牛aonk's avatarweifulun <weifulun@huawei.com>
Change-Id: I404c43f3bf3f890e15c79f7e5c9ff14683de8e0a
上级 7989c06b
......@@ -102,6 +102,12 @@ def add_options(parser):
help='it will skip prepare, preloader, '
'gn_gen steps so we can enable it only '
'when there is no change for gn related script')
parser.add_argument('--device-type',
help='specifies device type',
default='default')
parser.add_argument('--is-usermod',
help='specifies device operating mode',
default='true')
def exec_command(args):
......@@ -178,6 +184,10 @@ def exec_command(args):
ninja = False
if args.fast_rebuild:
cmd_args['fast_rebuild'] = args.fast_rebuild
if hasattr(args, 'device_type') and args.device_type:
cmd_args['device_type'] = args.device_type
if hasattr(args, 'is_usermod') and args.is_usermod:
cmd_args['is_usermod'] = args.is_usermod
return build.build(args.full,
patch=args.patch,
cmd_args=cmd_args,
......
......@@ -151,6 +151,7 @@ class Build():
finally:
post_build = PostBuild(self.config)
post_build.clean(self.start_time)
post_build.patch_ohos_para(cmd_args)
hb_info(f'{os.path.basename(self.config.out_path)} build success')
hb_info(f'cost time: {self.build_time}')
......
......@@ -20,7 +20,7 @@ import os
import subprocess
from datetime import datetime
from distutils.spawn import find_executable
from hb_internal.common.utils import exec_command
from hb_internal.common.utils import OHOSException, exec_command
from hb_internal.common.utils import hb_warning
......@@ -93,6 +93,38 @@ class PostBuild:
self.get_warning_list()
self.compute_overlap_rate()
def patch_ohos_para(self, cmd_args):
ohos_para_data = []
ohos_para_file_path = os.path.join(self._out_path, 'packages/phone/system/etc/param/ohos.para')
with open(ohos_para_file_path, 'r', encoding='utf-8') as ohos_para_file:
for line in ohos_para_file:
ohos_para_data.append(line)
if cmd_args.get('device_type') and cmd_args.get('device_type') != 'default':
support_device = ['tabel', 'watch', 'kidwatch', 'tv', 'mobiletv', 'car']
if not support_device.__contains__(cmd_args.get('device_type')):
raise OHOSException(f'Unsupported device type :' + cmd_args.get('device_type'))
for i in range(len(ohos_para_data)):
if ohos_para_data[i].__contains__('const.build.characteristics'):
ohos_para_data[i] = ohos_para_data[i].replace('default', cmd_args.get('device_type'))
break
if cmd_args.get('is_usermod'):
for i in range(len(ohos_para_data)):
if ohos_para_data[i].__contains__('const.secure'):
if cmd_args.get('is_usermod') == True:
ohos_para_data[i] = 'const.secure=1\n'
else:
ohos_para_data[i] = 'const.secure=0\n'
if ohos_para_data[i].__contains__('const.debuggable'):
if cmd_args.get('is_usermod') == True:
ohos_para_data[i] = 'const.debuggable=0\n'
else:
ohos_para_data[i] = 'const.debuggable=1\n'
data = ''
for line in ohos_para_data:
data += line
with open(ohos_para_file_path, 'w', encoding='utf-8') as ohos_para_file:
ohos_para_file.write(data)
def stat_pycache(self):
cmd = [
'python3', '{}/build/scripts/util/pyd.py'.format(self._root_path),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册