Skip to content

Commit

Permalink
Change directory when building FFmpeg on Windows
Browse files Browse the repository at this point in the history
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
  • Loading branch information
martinburchell committed Dec 11, 2023
1 parent 8636ca2 commit 31be9c3
Showing 1 changed file with 32 additions and 17 deletions.
49 changes: 32 additions & 17 deletions tablet_qt/tools/build_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -4286,30 +4295,36 @@ 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)
run(make_args, env)
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
# =============================================================================
Expand Down

0 comments on commit 31be9c3

Please sign in to comment.