Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 30 additions & 28 deletions tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
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__':
Expand Down Expand Up @@ -129,6 +129,9 @@
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
Expand Down Expand Up @@ -185,35 +188,35 @@
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:
Expand All @@ -226,7 +229,6 @@
failures.append(tt_id)
print(e)


# Write summary of the builds
print("\nCompleted in: (%.2f)s\n" % (time() - start))

Expand Down
27 changes: 18 additions & 9 deletions tools/build_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -502,7 +506,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
notify=None, name=None, macros=None, inc_dirs=None, jobs=1,
report=None, properties=None, project_id=None,
project_description=None, config=None,
app_config=None, build_profile=None, stats_depth=None):
app_config=None, build_profile=None, stats_depth=None, ignore=None):
""" Build a project. A project may be a test or a user program.

Positional arguments:
Expand All @@ -529,6 +533,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
app_config - location of a chosen mbed_app.json file
build_profile - a dict of flags that will be passed to the compiler
stats_depth - depth level for memap to display file/dirs
ignore - list of paths to add to mbedignore
"""

# Convert src_path to a list if needed
Expand All @@ -546,7 +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)
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
Expand Down Expand Up @@ -643,7 +648,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
archive=True, notify=None, macros=None, inc_dirs=None, jobs=1,
report=None, properties=None, project_id=None,
remove_config_header_file=False, app_config=None,
build_profile=None):
build_profile=None, ignore=None):
""" Build a library

Positional arguments:
Expand All @@ -668,6 +673,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
remove_config_header_file - delete config header file when done building
app_config - location of a chosen mbed_app.json file
build_profile - a dict of flags that will be passed to the compiler
ignore - list of paths to add to mbedignore
"""

# Convert src_path to a list if needed
Expand All @@ -691,7 +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)
build_profile=build_profile, ignore=ignore)

# The first path will give the name to the library
if name is None:
Expand Down Expand Up @@ -793,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:
Expand All @@ -809,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):
Expand Down Expand Up @@ -872,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))
Expand Down Expand Up @@ -948,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

Expand All @@ -964,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:
Expand Down Expand Up @@ -1007,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
Expand Down
6 changes: 4 additions & 2 deletions tools/export/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion tools/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@
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",
Expand Down Expand Up @@ -284,7 +286,8 @@
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:
Expand Down
11 changes: 8 additions & 3 deletions tools/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
"""
Expand All @@ -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():
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))

Expand Down
10 changes: 8 additions & 2 deletions tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@
default=2,
help="Depth level for static memory report")

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()

# Filter tests by path if specified
Expand Down Expand Up @@ -153,6 +156,7 @@
if not config:
config = get_default_config(options.source_dir or ['.'], mcu)


# Find all tests in the relevant paths
for path in all_paths:
all_tests.update(find_tests(path, mcu, toolchain,
Expand Down Expand Up @@ -205,7 +209,8 @@
macros=options.macros,
notify=notify, archive=False,
app_config=config,
build_profile=profile)
build_profile=profile,
ignore=options.ignore)

library_build_success = True
except ToolException as e:
Expand Down Expand Up @@ -233,7 +238,8 @@
continue_on_build_fail=options.continue_on_build_fail,
app_config=config,
build_profile=profile,
stats_depth=options.stats_depth)
stats_depth=options.stats_depth,
ignore=options.ignore)

# If a path to a test spec is provided, write it to a file
if options.test_spec:
Expand Down
2 changes: 1 addition & 1 deletion tools/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2210,7 +2210,7 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
clean=False, notify=None, jobs=1, macros=None,
silent=False, report=None, properties=None,
continue_on_build_fail=False, app_config=None,
build_profile=None, stats_depth=None):
build_profile=None, stats_depth=None, ignore=None):
"""Given the data structure from 'find_tests' and the typical build parameters,
build all the tests

Expand Down