Skip to content

Commit

Permalink
ctypesgen: set compile-libdirs if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Sep 29, 2023
1 parent a8af264 commit 538797f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setupsrc/pypdfium2_setup/build_pdfium.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def pack(src_libpath, v_libpdfium, destname=None):
update_version(v_libpdfium)

include_dir = PDFiumDir / "public"
call_ctypesgen(OutputDir, include_dir)
call_ctypesgen(OutputDir, include_dir, pl_name=Host.platform)


def get_tool(name):
Expand Down
10 changes: 8 additions & 2 deletions setupsrc/pypdfium2_setup/packaging_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,21 @@ def purge_pdfium_versions():
))


def call_ctypesgen(target_dir, include_dir, use_v8xfa=False, guard_symbols=False):
def call_ctypesgen(target_dir, include_dir, pl_name, use_v8xfa=False, guard_symbols=False):

# The commands below are tailored to our fork of ctypesgen, so make sure we have that
# Import ctypesgen only in this function so it does not have to be available for other setup tasks
import ctypesgen
assert getattr(ctypesgen, "PYPDFIUM2_SPECIFIC", False)

bindings = target_dir / BindingsFileName
args = ["ctypesgen", "--library", "pdfium", "--runtime-libdirs", ".", "--no-srcinfo", f"--strip-build-path={include_dir}"]

args = ["ctypesgen", f"--strip-build-path={include_dir}", "--no-srcinfo", "--library", "pdfium", "--runtime-libdirs", "."]
if pl_name == Host.platform:
# assuming the binary already lies in target_dir
args += ["--compile-libdirs", target_dir]
else:
args += ["--no-load-library"]
if not guard_symbols:
args += ["--no-symbol-guards"]
if use_v8xfa:
Expand Down
4 changes: 2 additions & 2 deletions setupsrc/pypdfium2_setup/update_pdfium.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ def generate_bindings(archives, version, full_version, use_v8, ctypesgen_kws):
else:
assert not v8_file.exists()

call_ctypesgen(pl_dir, build_dir/"include", use_v8xfa=use_v8, **ctypesgen_kws)
call_ctypesgen(pl_dir, build_dir/"include", pl_name=pl_name, use_v8xfa=use_v8, **ctypesgen_kws)
shutil.rmtree(build_dir)


def main(platforms, version=None, robust=False, max_workers=None, use_v8=False, ctypesgen_kws=dict()):
def main(platforms, version=None, robust=False, max_workers=None, use_v8=False, ctypesgen_kws={}):

if not version:
version = get_latest_version()
Expand Down

0 comments on commit 538797f

Please sign in to comment.