Skip to content

Commit c854391

Browse files
committed
Added a -j/--parallelism flag to build.py to control the number of build threads
1 parent a6d13f2 commit c854391

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

build.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
parser.add_option('-r', '--revision', dest='revision', action="store", help='Checkout a specific revision of the target', default=False)
4646
parser.add_option('-d', '--dev', dest='dev', action="store_true", help='enable developer mode (does not use target-locked.json)', default=False)
4747
parser.add_option('-g', '--generate-docs', dest='generate_docs', action="store_true", help='generate documentation for the current target', default=False)
48+
parser.add_option('-j', '--parallelism', dest='parallelism', action="store", help='Set the number of parallel threads to build with, if supported', default=10)
4849

4950
(options, args) = parser.parse_args()
5051

@@ -139,7 +140,7 @@
139140
generate_docs()
140141
exit(0)
141142

142-
build(options.clean, verbose=options.verbose)
143+
build(options.clean, verbose=options.verbose, parallelism=options.parallelism)
143144
exit(0)
144145

145146
for json_obj in test_json:
@@ -166,4 +167,4 @@
166167
with open("../codal.json", 'w') as codal_json:
167168
json.dump(config, codal_json, indent=4)
168169

169-
build(True, True)
170+
build(True, True, options.parallelism)

utils/python/codal_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def system(cmd):
1515
if os.system(cmd) != 0:
1616
sys.exit(1)
1717

18-
def build(clean, verbose = False):
18+
def build(clean, verbose = False, parallelism = 10):
1919
if platform.system() == "Windows":
2020
# configure
2121
system("cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -G \"Ninja\"")
@@ -25,9 +25,9 @@ def build(clean, verbose = False):
2525

2626
# build
2727
if verbose:
28-
system("ninja --verbose")
28+
system(f"ninja -j {parallelism} --verbose")
2929
else:
30-
system("ninja")
30+
system(f"ninja -j {parallelism}")
3131
else:
3232
# configure
3333
system("cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -G \"Unix Makefiles\"")
@@ -37,9 +37,9 @@ def build(clean, verbose = False):
3737

3838
# build
3939
if verbose:
40-
system("make -j 10 VERBOSE=1")
40+
system(f"make -j {parallelism} VERBOSE=1")
4141
else:
42-
system("make -j 10")
42+
system(f"make -j {parallelism}")
4343

4444
def read_json(fn):
4545
json_file = ""

0 commit comments

Comments
 (0)