update the build_apps.py, now it can recognize build and preserve keys

This commit is contained in:
Fu Hanxi 2020-04-23 18:48:51 +08:00
parent ba12a549bb
commit 2d57fd7fca
4 changed files with 15 additions and 13 deletions

View File

@ -5,9 +5,10 @@
#
import argparse
import shutil
import sys
import logging
from find_build_apps import BuildItem, BuildError, setup_logging, BUILD_SYSTEMS, safe_exit_if_file_is_empty
from find_build_apps import BuildItem, BuildError, setup_logging, BUILD_SYSTEMS
def main():
@ -71,10 +72,11 @@ def main():
help="Name of the file to read the list of builds from. If not specified, read from stdin.",
)
args = parser.parse_args()
setup_logging(args)
safe_exit_if_file_is_empty(args.build_list.name)
build_items = [BuildItem.from_json(line) for line in args.build_list]
if not build_items:
logging.error("Empty build list!")
raise SystemExit(1)
@ -106,6 +108,10 @@ def main():
failed_builds = []
for build_info in builds_for_current_job:
if not build_info.build:
logging.info('Skip build detected. Skipping...')
continue
logging.info("Running build {}: {}".format(build_info.index, repr(build_info)))
build_system_class = BUILD_SYSTEMS[build_info.build_system]
try:
@ -116,6 +122,11 @@ def main():
failed_builds.append(build_info)
else:
raise SystemExit(1)
else:
if not build_info.preserve:
logging.info('NOT preserve artifacts detected. Deleting...')
shutil.rmtree(build_info.work_dir, ignore_errors=True)
shutil.rmtree(build_info.build_log_path, ignore_errors=True)
if failed_builds:
logging.error("The following build have failed:")

View File

@ -13,10 +13,10 @@ import logging
import re
try:
from find_build_apps import BuildItem, setup_logging, safe_exit_if_file_is_empty
from find_build_apps import BuildItem, setup_logging
except ImportError:
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from find_build_apps import BuildItem, setup_logging, safe_exit_if_file_is_empty
from find_build_apps import BuildItem, setup_logging
WARNING_REGEX = re.compile(r"(?:error|warning)[^\w]", re.MULTILINE | re.IGNORECASE)
@ -69,7 +69,6 @@ def main():
args = parser.parse_args()
setup_logging(args)
safe_exit_if_file_is_empty(args.build_list.name)
build_items = [BuildItem.from_json(line) for line in args.build_list]
if not build_items:

View File

@ -6,7 +6,6 @@ from .common import (
config_rules_from_str,
setup_logging,
DEFAULT_TARGET,
safe_exit_if_file_is_empty,
)
from .cmake import CMakeBuildSystem, BUILD_SYSTEM_CMAKE
from .make import MakeBuildSystem, BUILD_SYSTEM_MAKE
@ -29,5 +28,4 @@ __all__ = [
"MakeBuildSystem",
"BUILD_SYSTEM_MAKE",
"BUILD_SYSTEMS",
"safe_exit_if_file_is_empty",
]

View File

@ -392,9 +392,3 @@ def setup_logging(args):
stream=args.log_file or sys.stderr,
level=log_level,
)
def safe_exit_if_file_is_empty(file_name):
if os.stat(file_name).st_size == 0:
logging.warning('Skipping all...')
sys.exit(0)