Add simple build profiles to toolchains

pull/2802/head
Jimmy Brisson 2016-09-23 15:44:09 -05:00
parent b481da44e9
commit ceda396e18
6 changed files with 58 additions and 21 deletions

View File

@ -277,7 +277,7 @@ def prepare_toolchain(src_paths, target, toolchain_name,
macros=None, options=None, clean=False, jobs=1,
notify=None, silent=False, verbose=False,
extra_verbose=False, config=None,
app_config=None):
app_config=None, build_profile=None):
""" Prepares resource related objects - toolchain, target, config
Positional arguments:
@ -310,7 +310,7 @@ def prepare_toolchain(src_paths, target, toolchain_name,
try:
toolchain = TOOLCHAIN_CLASSES[toolchain_name](
target, options, notify, macros, silent,
extra_verbose=extra_verbose)
extra_verbose=extra_verbose, build_profile=build_profile)
except KeyError:
raise KeyError("Toolchain %s not supported" % toolchain_name)
@ -366,7 +366,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
macros=None, inc_dirs=None, jobs=1, silent=False,
report=None, properties=None, project_id=None,
project_description=None, extra_verbose=False, config=None,
app_config=None):
app_config=None, build_profile=None):
""" Build a project. A project may be a test or a user program.
Positional arguments:
@ -413,7 +413,8 @@ def build_project(src_paths, build_path, target, toolchain_name,
toolchain = prepare_toolchain(
src_paths, target, toolchain_name, macros=macros, options=options,
clean=clean, jobs=jobs, notify=notify, silent=silent, verbose=verbose,
extra_verbose=extra_verbose, config=config, app_config=app_config)
extra_verbose=extra_verbose, config=config, app_config=app_config,
build_profile=build_profile)
# The first path will give the name to the library
if name is None:

View File

@ -19,6 +19,7 @@ limitations under the License.
TEST BUILD & RUN
"""
import sys
import json
from time import sleep
from shutil import copy
from os.path import join, abspath, dirname
@ -180,6 +181,9 @@ if __name__ == '__main__':
parser.add_argument("-l", "--linker", dest="linker_script",
type=argparse_filestring_type,
default=None, help="use the specified linker script")
parser.add_argument("--profile", dest="profile",
type=argparse_filestring_type,
default=None)
options = parser.parse_args()
@ -220,6 +224,17 @@ if __name__ == '__main__':
if options.source_dir and not options.build_dir:
args_error(parser, "argument --build is required when argument --source is provided")
if options.profile:
contents = json.load(open(options.profile))
try:
profile = contents[toolchain]
except KeyError:
args_error(parser, ("argument --profile: toolchain {} is not"
" supported by profile {}").format(toolchain,
options.profile))
else:
profile = None
if options.color:
# This import happens late to prevent initializing colorization when we don't need it
import colorize
@ -280,7 +295,8 @@ if __name__ == '__main__':
macros=options.macros,
jobs=options.jobs,
name=options.artifact_name,
app_config=options.app_config)
app_config=options.app_config,
build_profile=profile)
print 'Image: %s'% bin_file
if options.disk:

View File

@ -217,7 +217,7 @@ class mbedToolchain:
__metaclass__ = ABCMeta
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False, build_profile=None):
self.target = target
self.name = self.__class__.__name__
@ -225,7 +225,7 @@ class mbedToolchain:
self.hook = hooks.Hook(target, self)
# Toolchain flags
self.flags = deepcopy(self.DEFAULT_FLAGS)
self.flags = deepcopy(build_profile or self.DEFAULT_FLAGS)
# User-defined macros
self.macros = macros or []

View File

@ -51,8 +51,11 @@ class ARM(mbedToolchain):
Returns False otherwise."""
return mbedToolchain.generic_check_executable("ARM", 'armcc', 2, 'bin')
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
def __init__(self, target, options=None, notify=None, macros=None,
silent=False, extra_verbose=False, build_profile=None):
mbedToolchain.__init__(self, target, options, notify, macros, silent,
extra_verbose=extra_verbose,
build_profile=build_profile)
if target.core == "Cortex-M0+":
cpu = "Cortex-M0"
@ -241,8 +244,10 @@ class ARM(mbedToolchain):
class ARM_STD(ARM):
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
ARM.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
def __init__(self, target, options=None, notify=None, macros=None,
silent=False, extra_verbose=False, build_profile=None):
ARM.__init__(self, target, options, notify, macros, silent,
extra_verbose=extra_verbose, build_profile=build_profile)
# Run-time values
self.ld.extend(["--libpath", join(TOOLCHAIN_PATHS['ARM'], "lib")])
@ -251,8 +256,10 @@ class ARM_STD(ARM):
class ARM_MICRO(ARM):
PATCHED_LIBRARY = False
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
ARM.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
def __init__(self, target, options=None, notify=None, macros=None,
silent=False, extra_verbose=False, build_profile=None):
ARM.__init__(self, target, options, notify, macros, silent,
extra_verbose=extra_verbose, build_profile=build_profile)
# Extend flags
self.flags['common'].extend(["-D__MICROLIB"])

View File

@ -46,8 +46,12 @@ class GCC(mbedToolchain):
"-Wl,--wrap,exit", "-Wl,--wrap,atexit"],
}
def __init__(self, target, options=None, notify=None, macros=None, silent=False, tool_path="", extra_verbose=False):
mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
def __init__(self, target, options=None, notify=None, macros=None,
silent=False, tool_path="", extra_verbose=False,
build_profile=None):
mbedToolchain.__init__(self, target, options, notify, macros, silent,
extra_verbose=extra_verbose,
build_profile=build_profile)
if target.core == "Cortex-M0+":
cpu = "cortex-m0plus"
@ -280,8 +284,11 @@ class GCC_ARM(GCC):
Returns False otherwise."""
return mbedToolchain.generic_check_executable("GCC_ARM", 'arm-none-eabi-gcc', 1)
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
GCC.__init__(self, target, options, notify, macros, silent, TOOLCHAIN_PATHS['GCC_ARM'], extra_verbose=extra_verbose)
def __init__(self, target, options=None, notify=None, macros=None,
silent=False, extra_verbose=False, build_profile=None):
GCC.__init__(self, target, options, notify, macros, silent,
TOOLCHAIN_PATHS['GCC_ARM'], extra_verbose=extra_verbose,
build_profile=build_profile)
# Use latest gcc nanolib
if "std-lib" in self.options:
@ -312,8 +319,11 @@ class GCC_CR(GCC):
Returns False otherwise."""
return mbedToolchain.generic_check_executable("GCC_CR", 'arm-none-eabi-gcc', 1)
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
GCC.__init__(self, target, options, notify, macros, silent, TOOLCHAIN_PATHS['GCC_CR'], extra_verbose=extra_verbose)
def __init__(self, target, options=None, notify=None, macros=None,
silent=False, extra_verbose=False, build_profile=None):
GCC.__init__(self, target, options, notify, macros, silent,
TOOLCHAIN_PATHS['GCC_CR'], extra_verbose=extra_verbose,
build_profile=build_profile)
additional_compiler_flags = [
"-D__NEWLIB__", "-D__CODE_RED", "-D__USE_CMSIS", "-DCPP_USE_HEAP",

View File

@ -54,8 +54,11 @@ class IAR(mbedToolchain):
Returns False otherwise."""
return mbedToolchain.generic_check_executable("IAR", 'iccarm', 2, "bin")
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
def __init__(self, target, options=None, notify=None, macros=None,
silent=False, extra_verbose=False, build_profile=None):
mbedToolchain.__init__(self, target, options, notify, macros, silent,
extra_verbose=extra_verbose,
build_profile=build_profile)
if target.core == "Cortex-M7F" or target.core == "Cortex-M7FD":
cpuchoice = "Cortex-M7"
else: