未验证 提交 e3a931ef 编写于 作者: C Cosimo Lupo

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.
上级 46d8f0d5
...@@ -4,8 +4,14 @@ from __future__ import print_function, division, absolute_import ...@@ -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 ...@@ -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)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册