Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/tools/ports/harfbuzz.py
4130 views
1
# Copyright 2018 The Emscripten Authors. All rights reserved.
2
# Emscripten is available under two separate licenses, the MIT license and the
3
# University of Illinois/NCSA Open Source License. Both these licenses can be
4
# found in the LICENSE file.
5
6
import os
7
8
VERSION = '3.2.0'
9
HASH = 'c9d88068d8017046842f444f02f31dbae109026ede943aaf265db5508de8b4b2be84203950f274a237f515bf7cbd361629d2032c6e8ee8f50354b430bba3a8ca'
10
11
deps = ['freetype']
12
variants = {'harfbuzz-mt': {'PTHREADS': 1}}
13
14
srcs = '''
15
hb-aat-layout.cc
16
hb-aat-map.cc
17
hb-blob.cc
18
hb-buffer-serialize.cc
19
hb-buffer.cc
20
hb-common.cc
21
hb-draw.cc
22
hb-face.cc
23
hb-fallback-shape.cc
24
hb-font.cc
25
hb-map.cc
26
hb-number.cc
27
hb-ot-cff1-table.cc
28
hb-ot-cff2-table.cc
29
hb-ot-color.cc
30
hb-ot-face.cc
31
hb-ot-font.cc
32
hb-ot-layout.cc
33
hb-ot-map.cc
34
hb-ot-math.cc
35
hb-ot-meta.cc
36
hb-ot-metrics.cc
37
hb-ot-name.cc
38
hb-ot-shape-complex-arabic.cc
39
hb-ot-shape-complex-default.cc
40
hb-ot-shape-complex-hangul.cc
41
hb-ot-shape-complex-hebrew.cc
42
hb-ot-shape-complex-indic-table.cc
43
hb-ot-shape-complex-indic.cc
44
hb-ot-shape-complex-khmer.cc
45
hb-ot-shape-complex-myanmar.cc
46
hb-ot-shape-complex-syllabic.cc
47
hb-ot-shape-complex-thai.cc
48
hb-ot-shape-complex-use.cc
49
hb-ot-shape-complex-vowel-constraints.cc
50
hb-ot-shape-fallback.cc
51
hb-ot-shape-normalize.cc
52
hb-ot-shape.cc
53
hb-ot-tag.cc
54
hb-ot-var.cc
55
hb-set.cc
56
hb-shape-plan.cc
57
hb-shape.cc
58
hb-shaper.cc
59
hb-static.cc
60
hb-style.cc
61
hb-ucd.cc
62
hb-unicode.cc
63
hb-glib.cc
64
hb-ft.cc
65
hb-graphite2.cc
66
hb-uniscribe.cc
67
hb-gdi.cc
68
hb-directwrite.cc
69
hb-coretext.cc
70
'''.split()
71
72
73
def needed(settings):
74
return settings.USE_HARFBUZZ
75
76
77
def get_lib_name(settings):
78
return 'libharfbuzz' + ('-mt' if settings.PTHREADS else '') + '.a'
79
80
81
def get(ports, settings, shared):
82
ports.fetch_project('harfbuzz', f'https://github.com/harfbuzz/harfbuzz/releases/download/{VERSION}/harfbuzz-{VERSION}.tar.xz', sha512hash=HASH)
83
84
def create(final):
85
source_path = ports.get_dir('harfbuzz', 'harfbuzz-' + VERSION)
86
freetype_include = ports.get_include_dir('freetype2')
87
ports.install_headers(os.path.join(source_path, 'src'), target='harfbuzz')
88
89
# TODO(sbc): Look into HB_TINY, HB_LEAN, HB_MINI options. Remove
90
# HAVE_MMAP/HAVE_MPROTECT/HAVE_SYSCONF since we don't really support those?
91
92
# These cflags are the ones that the cmake build selects when running emcmake
93
# with harfbuzz
94
cflags = '''
95
-DHAVE_FREETYPE
96
-DHAVE_ATEXIT
97
-DHAVE_FALLBACK
98
-DHAVE_FT_SET_VAR_BLEND_COORDINATES
99
-DHAVE_INTEL_ATOMIC_PRIMITIVES
100
-DHAVE_MMAP
101
-DHAVE_MPROTECT
102
-DHAVE_OT
103
-DHAVE_STRTOD_L
104
-DHAVE_SYSCONF
105
-DHAVE_UCDN
106
-DHAVE_UNIST_H
107
-DHAVE_XLOCALE_H
108
-DHAVE_SYS_MMAN_H
109
-DHAVE_UNISTD_H
110
-fno-rtti
111
-fno-exceptions
112
-O3
113
-DNDEBUG
114
-Wno-nontrivial-memaccess
115
'''.split()
116
117
cflags += ['-I' + freetype_include, '-I' + os.path.join(freetype_include, 'config')]
118
119
if settings.RELOCATABLE:
120
cflags.append('-fPIC')
121
122
if settings.PTHREADS:
123
cflags.append('-pthread')
124
cflags.append('-DHAVE_PTHREAD')
125
else:
126
cflags.append('-DHB_NO_MT')
127
128
# Letting HarfBuzz enable warnings through pragmas can block compiler
129
# upgrades in situations where say a ToT compiler build adds a new
130
# stricter warning under -Wfoowarning-subgroup. HarfBuzz pragma-enables
131
# -Wfoowarning which default-enables -Wfoowarning-subgroup implicitly but
132
# HarfBuzz upstream is not yet clean of warnings produced for
133
# -Wfoowarning-subgroup. Hence disabling pragma warning control here.
134
# See also: https://github.com/emscripten-core/emscripten/pull/18119
135
cflags.append('-DHB_NO_PRAGMA_GCC_DIAGNOSTIC_ERROR')
136
cflags.append('-DHB_NO_PRAGMA_GCC_DIAGNOSTIC_WARNING')
137
138
ports.build_port(os.path.join(source_path, 'src'), final, 'harfbuzz', flags=cflags, srcs=srcs)
139
140
return [shared.cache.get_lib(get_lib_name(settings), create, what='port')]
141
142
143
def clear(ports, settings, shared):
144
shared.cache.erase_lib(get_lib_name(settings))
145
146
147
def process_dependencies(settings):
148
settings.USE_FREETYPE = 1
149
150
151
def process_args(ports):
152
return ['-isystem', ports.get_include_dir('harfbuzz')]
153
154
155
def show():
156
return 'harfbuzz (-sUSE_HARFBUZZ=1 or --use-port=harfbuzz; MIT license)'
157
158