From 31be9c3894134de081c176d930ccb9372e9a5113 Mon Sep 17 00:00:00 2001 From: Martin Burchell Date: Mon, 11 Dec 2023 14:25:28 +0000 Subject: [PATCH] Change directory when building FFmpeg on Windows When building FFmpeg from bash on Windows, we need to make sure we're in the build directory for the configure, make and make install commands. The pushd statements are ineffective here as they will be lost once we're in the bash shell --- tablet_qt/tools/build_qt.py | 49 ++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/tablet_qt/tools/build_qt.py b/tablet_qt/tools/build_qt.py index eab39d884..5adbad837 100755 --- a/tablet_qt/tools/build_qt.py +++ b/tablet_qt/tools/build_qt.py @@ -4267,6 +4267,15 @@ def build_ffmpeg(cfg: Config, target_platform: Platform) -> None: ] ) + make = MAKE + + make_args = [make] + make_install_args = [ + make, + "install", + f"DESTDIR={installdir}", + ] + if target_platform.windows: # We use MSYS/bash because that's what Qt do in their Continuous # Integration scripts and we know they work. (choco install msys2) @@ -4286,23 +4295,9 @@ def build_ffmpeg(cfg: Config, target_platform: Platform) -> None: # "cygheap base mismatch detected" fail("Ensure msys64\\usr\\bin is before cygwin\\bin in your PATH") - msys_root = Path(shutil.which(MSYS2)).parent.absolute() - bash = join(msys_root, "usr", "bin", "bash") - configure_command = " ".join(config_args) - config_args = [ - bash, - "-lc", - f"{configure_command}", - ] - - make = MAKE - - make_args = [make] - make_install_args = [ - make, - "install", - f"DESTDIR={installdir}", - ] + config_args = bash_command_args(workdir, config_args) + make_args = bash_command_args(workdir, make_args) + make_install_args = bash_command_args(workdir, make_install_args) with pushd(workdir): run(config_args, env) @@ -4310,6 +4305,26 @@ def build_ffmpeg(cfg: Config, target_platform: Platform) -> None: run(make_install_args, env) +def bash_command_args(workdir: str, command_args: List[str]) -> List[str]: + """ + For the Windows FFmpeg we need to build within bash so all of the + configure, make and make install command arguments need to be converted + appropriately. + """ + msys_root = Path(shutil.which(MSYS2)).parent.absolute() + bash_workdir = workdir.replace("C:", "/c") + bash_workdir = bash_workdir.replace("\\", "/") + bash = join(msys_root, "usr", "bin", "bash") + command = " ".join(command_args) + bash_command_args = [ + bash, + "-lc", + f"cd {bash_workdir} && {command}", + ] + + return bash_command_args + + # ============================================================================= # Eigen # =============================================================================