Use cross compilation for extdev

This commit is contained in:
Kovid Goyal 2023-01-27 13:05:34 +05:30
parent ef9e669ef9
commit 39f5192c99
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -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)