mirror of https://github.com/ARMmbed/mbed-os.git
add `--ignore` argument to `mbed compile` & `mbed export` commands
parent
badd753466
commit
3b79b3f65e
|
@ -41,7 +41,7 @@ from tools.build_api import print_build_results
|
|||
from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT
|
||||
from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, CLI_COLOR_MAP
|
||||
from tools.notifier.term import TerminalNotifier
|
||||
from tools.utils import argparse_filestring_type, args_error
|
||||
from tools.utils import argparse_filestring_type, args_error, argparse_many
|
||||
from tools.utils import argparse_filestring_type, argparse_dir_not_parent
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -129,6 +129,9 @@ if __name__ == '__main__':
|
|||
default=False,
|
||||
help="Makes compiler more verbose, CI friendly.")
|
||||
|
||||
parser.add_argument("--ignore", dest="ignore", type=argparse_many(str),
|
||||
default=None, help="Comma separated list of patterns to add to mbedignore (eg. ./main.cpp)")
|
||||
|
||||
options = parser.parse_args()
|
||||
|
||||
# Only prints matrix of supported toolchains
|
||||
|
@ -185,35 +188,35 @@ if __name__ == '__main__':
|
|||
mcu = TARGET_MAP[target]
|
||||
profile = extract_profile(parser, options, toolchain)
|
||||
if options.source_dir:
|
||||
lib_build_res = build_library(options.source_dir, options.build_dir, mcu, toolchain,
|
||||
extra_verbose=options.extra_verbose_notify,
|
||||
verbose=options.verbose,
|
||||
silent=options.silent,
|
||||
jobs=options.jobs,
|
||||
clean=options.clean,
|
||||
archive=(not options.no_archive),
|
||||
macros=options.macros,
|
||||
name=options.artifact_name,
|
||||
build_profile=profile)
|
||||
lib_build_res = build_library(
|
||||
options.source_dir, options.build_dir, mcu, toolchain,
|
||||
jobs=options.jobs,
|
||||
clean=options.clean,
|
||||
archive=(not options.no_archive),
|
||||
macros=options.macros,
|
||||
name=options.artifact_name,
|
||||
build_profile=profile,
|
||||
ignore=options.ignore,
|
||||
)
|
||||
else:
|
||||
lib_build_res = build_mbed_libs(mcu, toolchain,
|
||||
extra_verbose=options.extra_verbose_notify,
|
||||
verbose=options.verbose,
|
||||
silent=options.silent,
|
||||
jobs=options.jobs,
|
||||
clean=options.clean,
|
||||
macros=options.macros,
|
||||
build_profile=profile)
|
||||
lib_build_res = build_mbed_libs(
|
||||
mcu, toolchain,
|
||||
jobs=options.jobs,
|
||||
clean=options.clean,
|
||||
macros=options.macros,
|
||||
build_profile=profile,
|
||||
ignore=options.ignore,
|
||||
)
|
||||
|
||||
for lib_id in libraries:
|
||||
build_lib(lib_id, mcu, toolchain,
|
||||
extra_verbose=options.extra_verbose_notify,
|
||||
verbose=options.verbose,
|
||||
silent=options.silent,
|
||||
clean=options.clean,
|
||||
macros=options.macros,
|
||||
jobs=options.jobs,
|
||||
build_profile=profile)
|
||||
build_lib(
|
||||
lib_id, mcu, toolchain,
|
||||
clean=options.clean,
|
||||
macros=options.macros,
|
||||
jobs=options.jobs,
|
||||
build_profile=profile,
|
||||
ignore=options.ignore,
|
||||
)
|
||||
if lib_build_res:
|
||||
successes.append(tt_id)
|
||||
else:
|
||||
|
@ -226,7 +229,6 @@ if __name__ == '__main__':
|
|||
failures.append(tt_id)
|
||||
print(e)
|
||||
|
||||
|
||||
# Write summary of the builds
|
||||
print("\nCompleted in: (%.2f)s\n" % (time() - start))
|
||||
|
||||
|
|
|
@ -301,7 +301,7 @@ def target_supports_toolchain(target, toolchain_name):
|
|||
def prepare_toolchain(src_paths, build_dir, target, toolchain_name,
|
||||
macros=None, clean=False, jobs=1,
|
||||
notify=None, config=None, app_config=None,
|
||||
build_profile=None):
|
||||
build_profile=None, ignore=None):
|
||||
""" Prepares resource related objects - toolchain, target, config
|
||||
|
||||
Positional arguments:
|
||||
|
@ -317,6 +317,7 @@ def prepare_toolchain(src_paths, build_dir, target, toolchain_name,
|
|||
config - a Config object to use instead of creating one
|
||||
app_config - location of a chosen mbed_app.json file
|
||||
build_profile - a list of mergeable build profiles
|
||||
ignore - list of paths to add to mbedignore
|
||||
"""
|
||||
|
||||
# We need to remove all paths which are repeated to avoid
|
||||
|
@ -348,6 +349,9 @@ def prepare_toolchain(src_paths, build_dir, target, toolchain_name,
|
|||
toolchain.jobs = jobs
|
||||
toolchain.build_all = clean
|
||||
|
||||
if ignore:
|
||||
toolchain.add_ignore_patterns(root=".", base_path=".", patterns=ignore)
|
||||
|
||||
return toolchain
|
||||
|
||||
def _printihex(ihex):
|
||||
|
@ -547,11 +551,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
|
|||
toolchain = prepare_toolchain(
|
||||
src_paths, build_path, target, toolchain_name, macros=macros,
|
||||
clean=clean, jobs=jobs, notify=notify, config=config,
|
||||
app_config=app_config, build_profile=build_profile)
|
||||
|
||||
if ignore:
|
||||
toolchain.add_ignore_patterns(root=".", base_path=".",
|
||||
patterns=ignore)
|
||||
app_config=app_config, build_profile=build_profile, ignore=ignore)
|
||||
|
||||
# The first path will give the name to the library
|
||||
name = (name or toolchain.config.name or
|
||||
|
@ -697,11 +697,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
|
|||
toolchain = prepare_toolchain(
|
||||
src_paths, build_path, target, toolchain_name, macros=macros,
|
||||
clean=clean, jobs=jobs, notify=notify, app_config=app_config,
|
||||
build_profile=build_profile)
|
||||
|
||||
if ignore:
|
||||
toolchain.add_ignore_patterns(root=".", base_path=".",
|
||||
patterns=ignore)
|
||||
build_profile=build_profile, ignore=ignore)
|
||||
|
||||
# The first path will give the name to the library
|
||||
if name is None:
|
||||
|
@ -803,7 +799,7 @@ def mbed2_obj_path(target_name, toolchain_name):
|
|||
|
||||
def build_lib(lib_id, target, toolchain_name, clean=False, macros=None,
|
||||
notify=None, jobs=1, report=None, properties=None,
|
||||
build_profile=None):
|
||||
build_profile=None, ignore=None):
|
||||
""" Legacy method for building mbed libraries
|
||||
|
||||
Positional arguments:
|
||||
|
@ -819,6 +815,7 @@ def build_lib(lib_id, target, toolchain_name, clean=False, macros=None,
|
|||
report - a dict where a result may be appended
|
||||
properties - UUUUHHHHH beats me
|
||||
build_profile - a dict of flags that will be passed to the compiler
|
||||
ignore - list of paths to add to mbedignore
|
||||
"""
|
||||
lib = Library(lib_id)
|
||||
if not lib.is_supported(target, toolchain_name):
|
||||
|
@ -882,7 +879,8 @@ def build_lib(lib_id, target, toolchain_name, clean=False, macros=None,
|
|||
|
||||
toolchain = prepare_toolchain(
|
||||
src_paths, tmp_path, target, toolchain_name, macros=macros,
|
||||
notify=notify, build_profile=build_profile, jobs=jobs, clean=clean)
|
||||
notify=notify, build_profile=build_profile, jobs=jobs, clean=clean,
|
||||
ignore=ignore)
|
||||
|
||||
notify.info("Building library %s (%s, %s)" %
|
||||
(name.upper(), target.name, toolchain_name))
|
||||
|
@ -958,7 +956,7 @@ def build_lib(lib_id, target, toolchain_name, clean=False, macros=None,
|
|||
# library
|
||||
def build_mbed_libs(target, toolchain_name, clean=False, macros=None,
|
||||
notify=None, jobs=1, report=None, properties=None,
|
||||
build_profile=None):
|
||||
build_profile=None, ignore=None):
|
||||
""" Function returns True is library was built and false if building was
|
||||
skipped
|
||||
|
||||
|
@ -974,6 +972,7 @@ def build_mbed_libs(target, toolchain_name, clean=False, macros=None,
|
|||
report - a dict where a result may be appended
|
||||
properties - UUUUHHHHH beats me
|
||||
build_profile - a dict of flags that will be passed to the compiler
|
||||
ignore - list of paths to add to mbedignore
|
||||
"""
|
||||
|
||||
if report != None:
|
||||
|
@ -1017,7 +1016,7 @@ def build_mbed_libs(target, toolchain_name, clean=False, macros=None,
|
|||
|
||||
toolchain = prepare_toolchain(
|
||||
[""], tmp_path, target, toolchain_name, macros=macros, notify=notify,
|
||||
build_profile=build_profile, jobs=jobs, clean=clean)
|
||||
build_profile=build_profile, jobs=jobs, clean=clean, ignore=ignore)
|
||||
|
||||
# Take into account the library configuration (MBED_CONFIG_FILE)
|
||||
config = toolchain.config
|
||||
|
|
|
@ -221,7 +221,8 @@ def zip_export(file_name, prefix, resources, project_files, inc_repos, notify):
|
|||
def export_project(src_paths, export_path, target, ide, libraries_paths=None,
|
||||
linker_script=None, notify=None, name=None, inc_dirs=None,
|
||||
jobs=1, config=None, macros=None, zip_proj=None,
|
||||
inc_repos=False, build_profile=None, app_config=None):
|
||||
inc_repos=False, build_profile=None, app_config=None,
|
||||
ignore=None):
|
||||
"""Generates a project file and creates a zip archive if specified
|
||||
|
||||
Positional Arguments:
|
||||
|
@ -242,6 +243,7 @@ def export_project(src_paths, export_path, target, ide, libraries_paths=None,
|
|||
macros - User-defined macros
|
||||
zip_proj - string name of the zip archive you wish to creat (exclude arg
|
||||
if you do not wish to create an archive
|
||||
ignore - list of paths to add to mbedignore
|
||||
"""
|
||||
|
||||
# Convert src_path to a list if needed
|
||||
|
@ -269,7 +271,7 @@ def export_project(src_paths, export_path, target, ide, libraries_paths=None,
|
|||
toolchain = prepare_toolchain(
|
||||
paths, "", target, toolchain_name, macros=macros, jobs=jobs,
|
||||
notify=notify, config=config, build_profile=build_profile,
|
||||
app_config=app_config)
|
||||
app_config=app_config, ignore=ignore)
|
||||
|
||||
toolchain.RESPONSE_FILES = False
|
||||
if name is None:
|
||||
|
|
|
@ -140,6 +140,8 @@ if __name__ == '__main__':
|
|||
default=None, help="The build (output) directory")
|
||||
parser.add_argument("-N", "--artifact-name", dest="artifact_name",
|
||||
default=None, help="The built project's name")
|
||||
parser.add_argument("--ignore", dest="ignore", type=argparse_many(str),
|
||||
default=None, help="Comma separated list of patterns to add to mbedignore (eg. ./main.cpp)")
|
||||
parser.add_argument("-d", "--disk", dest="disk",
|
||||
default=None, help="The mbed disk")
|
||||
parser.add_argument("-s", "--serial", dest="serial",
|
||||
|
@ -284,7 +286,8 @@ if __name__ == '__main__':
|
|||
build_profile=extract_profile(parser,
|
||||
options,
|
||||
toolchain),
|
||||
stats_depth=options.stats_depth)
|
||||
stats_depth=options.stats_depth,
|
||||
ignore=options.ignore)
|
||||
print('Image: %s'% bin_file)
|
||||
|
||||
if options.disk:
|
||||
|
|
|
@ -73,7 +73,7 @@ def setup_project(ide, target, program=None, source_dir=None, build=None, export
|
|||
|
||||
def export(target, ide, build=None, src=None, macros=None, project_id=None,
|
||||
zip_proj=False, build_profile=None, export_path=None, notify=None,
|
||||
app_config=None):
|
||||
app_config=None, ignore=None):
|
||||
"""Do an export of a project.
|
||||
|
||||
Positional arguments:
|
||||
|
@ -87,6 +87,7 @@ def export(target, ide, build=None, src=None, macros=None, project_id=None,
|
|||
project_id - the name of the project
|
||||
clean - start from a clean state before exporting
|
||||
zip_proj - create a zip file or not
|
||||
ignore - list of paths to add to mbedignore
|
||||
|
||||
Returns an object of type Exporter (tools/exports/exporters.py)
|
||||
"""
|
||||
|
@ -98,7 +99,7 @@ def export(target, ide, build=None, src=None, macros=None, project_id=None,
|
|||
return export_project(src, project_dir, target, ide, name=name,
|
||||
macros=macros, libraries_paths=lib, zip_proj=zip_name,
|
||||
build_profile=build_profile, notify=notify,
|
||||
app_config=app_config)
|
||||
app_config=app_config, ignore=ignore)
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -197,6 +198,9 @@ def main():
|
|||
dest="app_config",
|
||||
default=None)
|
||||
|
||||
parser.add_argument("--ignore", dest="ignore", type=argparse_many(str),
|
||||
default=None, help="Comma separated list of patterns to add to mbedignore (eg. ./main.cpp)")
|
||||
|
||||
options = parser.parse_args()
|
||||
|
||||
# Print available tests in order and exit
|
||||
|
@ -273,7 +277,8 @@ def main():
|
|||
src=options.source_dir, macros=options.macros,
|
||||
project_id=options.program, zip_proj=zip_proj,
|
||||
build_profile=profile, app_config=options.app_config,
|
||||
export_path=options.build_dir, notify = notify)
|
||||
export_path=options.build_dir, notify=notify,
|
||||
ignore=options.ignore)
|
||||
except NotSupportedException as exc:
|
||||
print("[ERROR] %s" % str(exc))
|
||||
|
||||
|
|
Loading…
Reference in New Issue