| 1 |
#!/usr/bin/env python |
| 2 |
# License: GPLv3 Copyright: 2023, Kovid Goyal <kovid at kovidgoyal.net> |
| 3 |
|
| 4 |
|
| 5 |
import os |
| 6 |
import runpy |
| 7 |
import shutil |
| 8 |
|
| 9 |
from setup import Command |
| 10 |
|
| 11 |
|
| 12 |
class XWin(Command): |
| 13 |
description = 'Install the Windows headers for cross compilation' |
| 14 |
|
| 15 |
def run(self, opts): |
| 16 |
if not shutil.which('msiextract'): |
| 17 |
raise SystemExit('No msiextract found in PATH you may need to install msitools') |
| 18 |
base = os.path.dirname(self.SRC) |
| 19 |
m = runpy.run_path(os.path.join(base, 'setup', 'wincross.py')) |
| 20 |
cache_dir = os.path.join(base, '.build-cache', 'xwin') |
| 21 |
if os.path.exists(cache_dir): |
| 22 |
shutil.rmtree(cache_dir) |
| 23 |
os.makedirs(cache_dir) |
| 24 |
m['main'](['--dest', cache_dir]) |
| 25 |
for x in os.listdir(cache_dir): |
| 26 |
if x != 'root': |
| 27 |
shutil.rmtree(os.path.join(cache_dir, x)) |