mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Allow extdev to work with local libraries
This commit is contained in:
parent
1a751bc1c2
commit
c7907e2081
@ -326,6 +326,8 @@ def init_env(debug=False, sanitize=False, compiling_for='native'):
|
|||||||
cflags.append(f'{splat}/{I}')
|
cflags.append(f'{splat}/{I}')
|
||||||
for L in 'sdk/lib/um crt/lib sdk/lib/ucrt'.split():
|
for L in 'sdk/lib/um crt/lib sdk/lib/ucrt'.split():
|
||||||
ldflags.append(f'/libpath:{splat}/{L}')
|
ldflags.append(f'/libpath:{splat}/{L}')
|
||||||
|
for L in os.environ.get('CROSS_LIBDIRS', '').split(os.pathsep):
|
||||||
|
ldflags.append(f'/libpath:{L}')
|
||||||
else:
|
else:
|
||||||
for p in win_inc:
|
for p in win_inc:
|
||||||
cflags.append('-I'+p)
|
cflags.append('-I'+p)
|
||||||
|
@ -238,10 +238,15 @@ class ExtDev(Command):
|
|||||||
|
|
||||||
description = 'Develop a single native extension conveniently'
|
description = 'Develop a single native extension conveniently'
|
||||||
|
|
||||||
|
def add_options(self, parser):
|
||||||
|
parser.add_option('-L', '--libdir', default=[], action='append',
|
||||||
|
help='Path to directory from which to load extra libraries, relative to pkg directory of cross compile target.')
|
||||||
|
|
||||||
def run(self, opts):
|
def run(self, opts):
|
||||||
which, ext = opts.cli_args[:2]
|
which, ext = opts.cli_args[:2]
|
||||||
cmd = opts.cli_args[2:] or ['calibre-debug', '--test-build']
|
cmd = opts.cli_args[2:] or ['calibre-debug', '--test-build']
|
||||||
if which == 'windows':
|
if which == 'windows':
|
||||||
|
os.environ['CROSS_LIBDIRS'] = os.pathsep.join(f'bypy/b/windows/64/pkg/{x}' for x in opts.libdir)
|
||||||
cp = subprocess.run([sys.executable, 'setup.py', 'build', '--cross-compile-extensions=windows', f'--only={ext}'])
|
cp = subprocess.run([sys.executable, 'setup.py', 'build', '--cross-compile-extensions=windows', f'--only={ext}'])
|
||||||
if cp.returncode != 0:
|
if cp.returncode != 0:
|
||||||
raise SystemExit(cp.returncode)
|
raise SystemExit(cp.returncode)
|
||||||
@ -250,6 +255,7 @@ class ExtDev(Command):
|
|||||||
path = '/cygdrive/c/Program Files/Calibre2/app/bin/{}.pyd'
|
path = '/cygdrive/c/Program Files/Calibre2/app/bin/{}.pyd'
|
||||||
bin_dir = '/cygdrive/c/Program Files/Calibre2'
|
bin_dir = '/cygdrive/c/Program Files/Calibre2'
|
||||||
elif which == 'macos':
|
elif which == 'macos':
|
||||||
|
os.environ['CROSS_LIBDIRS'] = os.pathsep.join(f'bypy/b/macos/pkg/{x}' for x in opts.libdir)
|
||||||
ext_dir = build_only(which, '', ext)
|
ext_dir = build_only(which, '', ext)
|
||||||
src = os.path.join(ext_dir, f'{ext}.so')
|
src = os.path.join(ext_dir, f'{ext}.so')
|
||||||
print(
|
print(
|
||||||
@ -269,13 +275,13 @@ class ExtDev(Command):
|
|||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
try:
|
try:
|
||||||
path = path.format(ext)
|
path = path.format(ext)
|
||||||
subprocess.check_call(['ssh', '-S', control_path, host, 'chmod', '+wx', f'"{path}"'])
|
subprocess.call(['ssh', '-S', control_path, host, 'chmod', '+wx', f'"{path}"'])
|
||||||
with open(src, 'rb') as f:
|
with open(src, 'rb') as f:
|
||||||
p = subprocess.Popen(['ssh', '-S', control_path, host, f'cat - > "{path}"'], stdin=subprocess.PIPE)
|
p = subprocess.Popen(['ssh', '-S', control_path, host, f'cat - > "{path}"'], stdin=subprocess.PIPE)
|
||||||
p.communicate(f.read())
|
p.communicate(f.read())
|
||||||
if p.wait() != 0:
|
if p.wait() != 0:
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
subprocess.check_call(['ssh', '-S', control_path, host, './update-calibre'])
|
subprocess.check_call(['ssh', '-S', control_path, host, 'bin/update-calibre'])
|
||||||
enc = json.dumps(cmd)
|
enc = json.dumps(cmd)
|
||||||
if not isinstance(enc, bytes):
|
if not isinstance(enc, bytes):
|
||||||
enc = enc.encode('utf-8')
|
enc = enc.encode('utf-8')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user