common: add --force-rebuild option to build scripts

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-03-13 00:00:00 +00:00
parent 550897ce17
commit bb28e260c5

View File

@@ -1042,15 +1042,6 @@ lunch aosp_{}-eng
os.makedirs(self.env['p9_dir'], exist_ok=True)
os.makedirs(self.env['qemu_run_dir'], exist_ok=True)
@staticmethod
def need_rebuild(srcs, dst):
if not os.path.exists(dst):
return True
for src in srcs:
if os.path.getmtime(src) > os.path.getmtime(dst):
return True
return False
@staticmethod
def seconds_to_hms(seconds):
'''
@@ -1175,6 +1166,11 @@ class BuildCliFunction(LkmcCliFunction):
default=False,
help='Clean the build instead of building.',
),
self.add_argument(
'--force-rebuild',
default=False,
help="Force rebuild even if sources didn't chage",
)
self.add_argument(
'-j',
'--nproc',
@@ -1198,6 +1194,16 @@ class BuildCliFunction(LkmcCliFunction):
def get_build_dir(self):
return None
def need_rebuild(self, srcs, dst):
if self.env['force_rebuild']:
return True
if not os.path.exists(dst):
return True
for src in srcs:
if os.path.getmtime(src) > os.path.getmtime(dst):
return True
return False
def timed_main(self):
'''
Parse CLI, and to the build based on it.