Skip to content

cpp-packaging.yml: install patch.exe via choco on Windows #1005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/cpp-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
43 changes: 43 additions & 0 deletions scripts/gha/setup_patch_from_git_windows.py
Original file line number Diff line number Diff line change
@@ -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)
Binary file added scripts/gha/tools/windows/bin/patch.exe
Binary file not shown.