Skip to content

Commit

Permalink
Fix issues of build_qt.py.
Browse files Browse the repository at this point in the history
* Copy include directories to the dest directory for macOS.
* Fix the issue that necessary files are not copied to the dest directory when `qt_dest_dir` is different from `qt_src_dir`.

#codehealth

PiperOrigin-RevId: 700937457
  • Loading branch information
hiroyuki-komatsu committed Nov 28, 2024
1 parent 7ee9a7f commit b81d09b
Showing 1 changed file with 30 additions and 27 deletions.
57 changes: 30 additions & 27 deletions src/build_tools/build_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,17 +671,23 @@ def build_on_mac(args: argparse.Namespace) -> None:
exec_command(configure_cmds, cwd=qt_src_dir, env=env, dryrun=args.dryrun)
exec_command(build_cmds, cwd=qt_src_dir, env=env, dryrun=args.dryrun)

if qt_src_dir == qt_dest_dir:
# No need to run 'install' command.
return
if qt_src_dir != qt_dest_dir:
if qt_dest_dir.exists():
if args.dryrun:
print(f'dryrun: delete {qt_dest_dir}')
else:
shutil.rmtree(qt_dest_dir)

if qt_dest_dir.exists():
if args.dryrun:
print(f'dryrun: delete {qt_dest_dir}')
else:
shutil.rmtree(qt_dest_dir)
exec_command(install_cmds, cwd=qt_src_dir, env=env, dryrun=args.dryrun)

exec_command(install_cmds, cwd=qt_src_dir, env=env, dryrun=args.dryrun)
# Copy include files.
for include in ['QtCore', 'QtGui', 'QtPrintSupport', 'QtWidgets']:
src = qt_src_dir.joinpath('include').joinpath(include)
dest = qt_dest_dir.joinpath('include').joinpath(include)
if args.dryrun:
print(f'dryrun: copy {src} => {dest}')
else:
shutil.copytree(src=src, dst=dest)

for tool in ['moc', 'rcc', 'uic']:
src = qt_host_dir.joinpath('libexec').joinpath(tool)
Expand Down Expand Up @@ -839,27 +845,24 @@ def build_on_windows(args: argparse.Namespace) -> None:

exec_command(build_cmds, cwd=qt_src_dir, env=env, dryrun=args.dryrun)

if qt_src_dir == qt_dest_dir:
# No need to run 'install' command.
return

if qt_dest_dir.exists():
if args.dryrun:
print(f'dryrun: shutil.rmtree({qt_dest_dir})')
else:
shutil.rmtree(qt_dest_dir)

exec_command(install_cmds, cwd=qt_src_dir, env=env, dryrun=args.dryrun)
if qt_src_dir != qt_dest_dir:
if qt_dest_dir.exists():
if args.dryrun:
print(f'dryrun: shutil.rmtree({qt_dest_dir})')
else:
shutil.rmtree(qt_dest_dir)

# When both '--debug' and '--release' are specified for Qt6, we need to run
# the command again with '--config debug' option to install debug DLLs.
if args.debug and args.release:
install_cmds += ['--config', 'debug']
exec_command(install_cmds, cwd=qt_src_dir, env=env, dryrun=args.dryrun)

for bool in ['moc.exe', 'rcc.exe', 'uic.exe']:
src = qt_host_dir.joinpath('bin').joinpath(bool)
dest = qt_dest_dir.joinpath('bin').joinpath(bool)
# When both '--debug' and '--release' are specified for Qt6, we need to run
# the command again with '--config debug' option to install debug DLLs.
if args.debug and args.release:
install_cmds += ['--config', 'debug']
exec_command(install_cmds, cwd=qt_src_dir, env=env, dryrun=args.dryrun)

for tool in ['moc.exe', 'rcc.exe', 'uic.exe']:
src = qt_host_dir.joinpath('bin').joinpath(tool)
dest = qt_dest_dir.joinpath('bin').joinpath(tool)
if args.dryrun:
print(f'dryrun: copy {src} => {dest}')
else:
Expand Down

0 comments on commit b81d09b

Please sign in to comment.