提交 a0b56e08 编写于 作者: O openharmony_ci 提交者: Gitee

!174 hb 编译流程优化

Merge pull request !174 from pilipala195/master
......@@ -22,9 +22,11 @@ import argparse
import shlex
from tempfile import NamedTemporaryFile
from shutil import copyfile
from datetime import datetime
def cmd_exec(command, temp_file, error_log_path):
start_time = datetime.now().replace(microsecond=0)
cmd = shlex.split(command)
proc = subprocess.Popen(cmd,
......@@ -40,6 +42,8 @@ def cmd_exec(command, temp_file, error_log_path):
os.remove(temp_file.name)
return ret_code
end_time = datetime.now().replace(microsecond=0)
temp_file.write(f'cmd:{command}\ncost time:{end_time-start_time}\n')
return ret_code
......
......@@ -42,4 +42,4 @@ CONFIG_STRUCT = {
"device_path": None,
"patch_cache": None
}
VERSION = '0.4.1'
VERSION = '0.4.2'
......@@ -26,6 +26,7 @@ from hb.common.utils import remove_path
from hb.common.utils import hb_info
from hb.common.utils import hb_warning
from hb.common.utils import OHOSException
from hb.common.utils import get_current_time
from hb.common.config import Config
from hb.cts.cts import CTS
from hb.common.device import Device
......@@ -34,6 +35,7 @@ from hb.build.fs_process import Packer
from hb.build.patch_process import Patch
from distutils.spawn import find_executable
class Build():
def __init__(self, component=None):
self.config = Config()
......@@ -45,6 +47,7 @@ class Build():
self._test = None
self.target = component
self.start_time = get_current_time()
self.check_in_device()
@property
......@@ -102,6 +105,10 @@ class Build():
else:
raise OHOSException('Error: wrong input of test')
@property
def build_time(self):
return get_current_time() - self.start_time
def register_args(self, args_name, args_value, quota=True):
quota = False if args_value in ['true', 'false'] else quota
if quota:
......@@ -129,6 +136,7 @@ class Build():
exec_cmd(cmd_args)
hb_info(f'{os.path.basename(self.config.out_path)} build success')
hb_info(f'cost time: {self.build_time}')
return 0
def get_cmd(self, full_compile, patch, ninja):
......
......@@ -183,11 +183,12 @@ def args_factory(args_dict):
return args
def get_current_time(type='timestamp'):
def get_current_time(type='default'):
if type == 'timestamp':
return int(datetime.utcnow().timestamp() * 1000)
if type == 'datetime':
return datetime.now().strftime('%Y-%m-%d %H:%M:%S')
return datetime.now().replace(microsecond=0)
def hb_info(msg):
......
......@@ -20,6 +20,8 @@ import os
from hb.common.config import Config
from hb.common.utils import get_input
from hb.common.utils import OHOSException
from hb.common.utils import hb_info
from hb.common.product import Product
from hb.common.device import Device
......@@ -47,7 +49,11 @@ def exec_command(args):
def set_root_path(root_path=None):
config = Config()
if root_path is None:
root_path = get_input('[OHOS INFO] Input code path: ')
try:
hb_info(f'hb root path: {config.root_path}')
return 0
except OHOSException:
root_path = get_input('[OHOS INFO] Input code path: ')
config.root_path = root_path
return 0
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册