Skip to content

Commit

Permalink
Pass through ctypesgen executable as well
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Aug 26, 2022
1 parent 46c1f97 commit bf06496
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
7 changes: 4 additions & 3 deletions setupsrc/pl_setup/build_pdfium.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def find_lib(srcname=None, directory=PDFiumBuildDir):
return libpath


def pack(src_libpath, destname=None):
def pack(Ctypesgen, src_libpath, destname=None):

if os.path.isdir(OutputDir):
shutil.rmtree(OutputDir)
Expand All @@ -188,7 +188,7 @@ def pack(src_libpath, destname=None):
include_dir = join(OutputDir, "include")
shutil.copytree(join(PDFiumDir, "public"), include_dir)

call_ctypesgen(OutputDir, include_dir)
call_ctypesgen(Ctypesgen, OutputDir, include_dir)
shutil.rmtree(include_dir)


Expand Down Expand Up @@ -226,6 +226,7 @@ def main(
):

Git = shutil.which("git")
Ctypesgen = shutil.which("ctypesgen")

if b_revision is None:
b_revision = "main"
Expand Down Expand Up @@ -258,7 +259,7 @@ def main(
configure(GN, config_str)
build(Ninja, b_target)
libpath = find_lib(b_srcname)
pack(libpath, b_destname)
pack(Ctypesgen, libpath, b_destname)


def parse_args(argv):
Expand Down
4 changes: 2 additions & 2 deletions setupsrc/pl_setup/packaging_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ def get_latest_version(Git):
return int( tag.split("/")[-1] )


def call_ctypesgen(platform_dir, include_dir):
def call_ctypesgen(Ctypesgen, platform_dir, include_dir):

bindings_file = join(platform_dir, "_pypdfium.py")

ctypesgen_cmd = [shutil.which("ctypesgen"), "--library", "pdfium", "--strip-build-path", platform_dir, "-L", "."] + sorted(glob( join(include_dir, "*.h") )) + ["-o", bindings_file]
ctypesgen_cmd = [Ctypesgen, "--library", "pdfium", "--strip-build-path", platform_dir, "-L", "."] + sorted(glob( join(include_dir, "*.h") )) + ["-o", bindings_file]
run_cmd(ctypesgen_cmd, cwd=platform_dir)

with open(bindings_file, "r") as file_reader:
Expand Down
7 changes: 4 additions & 3 deletions setupsrc/pl_setup/update_pdfium.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def unpack_archives(archives):
os.remove(file)


def generate_bindings(archives):
def generate_bindings(Ctypesgen, archives):

for platform_dir in archives.keys():

Expand All @@ -112,7 +112,7 @@ def generate_bindings(archives):

shutil.move(join(bin_dir, items[0]), join(platform_dir, target_name))

call_ctypesgen(platform_dir, join(build_dir, "include"))
call_ctypesgen(Ctypesgen, platform_dir, join(build_dir, "include"))
shutil.rmtree(build_dir)


Expand All @@ -135,6 +135,7 @@ def get_download_files(platforms):
def main(platforms):

Git = shutil.which("git")
Ctypesgen = shutil.which("ctypesgen")

download_files = get_download_files(platforms)

Expand All @@ -144,7 +145,7 @@ def main(platforms):

archives = download_releases(latest, download_files)
unpack_archives(archives)
generate_bindings(archives)
generate_bindings(Ctypesgen, archives)


def parse_args(argv):
Expand Down

0 comments on commit bf06496

Please sign in to comment.