Fix build of HarfBuzz tools and HarfBuzz-GObject on Visual Studio (#555)
* hb-buffer.h: Mark hb_buffer_diff() for export This will fix the tools builds on Visual Studio, as the symbol is used by the tools. * build: Adapt NMake Makefiles for GLib 2.53.4 or later glib-mkenums was ported from a PERL script to a Python script, so we need to update how we generate the enum sources for HarfBuzz-GObject in the NMake builds. Let this be known in the build documentation for MSVC builds. One of the problems with the underlying cmd.exe that the NMake Makefiles run on is that shebang lines are not recognized, so we need to to test run the script with Python and see whether it succeeded by outputing a source file that is larger than 0 in file size (since running the PERL version of the script will clearly fail and cause an empty file to be created). If it succeeds, we then run a small Python utility script that makes the necessary string replacements, and we are done. If that fails, then we run the glib-mkenums script with PERL, and do the replacements with the PERL one-liners as we did before. We need to make replace.py use latin-1 encoding when using Python 3.x to cope with the copyright sign that is in the generated enum sources.
This commit is contained in:
parent
c9e2cf6f55
commit
48a9406839
|
@ -504,7 +504,7 @@ typedef enum { /*< flags >*/
|
|||
} hb_buffer_diff_flags_t;
|
||||
|
||||
/* Compare the contents of two buffers, report types of differences. */
|
||||
hb_buffer_diff_flags_t
|
||||
HB_EXTERN hb_buffer_diff_flags_t
|
||||
hb_buffer_diff (hb_buffer_t *buffer,
|
||||
hb_buffer_t *reference,
|
||||
hb_codepoint_t dottedcircle_glyph,
|
||||
|
|
|
@ -11,6 +11,8 @@ EXTRA_DIST = \
|
|||
install.mak \
|
||||
introspection-msvc.mak \
|
||||
Makefile.vc \
|
||||
README.txt
|
||||
README.txt \
|
||||
replace.py \
|
||||
sed-enums-srcs.py
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
||||
|
|
|
@ -57,8 +57,9 @@ GLIB: Enable GLib support in HarfBuzz, which also uses the GLib unicode
|
|||
|
||||
GOBJECT: Enable building the HarfBuzz-GObject DLL, and thus implies GLib
|
||||
support. This requires the GObject libraries and glib-mkenums script,
|
||||
along with PERL to generate the enum sources and headers, which is
|
||||
required for the build.
|
||||
along with Python (when using GObject/GLib 2.53.4 or later) or PERL
|
||||
(when using GObject/GLib 2.53.3 or earlier) to generate the enum
|
||||
sources and headers, which is required for the build.
|
||||
|
||||
INTROSPECTION: Enable build of introspection files, for making HarfBuzz
|
||||
bindings for other programming languages available, such as
|
||||
|
|
|
@ -12,13 +12,20 @@ config.h: config.h.win32
|
|||
# we are already using PERL, use PERL one-liners.
|
||||
!if "$(GOBJECT)" == "1"
|
||||
$(HB_GOBJECT_ENUM_GENERATED_SOURCES): ..\src\hb-gobject-enums.h.tmpl ..\src\hb-gobject-enums.cc.tmpl $(HB_ACTUAL_HEADERS)
|
||||
-$(PYTHON) $(PREFIX)\bin\glib-mkenums \
|
||||
--identifier-prefix hb_ --symbol-prefix hb_gobject \
|
||||
--template ..\src\$(@F).tmpl $(HB_ACTUAL_HEADERS) > $@.tmp
|
||||
for %%f in ($@.tmp) do if %%~zf gtr 0 $(PYTHON) sed-enums-srcs.py --input=$@.tmp --output=$@
|
||||
@-del $@.tmp
|
||||
if not exist $@ \
|
||||
$(PERL) $(PREFIX)\bin\glib-mkenums \
|
||||
--identifier-prefix hb_ --symbol-prefix hb_gobject \
|
||||
--template ..\src\$(@F).tmpl $(HB_ACTUAL_HEADERS) > $@
|
||||
$(PERL) -p -i.tmp1 -e "s/_t_get_type/_get_type/g" $@
|
||||
$(PERL) -p -i.tmp2 -e "s/_T \(/ (/g" $@
|
||||
@-del $@.tmp1
|
||||
@-del $@.tmp2
|
||||
--template ..\src\$(@F).tmpl $(HB_ACTUAL_HEADERS) > $@.tmp
|
||||
if exist $@.tmp $(PERL) -p -i.tmp1 -e "s/_t_get_type/_get_type/g" $@.tmp
|
||||
if exist $@.tmp $(PERL) -p -i.tmp2 -e "s/_T \(/ (/g" $@.tmp
|
||||
@if exist $@.tmp.tmp1 del $@.tmp.tmp1
|
||||
@if exist $@.tmp.tmp2 del $@.tmp.tmp2
|
||||
@if exist $@.tmp move $@.tmp $@
|
||||
!endif
|
||||
|
||||
# Create the build directories
|
||||
|
|
|
@ -107,7 +107,10 @@ help:
|
|||
@echo GOBJECT:
|
||||
@echo Enable the HarfBuzz-GObject library, also implies GLib2 support,
|
||||
@echo requires the GNOME GLib2 libraries and tools, notably the glib-mkenums
|
||||
@echo tool script, which will require a PERL interpreter (use
|
||||
@echo tool script, which will require a Python interpretor (when using
|
||||
@echo GObject/GLib 2.53.4 or later; use PYTHON=^$(PATH_TO_PYTHON_INTERPRETOR)
|
||||
@echo if the Python interpretor is not already in your PATH) or PERL
|
||||
@echo interpreter (when using GObject/GLib 2.53.3 or earlier; use
|
||||
@echo PERL=^$(PATH_TO_PERL_INTERPRETOR)) if it is not already in your PATH).
|
||||
@echo.
|
||||
@echo GRAPHITE2:
|
||||
|
|
|
@ -25,7 +25,7 @@ def open_file(filename, mode):
|
|||
if sys.version_info[0] < 3:
|
||||
return open(filename, mode=mode)
|
||||
else:
|
||||
return open(filename, mode=mode, encoding='utf-8')
|
||||
return open(filename, mode=mode, encoding='latin-1')
|
||||
|
||||
def replace_multi(src, dest, replace_items):
|
||||
with open_file(src, 'r') as s:
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Utility script to replace strings in the
|
||||
# generated enum sources, as needed by the build
|
||||
|
||||
# Author: Fan, Chun-wei
|
||||
# Date: Oct. 5, 2017
|
||||
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
from replace import replace_multi
|
||||
|
||||
def main(argv):
|
||||
parser = argparse.ArgumentParser(description='Replace strings in generated enum sources')
|
||||
parser.add_argument('--input', help='input generated temporary enum source',
|
||||
required=True)
|
||||
parser.add_argument('--output',
|
||||
help='output generated final enum source', required=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
# check whether the generated temporary enum source exists
|
||||
if not os.path.exists(args.input):
|
||||
raise SystemExit('Specified generated temporary enum source \'%s\' is invalid' % args.input)
|
||||
|
||||
replace_items = {'_t_get_type': '_get_type',
|
||||
'_T (': ' ('}
|
||||
|
||||
# Generate the final enum source
|
||||
replace_multi(args.input,
|
||||
args.output,
|
||||
replace_items)
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv))
|
Loading…
Reference in New Issue