5 from collections
import defaultdict
6 locale
.setlocale(locale
.LC_ALL
, 'en_US.UTF-8')
10 # ##### ####### # # # # # #
11 # ## # # # # # # # # # # # #
12 # ## # # # # # # # # # # #
13 # ## #### # # # # # # # # # #
14 # ## # # # ####### # # # ####### # ###
15 # ## # # # # # # # # # # # ###
16 # # ##### ####### # # ## ## # # # ###
18 # Seriously. You shouldn't even be looking at this file unless you're
19 # debugging generate_mozbuild.py.
21 # DO NOT MODIFY THIS FILE IT IS AUTOGENERATED.
26 if CONFIG['MOZ_OPTIMIZE']:
27 if CONFIG['CC_TYPE'] == 'clang-cl':
28 skia_opt_flags += ['-O2']
29 elif CONFIG['CC_TYPE'] in ('clang', 'gcc'):
30 skia_opt_flags += ['-O3']
36 # We allow warnings for third-party code that can be updated from upstream.
37 AllowCompilerWarnings()
39 FINAL_LIBRARY = 'gkmedias'
44 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
45 DEFINES['UNICODE'] = True
46 DEFINES['_UNICODE'] = True
48 'skia/src/fonts/SkFontMgr_indirect.cpp',
49 'skia/src/fonts/SkRemotableFontMgr.cpp',
52 # We should autogenerate these SSE related flags.
54 if CONFIG['INTEL_ARCHITECTURE']:
55 SOURCES['skia/src/opts/SkOpts_ssse3.cpp'].flags += ['-Dskvx=skvx_ssse3', '-mssse3']
56 SOURCES['skia/src/opts/SkOpts_sse42.cpp'].flags += ['-Dskvx=skvx_sse42', '-msse4.2']
57 SOURCES['skia/src/opts/SkOpts_avx.cpp'].flags += ['-Dskvx=skvx_avx', '-mavx']
58 SOURCES['skia/src/opts/SkOpts_hsw.cpp'].flags += ['-Dskvx=skvx_hsw', '-mavx2', '-mf16c', '-mfma']
59 if not CONFIG["MOZ_CODE_COVERAGE"]:
60 SOURCES['skia/src/opts/SkOpts_skx.cpp'].flags += ['-Dskvx=skvx_skx', '-mavx512f', '-mavx512dq', '-mavx512cd', '-mavx512bw', '-mavx512vl']
61 elif CONFIG['TARGET_CPU'] == 'aarch64' and CONFIG['CC_TYPE'] in ('clang', 'gcc'):
62 SOURCES['skia/src/opts/SkOpts_crc32.cpp'].flags += ['-Dskvx=skvx_crc32', '-march=armv8-a+crc']
64 DEFINES['MOZ_SKIA'] = True
66 DEFINES['SKIA_IMPLEMENTATION'] = 1
68 DEFINES['SK_PDF_USE_HARFBUZZ_SUBSETTING'] = 1
70 if CONFIG['MOZ_TREE_FREETYPE']:
71 DEFINES['SK_CAN_USE_DLOPEN'] = 0
73 # Suppress warnings in third-party code.
75 '-Wno-deprecated-declarations',
76 '-Wno-overloaded-virtual',
78 '-Wno-unreachable-code',
79 '-Wno-unused-function',
81 if CONFIG['CC_TYPE'] == 'gcc':
84 '-Wno-maybe-uninitialized',
86 if CONFIG['CC_TYPE'] in ('clang', 'clang-cl'):
88 '-Wno-implicit-fallthrough',
89 '-Wno-inconsistent-missing-override',
90 '-Wno-macro-redefined',
91 '-Wno-unused-private-field',
94 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk', 'android'):
96 "/gfx/cairo/cairo/src",
98 CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
100 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk':
101 CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
103 if CONFIG['TARGET_CPU'] in ('mips32', 'mips64'):
104 # The skia code uses `mips` as a variable, but it's a builtin preprocessor
105 # macro on mips that expands to `1`.
106 DEFINES['mips'] = False
111 platforms
= ['linux', 'mac', 'android', 'win']
113 def parse_sources(output
):
114 return set(v
.replace('//', 'skia/') for v
in output
.decode('utf-8').split() if v
.endswith('.cpp') or v
.endswith('.S'))
116 def generate_opt_sources():
117 cpus
= [('intel', 'x86', [':ssse3', ':sse42', ':avx', ':hsw', ':skx']),
118 ('arm64', 'arm64', [':crc32'])]
121 for key
, cpu
, deps
in cpus
:
122 subprocess
.check_output('cd skia && bin/gn gen out/{0} --args=\'target_cpu="{1}"\''.format(key
, cpu
), shell
=True)
123 opt_sources
[key
] = set()
126 output
= subprocess
.check_output('cd skia && bin/gn desc out/{0} {1} sources'.format(key
, dep
), shell
=True)
128 opt_sources
[key
].update(parse_sources(output
))
129 except subprocess
.CalledProcessError
as e
:
130 if e
.output
.find(b
'source_set') < 0:
135 def generate_platform_sources():
138 'win' : 'win_vc="C:/" win_sdk_version="00.0.00000.0" win_toolchain_version="00.00.00000"'
140 for plat
in platforms
:
141 args
= platform_args
.get(plat
, '')
142 output
= subprocess
.check_output('cd skia && bin/gn gen out/{0} --args=\'target_os="{0}" {1}\' > /dev/null && bin/gn desc out/{0} :skia sources'.format(plat
, args
), shell
=True)
144 sources
[plat
] = parse_sources(output
)
147 ':fontmgr_win' : 'win',
148 ':fontmgr_win_gdi' : 'win',
149 ':fontmgr_mac_ct' : 'mac',
151 for dep
, key
in plat_deps
.items():
152 output
= subprocess
.check_output('cd skia && bin/gn desc out/{1} {0} sources'.format(dep
, key
), shell
=True)
154 sources
[key
].update(parse_sources(output
))
156 deps
= {':pdf' : 'pdf'}
157 for dep
, key
in deps
.items():
158 output
= subprocess
.check_output('cd skia && bin/gn desc out/linux {} sources'.format(dep
), shell
=True)
160 sources
[key
] = parse_sources(output
)
162 sources
.update(generate_opt_sources())
166 def generate_separated_sources(platform_sources
):
171 'skia/src/ports/SkImageEncoder',
172 'skia/src/ports/SkImageGenerator',
181 'SkCanvasStateUtils',
183 'SkMultiPictureDocument',
187 'SkPaintFilterCanvas',
190 'SkCreateCGImageRef',
191 'skia/src/ports/SkGlobalInitialization',
195 def isignorelisted(value
):
196 for item
in ignorelist
:
197 if value
.find(item
) >= 0:
202 separated
= defaultdict(set, {
204 'skia/src/codec/SkMasks.cpp',
205 'skia/src/effects/imagefilters/SkBlurImageFilter.cpp',
206 'skia/src/effects/imagefilters/SkComposeImageFilter.cpp',
207 'skia/src/effects/SkDashPathEffect.cpp',
208 'skia/src/ports/SkDiscardableMemory_none.cpp',
209 'skia/src/ports/SkGlobalInitialization_default.cpp',
210 'skia/src/ports/SkMemory_mozalloc.cpp',
211 'skia/src/ports/SkImageGenerator_none.cpp',
212 'skia/modules/skcms/skcms.cc',
213 'skia/src/core/SkImageFilterTypes.cpp',
214 'skia/src/ports/SkFontMgr_empty_factory.cpp',
217 # 'skia/src/ports/SkDebug_android.cpp',
218 'skia/src/ports/SkFontHost_cairo.cpp',
219 # 'skia/src/ports/SkFontHost_FreeType.cpp',
220 'skia/src/ports/SkFontHost_FreeType_common.cpp',
221 # 'skia/src/ports/SkTime_Unix.cpp',
222 # 'skia/src/utils/SkThreadUtils_pthread.cpp',
225 'skia/src/ports/SkFontHost_cairo.cpp',
226 'skia/src/ports/SkFontHost_FreeType_common.cpp',
236 for plat
in platform_sources
.keys():
237 for value
in platform_sources
[plat
]:
238 if isignorelisted(value
):
241 if value
in separated
['common']:
246 if all(value
in platform_sources
.get(p
, {})
247 for p
in platforms
if p
!= plat
):
250 separated
[key
].add(value
)
257 return [ x
for x
in seq
if x
not in seen
and not seen_add(x
)]
259 def write_cflags(f
, values
, subsearch
, cflag
, indent
):
260 def write_indent(indent
):
261 for _
in range(indent
):
264 if isinstance(subsearch
, str):
265 subsearch
= [ subsearch
]
267 def isallowlisted(value
):
268 for item
in subsearch
:
269 if value
.find(item
) >= 0:
274 val_list
= uniq(sorted(values
, key
=lambda x
: x
.lower()))
276 if len(val_list
) == 0:
280 if isallowlisted(val
):
282 f
.write("SOURCES[\'" + val
+ "\'].flags += " + cflag
+ "\n")
294 # Unfortunately for now the gpu and pathops directories are
295 # non-unifiable. Keep track of this and fix it.
296 unified_ignorelist
= [
298 'SkBitmapProcState_matrixProcs.cpp',
300 'SkBlitter_ARGB32.cpp',
301 'SkBlitter_Sprite.cpp',
303 'SkScan_Antihair.cpp',
304 'SkScan_AntiPath.cpp',
308 'SkPDFType1Font.cpp',
312 'SkPathOpsDebug.cpp',
321 def write_sources(f
, values
, indent
):
322 def isignorelisted(value
):
323 for item
in unified_ignorelist
:
324 if value
.find(item
) >= 0:
330 sources
['nonunified'] = set()
331 sources
['unified'] = set()
334 if isignorelisted(item
):
335 sources
['nonunified'].add(item
)
337 sources
['unified'].add(item
)
339 write_list(f
, "UNIFIED_SOURCES", sources
['unified'], indent
)
340 write_list(f
, "SOURCES", sources
['nonunified'], indent
)
342 def write_list(f
, name
, values
, indent
):
343 def write_indent(indent
):
344 for _
in range(indent
):
347 val_list
= uniq(sorted(values
, key
=lambda x
: x
.lower()))
349 if len(val_list
) == 0:
353 f
.write(name
+ ' += [\n')
355 write_indent(indent
+ 4)
356 f
.write('\'' + val
+ '\',\n')
361 def write_mozbuild(sources
):
362 filename
= 'moz.build'
363 f
= open(filename
, 'w')
367 write_sources(f
, sources
['common'], 0)
368 write_cflags(f
, sources
['common'], opt_allowlist
, 'skia_opt_flags', 0)
370 f
.write("if CONFIG['MOZ_ENABLE_SKIA_PDF']:\n")
371 write_sources(f
, sources
['pdf'], 4)
373 f
.write("if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':\n")
374 write_sources(f
, sources
['android'], 4)
376 f
.write("if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'uikit'):\n")
377 write_sources(f
, sources
['mac'], 4)
379 f
.write("if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk':\n")
380 write_sources(f
, sources
['linux'], 4)
382 f
.write("if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':\n")
383 write_list(f
, "SOURCES", sources
['win'], 4)
385 f
.write("if CONFIG['INTEL_ARCHITECTURE']:\n")
386 write_sources(f
, sources
['intel'], 4)
387 write_cflags(f
, sources
['intel'], opt_allowlist
, 'skia_opt_flags', 4)
390 f
.write("elif CONFIG['TARGET_CPU'] == 'arm' and CONFIG['CC_TYPE'] in ('clang', 'gcc'):\n")
391 write_sources(f
, sources
['arm'], 4)
392 write_cflags(f
, sources
['arm'], opt_allowlist
, 'skia_opt_flags', 4)
395 f
.write("elif CONFIG['TARGET_CPU'] == 'aarch64':\n")
396 write_sources(f
, sources
['arm64'], 4)
397 write_cflags(f
, sources
['arm64'], opt_allowlist
, 'skia_opt_flags', 4)
401 write_sources(f
, sources
['none'], 4)
407 print('Wrote ' + filename
)
410 platform_sources
= generate_platform_sources()
411 separated_sources
= generate_separated_sources(platform_sources
)
412 write_mozbuild(separated_sources
)
415 if __name__
== '__main__':