|
1 | 1 | #!/usr/bin/env python |
2 | 2 |
|
| 3 | +if __name__ != "__main__": |
| 4 | + raise SystemExit(f'Utility script "{__file__}" should not be used as a module!') |
| 5 | + |
| 6 | +import argparse |
3 | 7 | import os |
4 | 8 | import shutil |
5 | 9 | import subprocess |
|
10 | 14 |
|
11 | 15 | from misc.utility.color import Ansi, color_print |
12 | 16 |
|
| 17 | +parser = argparse.ArgumentParser(description="Install D3D12 dependencies for Windows platforms.") |
| 18 | +parser.add_argument( |
| 19 | + "--mingw_prefix", |
| 20 | + default=os.getenv("MINGW_PREFIX", ""), |
| 21 | + help="Explicitly specify a path containing the MinGW bin folder.", |
| 22 | +) |
| 23 | +args = parser.parse_args() |
| 24 | + |
13 | 25 | # Base Godot dependencies path |
14 | 26 | # If cross-compiling (no LOCALAPPDATA), we install in `bin` |
15 | 27 | deps_folder = os.getenv("LOCALAPPDATA") |
|
74 | 86 | # MinGW needs DLLs converted with dlltool. |
75 | 87 | # We rely on finding gendef/dlltool to detect if we have MinGW. |
76 | 88 | # Check existence of needed tools for generating mingw library. |
77 | | -gendef = shutil.which("gendef") or "" |
78 | | -dlltool = shutil.which("dlltool") or "" |
79 | | -if dlltool == "": |
80 | | - dlltool = shutil.which("x86_64-w64-mingw32-dlltool") or "" |
| 89 | +pathstr = os.environ.get("PATH", "") |
| 90 | +if args.mingw_prefix: |
| 91 | + pathstr = os.path.join(args.mingw_prefix, "bin") + os.pathsep + pathstr |
| 92 | +gendef = shutil.which("x86_64-w64-mingw32-gendef", path=pathstr) or shutil.which("gendef", path=pathstr) or "" |
| 93 | +dlltool = shutil.which("x86_64-w64-mingw32-dlltool", path=pathstr) or shutil.which("dlltool", path=pathstr) or "" |
81 | 94 | has_mingw = gendef != "" and dlltool != "" |
82 | 95 |
|
83 | 96 | color_print(f"{Ansi.BOLD}[2/3] WinPixEventRuntime") |
|
107 | 120 | ) |
108 | 121 | os.chdir(cwd) |
109 | 122 | else: |
110 | | - print("MinGW wasn't found, so only MSVC support is provided for WinPixEventRuntime.") |
| 123 | + print( |
| 124 | + 'MinGW support requires "dlltool" and "gendef" dependencies, so only MSVC support is provided for WinPixEventRuntime. Did you forget to provide a `--mingw_prefix`?' |
| 125 | + ) |
111 | 126 | print(f"WinPixEventRuntime {pix_version} installed successfully.\n") |
112 | 127 |
|
113 | 128 | # DirectX 12 Agility SDK |
|
0 commit comments