Skip to content

Commit 2df4afd

Browse files
committed
Merge pull request #395 from screamerbg/master
Support for multiple compile queues/jobs, stats cache and compile order consistency
2 parents 83b4b6d + d583522 commit 2df4afd

File tree

8 files changed

+281
-67
lines changed

8 files changed

+281
-67
lines changed

workspace_tools/build.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@
107107
dest='general_filter_regex',
108108
default=None,
109109
help='For some commands you can use filter to filter out results')
110+
111+
parser.add_option("-j", "--jobs", type="int", dest="jobs",
112+
default=1, help="Number of concurrent jobs (default 1). Use 0 for auto based on host machine's number of CPUs")
110113

111114
parser.add_option("-v", "--verbose",
112115
action="store_true",
@@ -182,12 +185,12 @@
182185
try:
183186
mcu = TARGET_MAP[target]
184187
# CMSIS and MBED libs analysis
185-
static_analysis_scan(mcu, toolchain, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, verbose=options.verbose)
188+
static_analysis_scan(mcu, toolchain, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, verbose=options.verbose, jobs=options.jobs)
186189
for lib_id in libraries:
187190
# Static check for library
188191
static_analysis_scan_lib(lib_id, mcu, toolchain, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT,
189192
options=options.options,
190-
notify=notify, verbose=options.verbose, clean=options.clean,
193+
notify=notify, verbose=options.verbose, jobs=options.jobs, clean=options.clean,
191194
macros=options.macros)
192195
pass
193196
except Exception, e:
@@ -204,7 +207,7 @@
204207
try:
205208
mcu = TARGET_MAP[target]
206209
lib_build_res = build_mbed_libs(mcu, toolchain, options=options.options,
207-
notify=notify, verbose=options.verbose, clean=options.clean,
210+
notify=notify, verbose=options.verbose, jobs=options.jobs, clean=options.clean,
208211
macros=options.macros)
209212

210213
for lib_id in libraries:

workspace_tools/build_api.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@
3131

3232
def build_project(src_path, build_path, target, toolchain_name,
3333
libraries_paths=None, options=None, linker_script=None,
34-
clean=False, notify=None, verbose=False, name=None, macros=None, inc_dirs=None):
34+
clean=False, notify=None, verbose=False, name=None, macros=None, inc_dirs=None, jobs=1):
3535
""" This function builds project. Project can be for example one test / UT """
3636
# Toolchain instance
3737
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, notify, macros)
3838
toolchain.VERBOSE = verbose
39+
toolchain.jobs = jobs
3940
toolchain.build_all = clean
4041
src_paths = [src_path] if type(src_path) != ListType else src_path
4142

@@ -90,7 +91,7 @@ def build_project(src_path, build_path, target, toolchain_name,
9091

9192
def build_library(src_paths, build_path, target, toolchain_name,
9293
dependencies_paths=None, options=None, name=None, clean=False,
93-
notify=None, verbose=False, macros=None, inc_dirs=None):
94+
notify=None, verbose=False, macros=None, inc_dirs=None, jobs=1):
9495
""" src_path: the path of the source directory
9596
build_path: the path of the build directory
9697
target: ['LPC1768', 'LPC11U24', 'LPC2368']
@@ -110,6 +111,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
110111
# Toolchain instance
111112
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
112113
toolchain.VERBOSE = verbose
114+
toolchain.jobs = jobs
113115
toolchain.build_all = clean
114116

115117
# The first path will give the name to the library
@@ -166,7 +168,7 @@ def build_lib(lib_id, target, toolchain, options=None, verbose=False, clean=Fals
166168

167169

168170
# We do have unique legacy conventions about how we build and package the mbed library
169-
def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=False, macros=None, notify=None):
171+
def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1):
170172
""" Function returns True is library was built and false if building was skipped """
171173
# Check toolchain support
172174
if toolchain_name not in target.supported_toolchains:
@@ -178,6 +180,7 @@ def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=F
178180
# Toolchain
179181
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
180182
toolchain.VERBOSE = verbose
183+
toolchain.jobs = jobs
181184
toolchain.build_all = clean
182185

183186
# Source and Build Paths
@@ -296,10 +299,11 @@ def get_target_supported_toolchains(target):
296299
return TARGET_MAP[target].supported_toolchains if target in TARGET_MAP else None
297300

298301

299-
def static_analysis_scan(target, toolchain_name, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, options=None, verbose=False, clean=False, macros=None, notify=None):
302+
def static_analysis_scan(target, toolchain_name, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1):
300303
# Toolchain
301304
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
302305
toolchain.VERBOSE = verbose
306+
toolchain.jobs = jobs
303307
toolchain.build_all = clean
304308

305309
# Source and Build Paths
@@ -420,7 +424,7 @@ def static_analysis_scan_lib(lib_id, target, toolchain, cppcheck_cmd, cppcheck_m
420424

421425
def static_analysis_scan_library(src_paths, build_path, target, toolchain_name, cppcheck_cmd, cppcheck_msg_format,
422426
dependencies_paths=None, options=None, name=None, clean=False,
423-
notify=None, verbose=False, macros=None):
427+
notify=None, verbose=False, macros=None, jobs=1):
424428
""" Function scans library (or just some set of sources/headers) for staticly detectable defects """
425429
if type(src_paths) != ListType:
426430
src_paths = [src_paths]
@@ -432,6 +436,7 @@ def static_analysis_scan_library(src_paths, build_path, target, toolchain_name,
432436
# Toolchain instance
433437
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
434438
toolchain.VERBOSE = verbose
439+
toolchain.jobs = jobs
435440

436441
# The first path will give the name to the library
437442
name = basename(src_paths[0])

workspace_tools/build_release.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
parser = OptionParser()
7373
parser.add_option('-o', '--official', dest="official_only", default=False, action="store_true",
7474
help="Build using only the official toolchain for each target")
75+
parser.add_option("-j", "--jobs", type="int", dest="jobs",
76+
default=1, help="Number of concurrent jobs (default 1). Use 0 for auto based on host machine's number of CPUs")
7577
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
7678
default=False, help="Verbose diagnostic output")
7779
options, args = parser.parse_args()
@@ -86,7 +88,7 @@
8688
for toolchain in toolchains:
8789
id = "%s::%s" % (target_name, toolchain)
8890
try:
89-
build_mbed_libs(TARGET_MAP[target_name], toolchain, verbose=options.verbose)
91+
build_mbed_libs(TARGET_MAP[target_name], toolchain, verbose=options.verbose, jobs=options.jobs)
9092
successes.append(id)
9193
except Exception, e:
9294
failures.append(id)

workspace_tools/make.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
help="The index of the desired test program: [0-%d]" % (len(TESTS)-1))
4848
parser.add_option("-n", dest="program_name",
4949
help="The name of the desired test program")
50+
parser.add_option("-j", "--jobs", type="int", dest="jobs",
51+
default=1, help="Number of concurrent jobs (default 1). Use 0 for auto based on host machine's number of CPUs")
5052
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
5153
default=False, help="Verbose diagnostic output")
5254
parser.add_option("-D", "", action="append", dest="macros",

0 commit comments

Comments
 (0)