Skip to content

Commit 18661e3

Browse files
yukawahiroyuki-komatsu
authored andcommitted
Clean up build command handling in build_qt.py
As a preparation for Qt6 migration (#775), this commit aims to clean up build command handling in build_qt.py. This is a mechanical cleanup. There must be no change in the artifacts. #codehealth PiperOrigin-RevId: 551468250
1 parent 941c562 commit 18661e3

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

src/build_tools/build_qt.py

+22-18
Original file line numberDiff line numberDiff line change
@@ -305,25 +305,26 @@ def build_on_mac(args: argparse.Namespace) -> None:
305305
if not qt_src_dir.exists():
306306
raise FileNotFoundError('Could not find qt_src_dir=%s' % qt_src_dir)
307307

308-
jobs = os.cpu_count() * 2
309-
os.environ['MAKEFLAGS'] = '--jobs=%s' % jobs
310308
os.chdir(qt_src_dir)
311309

312-
commands = ['./configure'] + make_configure_options(args)
310+
configure_cmds = ['./configure'] + make_configure_options(args)
311+
build_cmds = ['make', '--jobs=%s' % (os.cpu_count() * 2)]
312+
install_cmds = ['make', 'install']
313313
if args.dryrun:
314-
print(f'dryrun: run_or_die({commands})')
315-
print('dryrun: make')
314+
print(f'dryrun: run_or_die({configure_cmds})')
315+
print('dryrun: run_or_die({build_cmds})')
316316
if qt_src_dir != qt_dest_dir:
317317
if qt_dest_dir.exists():
318318
print(f'dryrun: delete {qt_dest_dir}')
319-
print('dryrun: make install')
319+
print('dryrun: run_or_die({install_cmds})')
320320
else:
321-
run_or_die(commands)
322-
run_or_die(['make'])
321+
run_or_die(configure_cmds)
322+
323+
run_or_die(build_cmds)
323324
if qt_src_dir != qt_dest_dir:
324325
if qt_dest_dir.exists():
325326
shutil.rmtree(qt_dest_dir)
326-
run_or_die(['make', 'install'])
327+
run_or_die(install_cmds)
327328

328329

329330
def get_vcvarsall(path_hint: Union[str, None] = None) -> pathlib.Path:
@@ -437,12 +438,13 @@ def build_on_windows(args: argparse.Namespace) -> None:
437438

438439
options = make_configure_options(args)
439440
configs = ' '.join(options)
440-
command = f'configure.bat {configs}'
441+
configure_cmds = f'configure.bat {configs}'
441442
if args.dryrun:
442-
print(f"dryrun: subprocess.run('{command}', shell=True, check=True,"
443-
f' cwd={qt_src_dir}, env={env})')
443+
print(f"dryrun: subprocess.run('{configure_cmds}', shell=True, check=True,"
444+
f' cwd={configure_cmds}, env={env})')
444445
else:
445-
subprocess.run(command, shell=True, check=True, cwd=qt_src_dir, env=env)
446+
subprocess.run(configure_cmds, shell=True, check=True, cwd=qt_src_dir,
447+
env=env)
446448

447449
# In order not to expose internal build path, replace paths in qconfig.cpp,
448450
# which have been embedded by configure.exe based on the build directory.
@@ -454,20 +456,22 @@ def build_on_windows(args: argparse.Namespace) -> None:
454456
args.dryrun)
455457

456458
jom = qt_src_dir.joinpath('jom.exe')
459+
build_cmds = [str(jom)]
460+
install_cmds = [str(jom), 'install']
457461
if args.dryrun:
458-
print(f'dryrun: subprocess.run(str({jom}), shell=True, check=True,'
462+
print(f'dryrun: subprocess.run({build_cmds}, shell=True, check=True,'
459463
f' cwd={qt_src_dir}, env={env})')
460464
if qt_src_dir != qt_dest_dir:
461465
if qt_dest_dir.exists():
462466
print(f'dryrun: delete {qt_dest_dir}')
463-
print(f"dryrun: subprocess.run([str({jom}), 'install'], shell=True,"
464-
f" check=True, cwd={qt_src_dir}, env={env})")
467+
print(f'dryrun: subprocess.run({install_cmds}, shell=True,'
468+
f' check=True, cwd={qt_src_dir}, env={env})')
465469
else:
466-
subprocess.run(str(jom), shell=True, check=True, cwd=qt_src_dir, env=env)
470+
subprocess.run(build_cmds, shell=True, check=True, cwd=qt_src_dir, env=env)
467471
if qt_src_dir != qt_dest_dir:
468472
if qt_dest_dir.exists():
469473
shutil.rmtree(qt_dest_dir)
470-
subprocess.run([str(jom), 'install'], shell=True, check=True,
474+
subprocess.run(install_cmds, shell=True, check=True,
471475
cwd=qt_src_dir, env=env)
472476

473477

0 commit comments

Comments
 (0)