diff --git a/.github/workflows/cpp-packaging.yml b/.github/workflows/cpp-packaging.yml index 9cc495e8aa..b9e0282cc5 100644 --- a/.github/workflows/cpp-packaging.yml +++ b/.github/workflows/cpp-packaging.yml @@ -425,6 +425,13 @@ jobs: fi echo "VERBOSE_FLAG=${verbose_flag}" >> $GITHUB_ENV + - name: Use patch.exe from Git (windows) + if: startsWith(matrix.os, 'windows') + shell: bash + run: | + python scripts/gha/setup_patch_from_git_windows.py >> $GITHUB_PATH + echo "PATH is now: $PATH" + # Run the build in the host OS default shell since Windows can't handle long path names in bash. - name: Build desktop SDK run: | diff --git a/scripts/gha/setup_patch_from_git_windows.py b/scripts/gha/setup_patch_from_git_windows.py new file mode 100644 index 0000000000..1c958b7e19 --- /dev/null +++ b/scripts/gha/setup_patch_from_git_windows.py @@ -0,0 +1,43 @@ +import os +import pathlib +import shutil +import tempfile + +from absl import app +from absl import logging + +def main(argv): + if len(argv) > 1: + raise app.UsageError(f"unexpected argument: {argv[1]}") + + logging.info("Searching for git.exe") + git_executable_path_str = shutil.which("git") + if not git_executable_path_str: + raise Exception("git not found in the PATH") + git_executable = pathlib.Path(git_executable_path_str) + logging.info("Found: %s", git_executable) + + logging.info("Searching for patch.exe") + patch_executable = git_executable.parent / "patch.exe" + if not patch_executable.exists(): + raise Exception(f"file not found: {patch_executable}") + logging.info("Found: %s", patch_executable) + + logging.info("Searching for msys-2.0.dll") + msys_dll = patch_executable.parent / "msys-2.0.dll" + if not msys_dll.exists(): + raise Exception(f"file not found: {msys_dll}") + logging.info("Found %s", msys_dll) + + temp_dir = pathlib.Path(tempfile.mkdtemp("patch")) + logging.info("Created temporary directory: %s", temp_dir) + logging.info("Copying %s to %s", patch_executable, temp_dir) + shutil.copy2(patch_executable, temp_dir) + logging.info("Copying %s to %s", msys_dll, temp_dir) + shutil.copy2(msys_dll, temp_dir) + + print(str(temp_dir)) + + +if __name__ == "__main__": + app.run(main) diff --git a/scripts/gha/tools/windows/bin/patch.exe b/scripts/gha/tools/windows/bin/patch.exe new file mode 100644 index 0000000000..1b22a07288 Binary files /dev/null and b/scripts/gha/tools/windows/bin/patch.exe differ