mirror of https://github.com/ARMmbed/mbed-os.git
Add -j option to build.py, build_release.py and make.py
Multiple compile jobs are not enabled by default unless -j 0 or -j >1 is specifiedpull/395/head
parent
f858f02120
commit
ff3cd57126
|
@ -63,6 +63,8 @@ if __name__ == '__main__':
|
||||||
default=False, help="Displays supported matrix of MCUs and toolchains")
|
default=False, help="Displays supported matrix of MCUs and toolchains")
|
||||||
parser.add_option("", "--cppcheck", action="store_true", dest="cppcheck_validation",
|
parser.add_option("", "--cppcheck", action="store_true", dest="cppcheck_validation",
|
||||||
default=False, help="Forces 'cppcheck' static code analysis")
|
default=False, help="Forces 'cppcheck' static code analysis")
|
||||||
|
parser.add_option("-j", "--jobs", type="int", dest="jobs",
|
||||||
|
default=1, help="Number of concurrent jobs (default 1). Use 0 for auto based on host machine's number of CPUs")
|
||||||
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
|
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
|
||||||
default=False, help="Verbose diagnostic output")
|
default=False, help="Verbose diagnostic output")
|
||||||
parser.add_option("-x", "--extra-verbose-notifications", action="store_true", dest="extra_verbose_notify",
|
parser.add_option("-x", "--extra-verbose-notifications", action="store_true", dest="extra_verbose_notify",
|
||||||
|
@ -127,12 +129,12 @@ if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
mcu = TARGET_MAP[target]
|
mcu = TARGET_MAP[target]
|
||||||
# CMSIS and MBED libs analysis
|
# CMSIS and MBED libs analysis
|
||||||
static_analysis_scan(mcu, toolchain, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, verbose=options.verbose)
|
static_analysis_scan(mcu, toolchain, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, verbose=options.verbose, jobs=options.jobs)
|
||||||
for lib_id in libraries:
|
for lib_id in libraries:
|
||||||
# Static check for library
|
# Static check for library
|
||||||
static_analysis_scan_lib(lib_id, mcu, toolchain, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT,
|
static_analysis_scan_lib(lib_id, mcu, toolchain, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT,
|
||||||
options=options.options,
|
options=options.options,
|
||||||
notify=notify, verbose=options.verbose, clean=options.clean,
|
notify=notify, verbose=options.verbose, jobs=options.jobs, clean=options.clean,
|
||||||
macros=options.macros)
|
macros=options.macros)
|
||||||
pass
|
pass
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
@ -149,7 +151,7 @@ if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
mcu = TARGET_MAP[target]
|
mcu = TARGET_MAP[target]
|
||||||
lib_build_res = build_mbed_libs(mcu, toolchain, options=options.options,
|
lib_build_res = build_mbed_libs(mcu, toolchain, options=options.options,
|
||||||
notify=notify, verbose=options.verbose, clean=options.clean,
|
notify=notify, verbose=options.verbose, jobs=options.jobs, clean=options.clean,
|
||||||
macros=options.macros)
|
macros=options.macros)
|
||||||
|
|
||||||
for lib_id in libraries:
|
for lib_id in libraries:
|
||||||
|
|
|
@ -30,11 +30,12 @@ from workspace_tools.targets import TARGET_NAMES, TARGET_MAP
|
||||||
|
|
||||||
def build_project(src_path, build_path, target, toolchain_name,
|
def build_project(src_path, build_path, target, toolchain_name,
|
||||||
libraries_paths=None, options=None, linker_script=None,
|
libraries_paths=None, options=None, linker_script=None,
|
||||||
clean=False, notify=None, verbose=False, name=None, macros=None, inc_dirs=None):
|
clean=False, notify=None, verbose=False, name=None, macros=None, inc_dirs=None, jobs=1):
|
||||||
""" This function builds project. Project can be for example one test / UT """
|
""" This function builds project. Project can be for example one test / UT """
|
||||||
# Toolchain instance
|
# Toolchain instance
|
||||||
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, notify, macros)
|
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, notify, macros)
|
||||||
toolchain.VERBOSE = verbose
|
toolchain.VERBOSE = verbose
|
||||||
|
toolchain.jobs = jobs
|
||||||
toolchain.build_all = clean
|
toolchain.build_all = clean
|
||||||
src_paths = [src_path] if type(src_path) != ListType else src_path
|
src_paths = [src_path] if type(src_path) != ListType else src_path
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ def build_project(src_path, build_path, target, toolchain_name,
|
||||||
|
|
||||||
def build_library(src_paths, build_path, target, toolchain_name,
|
def build_library(src_paths, build_path, target, toolchain_name,
|
||||||
dependencies_paths=None, options=None, name=None, clean=False,
|
dependencies_paths=None, options=None, name=None, clean=False,
|
||||||
notify=None, verbose=False, macros=None, inc_dirs=None):
|
notify=None, verbose=False, macros=None, inc_dirs=None, jobs=1):
|
||||||
""" src_path: the path of the source directory
|
""" src_path: the path of the source directory
|
||||||
build_path: the path of the build directory
|
build_path: the path of the build directory
|
||||||
target: ['LPC1768', 'LPC11U24', 'LPC2368']
|
target: ['LPC1768', 'LPC11U24', 'LPC2368']
|
||||||
|
@ -103,6 +104,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
|
||||||
# Toolchain instance
|
# Toolchain instance
|
||||||
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
|
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
|
||||||
toolchain.VERBOSE = verbose
|
toolchain.VERBOSE = verbose
|
||||||
|
toolchain.jobs = jobs
|
||||||
toolchain.build_all = clean
|
toolchain.build_all = clean
|
||||||
|
|
||||||
# The first path will give the name to the library
|
# The first path will give the name to the library
|
||||||
|
@ -159,7 +161,7 @@ def build_lib(lib_id, target, toolchain, options=None, verbose=False, clean=Fals
|
||||||
|
|
||||||
|
|
||||||
# We do have unique legacy conventions about how we build and package the mbed library
|
# We do have unique legacy conventions about how we build and package the mbed library
|
||||||
def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=False, macros=None, notify=None):
|
def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1):
|
||||||
""" Function returns True is library was built and false if building was skipped """
|
""" Function returns True is library was built and false if building was skipped """
|
||||||
# Check toolchain support
|
# Check toolchain support
|
||||||
if toolchain_name not in target.supported_toolchains:
|
if toolchain_name not in target.supported_toolchains:
|
||||||
|
@ -169,6 +171,7 @@ def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=F
|
||||||
# Toolchain
|
# Toolchain
|
||||||
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
|
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
|
||||||
toolchain.VERBOSE = verbose
|
toolchain.VERBOSE = verbose
|
||||||
|
toolchain.jobs = jobs
|
||||||
toolchain.build_all = clean
|
toolchain.build_all = clean
|
||||||
|
|
||||||
# Source and Build Paths
|
# Source and Build Paths
|
||||||
|
@ -274,10 +277,11 @@ def mcu_toolchain_matrix(verbose_html=False):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def static_analysis_scan(target, toolchain_name, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, options=None, verbose=False, clean=False, macros=None, notify=None):
|
def static_analysis_scan(target, toolchain_name, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1):
|
||||||
# Toolchain
|
# Toolchain
|
||||||
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
|
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
|
||||||
toolchain.VERBOSE = verbose
|
toolchain.VERBOSE = verbose
|
||||||
|
toolchain.jobs = jobs
|
||||||
toolchain.build_all = clean
|
toolchain.build_all = clean
|
||||||
|
|
||||||
# Source and Build Paths
|
# Source and Build Paths
|
||||||
|
@ -398,7 +402,7 @@ def static_analysis_scan_lib(lib_id, target, toolchain, cppcheck_cmd, cppcheck_m
|
||||||
|
|
||||||
def static_analysis_scan_library(src_paths, build_path, target, toolchain_name, cppcheck_cmd, cppcheck_msg_format,
|
def static_analysis_scan_library(src_paths, build_path, target, toolchain_name, cppcheck_cmd, cppcheck_msg_format,
|
||||||
dependencies_paths=None, options=None, name=None, clean=False,
|
dependencies_paths=None, options=None, name=None, clean=False,
|
||||||
notify=None, verbose=False, macros=None):
|
notify=None, verbose=False, macros=None, jobs=1):
|
||||||
""" Function scans library (or just some set of sources/headers) for staticly detectable defects """
|
""" Function scans library (or just some set of sources/headers) for staticly detectable defects """
|
||||||
if type(src_paths) != ListType:
|
if type(src_paths) != ListType:
|
||||||
src_paths = [src_paths]
|
src_paths = [src_paths]
|
||||||
|
@ -410,6 +414,7 @@ def static_analysis_scan_library(src_paths, build_path, target, toolchain_name,
|
||||||
# Toolchain instance
|
# Toolchain instance
|
||||||
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
|
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
|
||||||
toolchain.VERBOSE = verbose
|
toolchain.VERBOSE = verbose
|
||||||
|
toolchain.jobs = jobs
|
||||||
|
|
||||||
# The first path will give the name to the library
|
# The first path will give the name to the library
|
||||||
name = basename(src_paths[0])
|
name = basename(src_paths[0])
|
||||||
|
|
|
@ -68,6 +68,8 @@ if __name__ == '__main__':
|
||||||
parser = OptionParser()
|
parser = OptionParser()
|
||||||
parser.add_option('-o', '--official', dest="official_only", default=False, action="store_true",
|
parser.add_option('-o', '--official', dest="official_only", default=False, action="store_true",
|
||||||
help="Build using only the official toolchain for each target")
|
help="Build using only the official toolchain for each target")
|
||||||
|
parser.add_option("-j", "--jobs", type="int", dest="jobs",
|
||||||
|
default=1, help="Number of concurrent jobs (default 1). Use 0 for auto based on host machine's number of CPUs")
|
||||||
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
|
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
|
||||||
default=False, help="Verbose diagnostic output")
|
default=False, help="Verbose diagnostic output")
|
||||||
options, args = parser.parse_args()
|
options, args = parser.parse_args()
|
||||||
|
@ -82,7 +84,7 @@ if __name__ == '__main__':
|
||||||
for toolchain in toolchains:
|
for toolchain in toolchains:
|
||||||
id = "%s::%s" % (target_name, toolchain)
|
id = "%s::%s" % (target_name, toolchain)
|
||||||
try:
|
try:
|
||||||
build_mbed_libs(TARGET_MAP[target_name], toolchain, verbose=options.verbose)
|
build_mbed_libs(TARGET_MAP[target_name], toolchain, verbose=options.verbose, jobs=options.jobs)
|
||||||
successes.append(id)
|
successes.append(id)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
failures.append(id)
|
failures.append(id)
|
||||||
|
|
|
@ -47,6 +47,8 @@ if __name__ == '__main__':
|
||||||
help="The index of the desired test program: [0-%d]" % (len(TESTS)-1))
|
help="The index of the desired test program: [0-%d]" % (len(TESTS)-1))
|
||||||
parser.add_option("-n", dest="program_name",
|
parser.add_option("-n", dest="program_name",
|
||||||
help="The name of the desired test program")
|
help="The name of the desired test program")
|
||||||
|
parser.add_option("-j", "--jobs", type="int", dest="jobs",
|
||||||
|
default=1, help="Number of concurrent jobs (default 1). Use 0 for auto based on host machine's number of CPUs")
|
||||||
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
|
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
|
||||||
default=False, help="Verbose diagnostic output")
|
default=False, help="Verbose diagnostic output")
|
||||||
parser.add_option("-D", "", action="append", dest="macros",
|
parser.add_option("-D", "", action="append", dest="macros",
|
||||||
|
|
|
@ -233,6 +233,7 @@ class mbedToolchain:
|
||||||
|
|
||||||
self.build_all = False
|
self.build_all = False
|
||||||
self.timestamp = time()
|
self.timestamp = time()
|
||||||
|
self.jobs = 1
|
||||||
|
|
||||||
self.CHROOT = None
|
self.CHROOT = None
|
||||||
|
|
||||||
|
@ -489,8 +490,8 @@ class mbedToolchain:
|
||||||
objects.append(object)
|
objects.append(object)
|
||||||
|
|
||||||
# Use queues/multiprocessing if cpu count is higher than setting
|
# Use queues/multiprocessing if cpu count is higher than setting
|
||||||
cpus = cpu_count()
|
jobs = self.jobs if self.jobs else cpu_count()
|
||||||
if cpus > CPU_COUNT_MIN and len(queue) > cpus:
|
if jobs > CPU_COUNT_MIN and len(queue) > jobs:
|
||||||
return self.compile_queue(queue, objects)
|
return self.compile_queue(queue, objects)
|
||||||
else:
|
else:
|
||||||
for item in queue:
|
for item in queue:
|
||||||
|
@ -503,7 +504,7 @@ class mbedToolchain:
|
||||||
q = manager.Queue()
|
q = manager.Queue()
|
||||||
|
|
||||||
groups = []
|
groups = []
|
||||||
groups_count = int(cpu_count())
|
groups_count = int(self.jobs if self.jobs else cpu_count())
|
||||||
for i in range(groups_count):
|
for i in range(groups_count):
|
||||||
groups.append([])
|
groups.append([])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue