提交 07a0c474 编写于 作者: L liwentao_uiw

add fast rebuild mechanism to skip prepare, preloader, gn_gen steps when no gn...

add fast rebuild mechanism to skip prepare, preloader, gn_gen steps when no gn related scripts changed
Signed-off-by: Nliwentao <liwentao20@huawei.com>
Change-Id: I9f6d575f859a24b7c2f490a9a979f0a157e78578
上级 7c18dd8e
......@@ -91,6 +91,12 @@ def add_options(parser):
parser.add_argument('--build-only-gn',
action='store_true',
help='only do gn parse, donot run ninja')
parser.add_argument('--fast-rebuild',
action='store_true',
default=False,
help='it will skip prepare, preloader, '
'gn_gen steps so we can enable it only '
'when there is no change for gn related script')
def exec_command(args):
......@@ -163,6 +169,8 @@ def exec_command(args):
ninja = True
if hasattr(args, 'build_only_gn') and args.build_only_gn:
ninja = False
if args.fast_rebuild:
cmd_args['fast_rebuild'] = args.fast_rebuild
return build.build(args.full,
patch=args.patch,
cmd_args=cmd_args,
......
......@@ -132,7 +132,7 @@ class Build():
def build(self, full_compile, patch=False, ninja=True, cmd_args=None):
if 'target_cpu' in str(cmd_args):
self.config.target_cpu = cmd_args["target_cpu"]
cmd_list = self.get_cmd(full_compile, patch, ninja)
cmd_list = self.get_cmd(full_compile, patch, ninja, cmd_args)
# enable ccache if it installed.
ccache_path = find_executable('ccache')
......@@ -156,18 +156,19 @@ class Build():
hb_info(f'cost time: {self.build_time}')
return 0
def get_cmd(self, full_compile, patch, ninja):
def get_cmd(self, full_compile, patch, ninja, cmd_args):
cmd_list = []
pre_build = PreBuild(self.config)
cmd_list.append(pre_build.prepare)
if not cmd_args.get('fast_rebuild'):
pre_build = PreBuild(self.config)
cmd_list.append(pre_build.prepare)
if patch:
patch = Patch()
cmd_list.append(patch.patch_make)
preloader = Preloader(self.config)
cmd_list.append(preloader.run)
if not cmd_args.get('fast_rebuild'):
preloader = Preloader(self.config)
cmd_list.append(preloader.run)
# if full_compile is set, remove out and do full build
# if build_only_gn is set, only do gn parse
......@@ -175,14 +176,20 @@ class Build():
if full_compile:
remove_path(self.config.out_path)
makedirs(self.config.out_path, exist_ok=True)
cmd_list.extend([self.gn_build, self.ninja_build])
if not cmd_args.get('fast_rebuild'):
cmd_list.append(self.gn_build)
cmd_list.append(self.ninja_build)
elif not ninja:
makedirs(self.config.out_path, exist_ok=True)
cmd_list.append(self.gn_build)
if not cmd_args.get('fast_rebuild'):
cmd_list.append(self.gn_build)
return cmd_list
else:
makedirs(self.config.out_path, exist_ok=True)
cmd_list.extend([self.gn_build, self.ninja_build])
if not cmd_args.get('fast_rebuild'):
cmd_list.append(self.gn_build)
cmd_list.append(self.ninja_build)
if self.config.os_level != "standard":
if self.config.fs_attr is not None:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册