From 39f5192c99bf321aa32dd3cdf747c62f9abf4d38 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 27 Jan 2023 13:05:34 +0530 Subject: [PATCH] Use cross compilation for extdev --- setup/installers.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/setup/installers.py b/setup/installers.py index ba64955633..6d63edaf46 100644 --- a/setup/installers.py +++ b/setup/installers.py @@ -238,13 +238,15 @@ class ExtDev(Command): def run(self, opts): which, ext = opts.cli_args[:2] cmd = opts.cli_args[2:] or ['calibre-debug', '--test-build'] - bitness = '64' if which == 'windows' else '' - ext_dir = build_only(which, bitness, ext) if which == 'windows': + subprocess.check_call([sys.executable, 'setup.py', 'build', '--cross-compile-extensions=windows', '--only=winspeech']) + src = 'src/calibre/plugins/winspeech.cross-windows-x64.pyd' host = 'win' path = '/cygdrive/c/Program Files/Calibre2/app/bin/{}.pyd' bin_dir = '/cygdrive/c/Program Files/Calibre2' elif which == 'macos': + ext_dir = build_only(which, '', ext) + src = os.path.join(ext_dir, os.path.basename(path)) print( "\n\n\x1b[33;1mWARNING: This does not work on macOS, unless you use un-signed builds with ", ' ./update-on-ox develop\x1b[m', @@ -252,6 +254,8 @@ class ExtDev(Command): host = 'ox' path = '/Applications/calibre.app/Contents/Frameworks/plugins/{}.so' bin_dir = '/Applications/calibre.app/Contents/MacOS' + else: + raise SystemExit(f'Unknown OS {which}') control_path = os.path.expanduser('~/.ssh/extdev-master-%C') if subprocess.Popen([ 'ssh', '-o', 'ControlMaster=auto', '-o', 'ControlPath=' + control_path, '-o', 'ControlPersist=yes', host, @@ -260,7 +264,6 @@ class ExtDev(Command): raise SystemExit(1) try: path = path.format(ext) - src = os.path.join(ext_dir, os.path.basename(path)) subprocess.check_call(['ssh', '-S', control_path, host, 'chmod', '+wx', f'"{path}"']) with open(src, 'rb') as f: p = subprocess.Popen(['ssh', '-S', control_path, host, f'cat - > "{path}"'], stdin=subprocess.PIPE)