|
1 #!/usr/bin/env python |
|
2 |
|
3 import os |
|
4 |
|
5 import locale |
|
6 locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') |
|
7 |
|
8 header = """ |
|
9 # Please note this file is autogenerated from generate_mozbuild.py, so do not modify it directly |
|
10 |
|
11 """ |
|
12 |
|
13 footer = """ |
|
14 |
|
15 # left out of UNIFIED_SOURCES for now; that's not C++ anyway, nothing else to unify it with |
|
16 if not CONFIG['INTEL_ARCHITECTURE'] and CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC']: |
|
17 SOURCES += [ |
|
18 'trunk/src/opts/memset.arm.S', |
|
19 ] |
|
20 if CONFIG['BUILD_ARM_NEON']: |
|
21 SOURCES += [ |
|
22 'trunk/src/opts/memset16_neon.S', |
|
23 'trunk/src/opts/memset32_neon.S', |
|
24 ] |
|
25 |
|
26 MSVC_ENABLE_PGO = True |
|
27 |
|
28 FINAL_LIBRARY = 'gkmedias' |
|
29 LOCAL_INCLUDES += [ |
|
30 'trunk/include/config', |
|
31 'trunk/include/core', |
|
32 'trunk/include/effects', |
|
33 'trunk/include/gpu', |
|
34 'trunk/include/images', |
|
35 'trunk/include/lazy', |
|
36 'trunk/include/pathops', |
|
37 'trunk/include/pipe', |
|
38 'trunk/include/ports', |
|
39 'trunk/include/utils', |
|
40 'trunk/include/utils/mac', |
|
41 'trunk/include/utils/win', |
|
42 'trunk/include/views', |
|
43 'trunk/src/core', |
|
44 'trunk/src/gpu', |
|
45 'trunk/src/gpu/effects', |
|
46 'trunk/src/gpu/gl', |
|
47 'trunk/src/image', |
|
48 'trunk/src/lazy', |
|
49 'trunk/src/opts', |
|
50 'trunk/src/sfnt', |
|
51 'trunk/src/utils', |
|
52 'trunk/src/utils/android', |
|
53 'trunk/src/utils/mac', |
|
54 'trunk/src/utils/win', |
|
55 ] |
|
56 |
|
57 DEFINES['SK_A32_SHIFT'] = 24 |
|
58 DEFINES['SK_R32_SHIFT'] = 16 |
|
59 DEFINES['SK_G32_SHIFT'] = 8 |
|
60 DEFINES['SK_B32_SHIFT'] = 0 |
|
61 |
|
62 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3', 'qt', 'gonk', 'cocoa'): |
|
63 DEFINES['SK_USE_POSIX_THREADS'] = 1 |
|
64 |
|
65 if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['HAVE_TOOLCHAIN_SUPPORT_MSSSE3']: |
|
66 DEFINES['SK_BUILD_SSSE3'] = 1 |
|
67 |
|
68 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gonk'): |
|
69 DEFINES['SK_FONTHOST_CAIRO_STANDALONE'] = 0 |
|
70 |
|
71 if (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android') or \ |
|
72 (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa') or \ |
|
73 (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk') or \ |
|
74 (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt') or \ |
|
75 CONFIG['MOZ_WIDGET_GTK']: |
|
76 DEFINES['SK_FONTHOST_DOES_NOT_USE_FONTMGR'] = 1 |
|
77 |
|
78 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': |
|
79 DEFINES['SKIA_DLL'] = 1 |
|
80 DEFINES['GR_DLL'] = 1 |
|
81 |
|
82 if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['GNU_CC']: |
|
83 SOURCES['trunk/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS'] |
|
84 SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS'] |
|
85 SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['-mssse3'] |
|
86 SOURCES['trunk/src/opts/SkBlitRect_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS'] |
|
87 SOURCES['trunk/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS'] |
|
88 SOURCES['trunk/src/opts/SkBlurImage_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS'] |
|
89 SOURCES['trunk/src/opts/SkMorphology_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS'] |
|
90 SOURCES['trunk/src/opts/SkUtils_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS'] |
|
91 elif CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC'] and CONFIG['BUILD_ARM_NEON']: |
|
92 DEFINES['__ARM_HAVE_OPTIONAL_NEON_SUPPORT'] = 1 |
|
93 DEFINES['USE_ANDROID_NDK_CPU_FEATURES'] = 0 |
|
94 |
|
95 DEFINES['SKIA_IMPLEMENTATION'] = 1 |
|
96 DEFINES['GR_IMPLEMENTATION'] = 1 |
|
97 |
|
98 if CONFIG['GNU_CXX']: |
|
99 CXXFLAGS += [ |
|
100 '-Wno-overloaded-virtual', |
|
101 '-Wno-unused-function', |
|
102 ] |
|
103 if not CONFIG['CLANG_CXX']: |
|
104 CXXFLAGS += ['-Wno-logical-op'] |
|
105 """ |
|
106 |
|
107 import json |
|
108 |
|
109 platforms = ['linux', 'mac', 'android', 'win'] |
|
110 |
|
111 custom_includes = { |
|
112 'trunk/src/ports/SkAtomics_android.h': True, |
|
113 'trunk/src/ports/SkAtomics_sync.h': True, |
|
114 'trunk/src/ports/SkAtomics_win.h': True, |
|
115 'trunk/src/ports/SkMutex_pthread.h': True, |
|
116 'trunk/src/ports/SkMutex_win.h': True |
|
117 } |
|
118 |
|
119 def generate_includes(): |
|
120 includes = {} |
|
121 for root, dirs, files in os.walk('trunk/include'): |
|
122 for name in files: |
|
123 if name.endswith('.h'): |
|
124 includes[os.path.join(root, name)] = True |
|
125 |
|
126 return dict(includes.items() + custom_includes.items()) |
|
127 |
|
128 def generate_opt_sources(): |
|
129 opt_sources = {'opts': {''}} |
|
130 for root, dirs, files in os.walk('trunk/src/opts'): |
|
131 for name in files: |
|
132 if name.endswith('.cpp'): |
|
133 opt_sources['opts'].add(os.path.join(root, name)) |
|
134 |
|
135 return opt_sources |
|
136 |
|
137 def generate_platform_sources(): |
|
138 sources = {} |
|
139 |
|
140 for plat in platforms: |
|
141 if os.system("cd trunk && GYP_GENERATORS=dump_mozbuild ./gyp_skia -D OS=%s gyp/skia_lib.gyp" % plat) != 0: |
|
142 print 'Failed to generate sources for ' + plat |
|
143 continue |
|
144 |
|
145 |
|
146 f = open('trunk/sources.json'); |
|
147 sources[plat] = set(json.load(f)); |
|
148 f.close() |
|
149 |
|
150 return dict(sources.items() + generate_opt_sources().items()) |
|
151 |
|
152 |
|
153 def generate_separated_sources(platform_sources): |
|
154 blacklist = [ |
|
155 'ChromeUtils', |
|
156 'SkImageDecoder_', |
|
157 '_gif', |
|
158 'SkFontConfigParser_android', |
|
159 'SkJpeg', |
|
160 'SkXML', |
|
161 'SkCity', |
|
162 'GrGLCreateNativeInterface', |
|
163 'fontconfig', |
|
164 'SkThreadUtils_pthread_', |
|
165 'SkImage_Codec', |
|
166 'SkBitmapChecksummer', |
|
167 'SkNativeGLContext', |
|
168 'SkFontConfig', |
|
169 'SkFontHost_win_dw', |
|
170 'SkForceLinking', |
|
171 'SkMovie', |
|
172 'SkImageDecoder', |
|
173 'SkImageEncoder', |
|
174 'SkBitmapHasher', |
|
175 'SkWGL', |
|
176 'SkImages', |
|
177 'SkDiscardableMemory_ashmem', |
|
178 'SkMemory_malloc' |
|
179 ] |
|
180 |
|
181 def isblacklisted(value): |
|
182 for item in blacklist: |
|
183 if value.find(item) >= 0: |
|
184 return True |
|
185 |
|
186 return False |
|
187 |
|
188 separated = { |
|
189 'common': { |
|
190 #'trunk/src/effects/gradients/SkGradientTileProc.cpp', |
|
191 'trunk/src/gpu/gl/GrGLCreateNativeInterface_none.cpp', |
|
192 'trunk/src/ports/SkDiscardableMemory_none.cpp', |
|
193 'trunk/src/ports/SkImageDecoder_empty.cpp', |
|
194 'trunk/src/ports/SkMemory_mozalloc.cpp', |
|
195 # 'trunk/src/images/SkImages.cpp', |
|
196 # 'trunk/src/images/SkImageRef.cpp', |
|
197 # 'trunk/src/images/SkImageRef_GlobalPool.cpp', |
|
198 # 'trunk/src/images/SkImageRefPool.cpp', |
|
199 # 'trunk/src/images/SkImageDecoder.cpp', |
|
200 # 'trunk/src/images/SkImageDecoder_Factory.cpp', |
|
201 }, |
|
202 'android': { |
|
203 # 'trunk/src/ports/SkDebug_android.cpp', |
|
204 'trunk/src/ports/SkFontHost_android_old.cpp', |
|
205 'trunk/src/ports/SkFontHost_cairo.cpp', |
|
206 # 'trunk/src/ports/SkFontHost_FreeType.cpp', |
|
207 # 'trunk/src/ports/SkFontHost_FreeType_common.cpp', |
|
208 # 'trunk/src/ports/SkThread_pthread.cpp', |
|
209 # 'trunk/src/ports/SkPurgeableMemoryBlock_android.cpp', |
|
210 # 'trunk/src/ports/SkTime_Unix.cpp', |
|
211 # 'trunk/src/utils/SkThreadUtils_pthread.cpp', |
|
212 # 'trunk/src/images/SkImageRef_ashmem.cpp', |
|
213 # 'trunk/src/utils/android/ashmem.cpp', |
|
214 }, |
|
215 'linux': { |
|
216 'trunk/src/ports/SkFontHost_cairo.cpp', |
|
217 }, |
|
218 'intel': { |
|
219 'trunk/src/opts/SkXfermode_opts_none.cpp', |
|
220 }, |
|
221 'arm': { |
|
222 'trunk/src/opts/SkUtils_opts_arm.cpp', |
|
223 'trunk/src/core/SkUtilsArm.cpp', |
|
224 }, |
|
225 'neon': { |
|
226 'trunk/src/opts/SkBitmapProcState_arm_neon.cpp', |
|
227 }, |
|
228 'none': { |
|
229 'trunk/src/opts/SkUtils_opts_none.cpp', |
|
230 } |
|
231 } |
|
232 |
|
233 for plat in platform_sources.keys(): |
|
234 if not separated.has_key(plat): |
|
235 separated[plat] = set() |
|
236 |
|
237 for value in platform_sources[plat]: |
|
238 if isblacklisted(value): |
|
239 continue |
|
240 |
|
241 if value.find('_SSE') > 0 or value.find('_SSSE') > 0: #lol |
|
242 separated['intel'].add(value) |
|
243 continue |
|
244 |
|
245 if value.find('_neon') > 0: |
|
246 separated['neon'].add(value) |
|
247 continue |
|
248 |
|
249 if value.find('_arm') > 0: |
|
250 separated['arm'].add(value) |
|
251 continue |
|
252 |
|
253 if value.find('_none') > 0: |
|
254 separated['none'].add(value) |
|
255 continue |
|
256 |
|
257 found = True |
|
258 for other in platforms: |
|
259 if other == plat or not platform_sources.has_key(other): |
|
260 continue |
|
261 |
|
262 if not value in platform_sources[other]: |
|
263 found = False |
|
264 break; |
|
265 |
|
266 if found: |
|
267 separated['common'].add(value) |
|
268 else: |
|
269 separated[plat].add(value) |
|
270 |
|
271 return separated |
|
272 |
|
273 def uniq(seq): |
|
274 seen = set() |
|
275 seen_add = seen.add |
|
276 return [ x for x in seq if x not in seen and not seen_add(x)] |
|
277 |
|
278 def write_cflags(f, values, subsearch, cflag, indent): |
|
279 def write_indent(indent): |
|
280 for _ in range(indent): |
|
281 f.write(' ') |
|
282 |
|
283 val_list = uniq(sorted(map(lambda val: val.replace('../', 'trunk/'), values), key=lambda x: x.lower())) |
|
284 |
|
285 if len(val_list) == 0: |
|
286 return |
|
287 |
|
288 for val in val_list: |
|
289 if val.find(subsearch) > 0: |
|
290 write_indent(indent) |
|
291 f.write("SOURCES[\'" + val + "\'].flags += [\'" + cflag + "\']\n") |
|
292 |
|
293 |
|
294 def write_list(f, name, values, indent): |
|
295 def write_indent(indent): |
|
296 for _ in range(indent): |
|
297 f.write(' ') |
|
298 |
|
299 val_list = uniq(sorted(map(lambda val: val.replace('../', 'trunk/'), values), key=lambda x: x.lower())) |
|
300 |
|
301 if len(val_list) == 0: |
|
302 return |
|
303 |
|
304 write_indent(indent) |
|
305 f.write(name + ' += [\n') |
|
306 for val in val_list: |
|
307 write_indent(indent + 4) |
|
308 f.write('\'' + val + '\',\n') |
|
309 |
|
310 write_indent(indent) |
|
311 f.write(']\n') |
|
312 |
|
313 def write_mozbuild(includes, sources): |
|
314 filename = 'moz.build' |
|
315 f = open(filename, 'w') |
|
316 |
|
317 f.write(header) |
|
318 |
|
319 write_list(f, 'EXPORTS.skia', includes, 0) |
|
320 |
|
321 write_list(f, 'SOURCES', sources['common'], 0) |
|
322 |
|
323 f.write("if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gonk'):\n") |
|
324 write_list(f, 'SOURCES', sources['android'], 4) |
|
325 |
|
326 f.write("if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':\n") |
|
327 write_list(f, 'SOURCES', sources['mac'], 4) |
|
328 |
|
329 f.write("if CONFIG['MOZ_WIDGET_GTK']:\n") |
|
330 write_list(f, 'SOURCES', sources['linux'], 4) |
|
331 |
|
332 f.write("if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt':\n") |
|
333 write_list(f, 'SOURCES', sources['linux'], 4) |
|
334 |
|
335 f.write("if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':\n") |
|
336 write_list(f, 'SOURCES', sources['win'], 4) |
|
337 |
|
338 f.write("\n\n") |
|
339 f.write("if CONFIG['INTEL_ARCHITECTURE']:\n") |
|
340 write_list(f, 'SOURCES', sources['intel'], 4) |
|
341 |
|
342 f.write("elif CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC']:\n") |
|
343 write_list(f, 'SOURCES', sources['arm'], 4) |
|
344 |
|
345 f.write(" if CONFIG['BUILD_ARM_NEON']:\n") |
|
346 write_list(f, 'SOURCES', sources['neon'], 8) |
|
347 write_cflags(f, sources['neon'], 'neon', '-mfpu=neon', 8) |
|
348 |
|
349 f.write("else:\n") |
|
350 write_list(f, 'SOURCES', sources['none'], 4) |
|
351 |
|
352 f.write(footer) |
|
353 |
|
354 f.close() |
|
355 |
|
356 print 'Wrote ' + filename |
|
357 |
|
358 def main(): |
|
359 includes = generate_includes() |
|
360 platform_sources = generate_platform_sources() |
|
361 separated_sources = generate_separated_sources(platform_sources) |
|
362 write_mozbuild(includes, separated_sources) |
|
363 |
|
364 |
|
365 if __name__ == '__main__': |
|
366 main() |