Skip to content

Commit 3e435ce

Browse files
authored
Merge pull request #10929 from lRespublica/multithread
bootstrap/bootstrap.py: Added support for multithreaded builds
2 parents c2d8353 + e01c936 commit 3e435ce

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

bootstrap/bootstrap.py

+21-4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ class PackageSource(Enum):
8989
, "cabal-install-solver"
9090
, "cabal-install" ]
9191

92+
# Value passed to setup build -j {jobs_amount}
93+
# 1 is not set by default.
94+
# For the default look up the parser.set_default in main() function
95+
jobs_amount = 1
96+
9297
class Compiler:
9398
def __init__(self, ghc_path: Path):
9499
if not ghc_path.is_file():
@@ -206,11 +211,15 @@ def install_sdist(dist_dir: Path, sdist_dir: Path, ghc: Compiler, flags: List[st
206211
setup_dist_dir = dist_dir / 'setup'
207212
setup = setup_dist_dir / 'Setup'
208213

209-
build_args = [
210-
f'--builddir={dist_dir}',
214+
build_dir = [
215+
f'--builddir={dist_dir}'
216+
]
217+
218+
build_args = build_dir + [
219+
f'-j{jobs_amount}'
211220
]
212221

213-
configure_args = build_args + [
222+
configure_args = build_dir + [
214223
f'--package-db={PKG_DB.resolve()}',
215224
f'--prefix={prefix}',
216225
f'--bindir={BINDIR.resolve()}',
@@ -232,7 +241,7 @@ def check_call(args: List[str]) -> None:
232241
check_call([str(ghc.ghc_path), '--make', '-package-env=-', '-i', f'-odir={setup_dist_dir}', f'-hidir={setup_dist_dir}', '-o', setup, 'Setup'])
233242
check_call([setup, 'configure'] + configure_args)
234243
check_call([setup, 'build'] + build_args)
235-
check_call([setup, 'install'] + build_args)
244+
check_call([setup, 'install'] + build_dir)
236245

237246
def hash_file(h, f: BinaryIO) -> SHA256Hash:
238247
while True:
@@ -376,10 +385,15 @@ def main() -> None:
376385
help='path to GHC')
377386
parser.add_argument('-s', '--bootstrap-sources', type=Path,
378387
help='path to prefetched bootstrap sources archive')
388+
379389
parser.add_argument('--archive', dest='want_archive', action='store_true')
380390
parser.add_argument('--no-archive', dest='want_archive', action='store_false')
381391
parser.set_defaults(want_archive=True)
382392

393+
parser.add_argument('-j', type=int, metavar="NUM",
394+
help='specify the number of jobs (commands) to run simultaneously')
395+
parser.set_defaults(j=1)
396+
383397
subparsers = parser.add_subparsers(dest="command")
384398

385399
parser_fetch = subparsers.add_parser('build', help='build cabal-install (default)')
@@ -389,6 +403,9 @@ def main() -> None:
389403

390404
args = parser.parse_args()
391405

406+
global jobs_amount
407+
jobs_amount = args.j
408+
392409
print(dedent("""
393410
DO NOT use this script if you have another recent cabal-install available.
394411
This script is intended only for bootstrapping cabal-install on new

0 commit comments

Comments
 (0)