From e3a931ef0b86419b5e4ba17de51535393471ed9d Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Mon, 9 Jul 2018 18:11:29 +0100 Subject: [PATCH 1/4] gen-def.py: pass headers as arguments so that msys2 can convert posix paths When one is not using the msys2 python, the header files that are passed in as environment variable cannot be found. https://ci.appveyor.com/project/fonttools/ttfautohint-py/build/1.0.65/job/rkremny4jjid9nl2#L803 This is because msys2 shell and make use POSIX paths (e.g. /c/Users/clupo/...) whereas non-msys2 python.exe uses native Windows paths (e.g. C:\Users\clupo\...). Msys2 will automatically convert command line arguments (but not environment variables) from POSIX to Windows paths when calling a native win32 executable, so we pass the header paths as arguments instead of environment variables. This way the gen-def.py script can support both mingw python running in an MSYS2 shell, and native win32 python. --- src/gen-def.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gen-def.py b/src/gen-def.py index 9a997d65a..ba39eaae5 100755 --- a/src/gen-def.py +++ b/src/gen-def.py @@ -4,8 +4,14 @@ from __future__ import print_function, division, absolute_import 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 = [] -for h in os.environ["headers"].split (' '): +for h in header_paths: if h.endswith (".h"): with io.open (h, encoding='utf-8') as f: headers_content.append (f.read ()) @@ -13,7 +19,7 @@ result = """EXPORTS %s LIBRARY lib%s-0.dll""" % ( "\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) From ccdd15655480fe35226c0b757e28d3527fe2e6af Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Mon, 9 Jul 2018 18:26:44 +0100 Subject: [PATCH 2/4] src/Makefile.am: pass headers to gen-def.py as arguments, not env vars --- src/Makefile.am | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 9d5662e4a..6dfec3bfa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -277,13 +277,13 @@ endif check: $(DEF_FILES) # For check-symbols.sh CLEANFILES += $(DEF_FILES) 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) - $(AM_V_GEN) headers="$^" $(srcdir)/gen-def.py "$@" + $(AM_V_GEN) $(srcdir)/gen-def.py "$@" $^ 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) - $(AM_V_GEN) headers="$^" $(srcdir)/gen-def.py "$@" + $(AM_V_GEN) $(srcdir)/gen-def.py "$@" $^ GENERATORS = \ From 83d2233a5c47cf1feadcdece5bd4a6b498c6ee7a Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Mon, 9 Jul 2018 18:48:20 +0100 Subject: [PATCH 3/4] CMakeLists.txt: pass headers as arguments to gen-def.py; call using PYTHON_EXECUTABLE --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ed7e56e8..e0a4b8812 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -836,7 +836,7 @@ if (UNIX OR MINGW) # generate harfbuzz.def after build completion string(REPLACE ";" " " space_separated_headers "${project_headers}") 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 ${space_separated_headers} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src) add_test(NAME check-static-inits.sh From 53f73409a91241765ae6a0cadf7600676988b6af Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Mon, 9 Jul 2018 18:54:23 +0100 Subject: [PATCH 4/4] CMakeLists.txt: don't pass header args as single space-separated string let python's parse command-line args as usual --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0a4b8812..e881dbd1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -834,9 +834,8 @@ set_target_properties(hb-ot-tag PROPERTIES COMPILE_FLAGS "-DMAIN") if (UNIX OR MINGW) if (BUILD_SHARED_LIBS) # generate harfbuzz.def after build completion - string(REPLACE ";" " " space_separated_headers "${project_headers}") add_custom_command(TARGET harfbuzz POST_BUILD - COMMAND "${PYTHON_EXECUTABLE}" ${PROJECT_SOURCE_DIR}/src/gen-def.py ${PROJECT_BINARY_DIR}/harfbuzz.def ${space_separated_headers} + COMMAND "${PYTHON_EXECUTABLE}" ${PROJECT_SOURCE_DIR}/src/gen-def.py ${PROJECT_BINARY_DIR}/harfbuzz.def ${project_headers} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src) add_test(NAME check-static-inits.sh