Merge pull request #1091 from anthrotype/fix-gen-def-py

gen-def.py: pass headers as arguments so that msys2 can convert posix paths
This commit is contained in:
Cosimo Lupo 2018-07-09 20:24:22 +02:00 committed by GitHub
commit bf9e9676dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 9 deletions

View File

@ -834,9 +834,8 @@ set_target_properties(hb-ot-tag PROPERTIES COMPILE_FLAGS "-DMAIN")
if (UNIX OR MINGW) if (UNIX OR MINGW)
if (BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)
# generate harfbuzz.def after build completion # generate harfbuzz.def after build completion
string(REPLACE ";" " " space_separated_headers "${project_headers}")
add_custom_command(TARGET harfbuzz POST_BUILD add_custom_command(TARGET harfbuzz POST_BUILD
COMMAND ${CMAKE_COMMAND} -E env "headers=${space_separated_headers}" python ${PROJECT_SOURCE_DIR}/src/gen-def.py ${PROJECT_BINARY_DIR}/harfbuzz.def COMMAND "${PYTHON_EXECUTABLE}" ${PROJECT_SOURCE_DIR}/src/gen-def.py ${PROJECT_BINARY_DIR}/harfbuzz.def ${project_headers}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src) WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src)
add_test(NAME check-static-inits.sh add_test(NAME check-static-inits.sh

View File

@ -277,13 +277,13 @@ endif
check: $(DEF_FILES) # For check-symbols.sh check: $(DEF_FILES) # For check-symbols.sh
CLEANFILES += $(DEF_FILES) CLEANFILES += $(DEF_FILES)
harfbuzz.def: $(HBHEADERS) $(HBNODISTHEADERS) harfbuzz.def: $(HBHEADERS) $(HBNODISTHEADERS)
$(AM_V_GEN) headers="$^" $(srcdir)/gen-def.py "$@" $(AM_V_GEN) $(srcdir)/gen-def.py "$@" $^
harfbuzz-subset.def: $(HB_SUBSET_headers) harfbuzz-subset.def: $(HB_SUBSET_headers)
$(AM_V_GEN) headers="$^" $(srcdir)/gen-def.py "$@" $(AM_V_GEN) $(srcdir)/gen-def.py "$@" $^
harfbuzz-icu.def: $(HB_ICU_headers) harfbuzz-icu.def: $(HB_ICU_headers)
$(AM_V_GEN) headers="$^" $(srcdir)/gen-def.py "$@" $(AM_V_GEN) $(srcdir)/gen-def.py "$@" $^
harfbuzz-gobject.def: $(HB_GOBJECT_headers) harfbuzz-gobject.def: $(HB_GOBJECT_headers)
$(AM_V_GEN) headers="$^" $(srcdir)/gen-def.py "$@" $(AM_V_GEN) $(srcdir)/gen-def.py "$@" $^
GENERATORS = \ GENERATORS = \

View File

@ -4,8 +4,14 @@ from __future__ import print_function, division, absolute_import
import io, os, re, sys import io, os, re, sys
if len (sys.argv) < 3:
sys.exit("usage: gen-def.py harfbuzz.def hb.h [hb-blob.h hb-buffer.h ...]")
output_file = sys.argv[1]
header_paths = sys.argv[2:]
headers_content = [] headers_content = []
for h in os.environ["headers"].split (' '): for h in header_paths:
if h.endswith (".h"): if h.endswith (".h"):
with io.open (h, encoding='utf-8') as f: headers_content.append (f.read ()) with io.open (h, encoding='utf-8') as f: headers_content.append (f.read ())
@ -13,7 +19,7 @@ result = """EXPORTS
%s %s
LIBRARY lib%s-0.dll""" % ( LIBRARY lib%s-0.dll""" % (
"\n".join (sorted (re.findall (r"^hb_\w+(?= \()", "\n".join (headers_content), re.M))), "\n".join (sorted (re.findall (r"^hb_\w+(?= \()", "\n".join (headers_content), re.M))),
sys.argv[1].replace ('.def', '') output_file.replace ('.def', '')
) )
with open (sys.argv[1], "w") as f: f.write (result) with open (output_file, "w") as f: f.write (result)