From bf6db247a2710a5c641bc73a60ff97550d929eed Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 26 Jan 2023 20:33:49 +0530 Subject: [PATCH] Command to automatically install the Windows SDK --- bypy/rsync.conf | 2 +- setup/commands.py | 6 +++++- setup/xwin.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 setup/xwin.py diff --git a/bypy/rsync.conf b/bypy/rsync.conf index 8625f7dcaa..64bd448c51 100644 --- a/bypy/rsync.conf +++ b/bypy/rsync.conf @@ -1 +1 @@ -to_vm_excludes '/imgsrc /build /dist /manual /format_docs /translations /.build-cache /tags /Changelog* *.so *.pyd' +to_vm_excludes '/imgsrc /build /dist /manual /format_docs /translations /.build-cache /.cache /tags /Changelog* *.so *.pyd' diff --git a/setup/commands.py b/setup/commands.py index fe414ca0a7..8cc1b1b6eb 100644 --- a/setup/commands.py +++ b/setup/commands.py @@ -20,7 +20,7 @@ __all__ = [ 'upload_user_manual', 'upload_demo', 'reupload', 'stage1', 'stage2', 'stage3', 'stage4', 'stage5', 'publish', 'publish_betas', 'linux', 'linux64', 'linuxarm64', 'win', 'win64', 'osx', 'build_dep', - 'export_packages', 'hyphenation', 'liberation_fonts', 'stylelint' + 'export_packages', 'hyphenation', 'liberation_fonts', 'stylelint', 'xwin', ] from setup.installers import Linux, Win, OSX, Linux64, LinuxArm64, Win64, ExtDev, BuildDep, ExportPackages @@ -101,6 +101,10 @@ upload_to_server = UploadToServer() upload_installers = UploadInstallers() reupload = ReUpload() + +from setup.xwin import XWin +xwin = XWin() + commands = {} for x in __all__: commands[x] = locals()[x] diff --git a/setup/xwin.py b/setup/xwin.py new file mode 100644 index 0000000000..bb140938c0 --- /dev/null +++ b/setup/xwin.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# License: GPLv3 Copyright: 2023, Kovid Goyal + + +import os +import shutil + +from setup import Command + + +class XWin(Command): + description = 'Install the Windows headers for cross compilation' + + def run(self, opts): + import subprocess + cache_dir = '.build-cache/xwin' + output_dir = cache_dir + '/splat' + cmd = f'xwin --include-atl --accept-license --cache-dir {cache_dir}'.split() + for step in 'download unpack'.split(): + try: + subprocess.check_call(cmd + [step]) + except FileNotFoundError: + raise SystemExit('xwin not found install it from https://github.com/Jake-Shadle/xwin/releases') + subprocess.check_call(cmd + ['splat', '--output', output_dir]) + base = f'{output_dir}/sdk/include/um' + for casefix in 'Ole2.h OleCtl.h OAIdl.h OCIdl.h'.split(): + os.link(f'{base}/{casefix.lower()}', f'{base}/{casefix}') + shutil.rmtree(f'{cache_dir}/dl') + shutil.rmtree(f'{cache_dir}/unpack')