michael@0: #!/usr/bin/env python michael@0: michael@0: import os michael@0: michael@0: import locale michael@0: locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') michael@0: michael@0: header = """ michael@0: # Please note this file is autogenerated from generate_mozbuild.py, so do not modify it directly michael@0: michael@0: """ michael@0: michael@0: footer = """ michael@0: michael@0: # left out of UNIFIED_SOURCES for now; that's not C++ anyway, nothing else to unify it with michael@0: if not CONFIG['INTEL_ARCHITECTURE'] and CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC']: michael@0: SOURCES += [ michael@0: 'trunk/src/opts/memset.arm.S', michael@0: ] michael@0: if CONFIG['BUILD_ARM_NEON']: michael@0: SOURCES += [ michael@0: 'trunk/src/opts/memset16_neon.S', michael@0: 'trunk/src/opts/memset32_neon.S', michael@0: ] michael@0: michael@0: MSVC_ENABLE_PGO = True michael@0: michael@0: FINAL_LIBRARY = 'gkmedias' michael@0: LOCAL_INCLUDES += [ michael@0: 'trunk/include/config', michael@0: 'trunk/include/core', michael@0: 'trunk/include/effects', michael@0: 'trunk/include/gpu', michael@0: 'trunk/include/images', michael@0: 'trunk/include/lazy', michael@0: 'trunk/include/pathops', michael@0: 'trunk/include/pipe', michael@0: 'trunk/include/ports', michael@0: 'trunk/include/utils', michael@0: 'trunk/include/utils/mac', michael@0: 'trunk/include/utils/win', michael@0: 'trunk/include/views', michael@0: 'trunk/src/core', michael@0: 'trunk/src/gpu', michael@0: 'trunk/src/gpu/effects', michael@0: 'trunk/src/gpu/gl', michael@0: 'trunk/src/image', michael@0: 'trunk/src/lazy', michael@0: 'trunk/src/opts', michael@0: 'trunk/src/sfnt', michael@0: 'trunk/src/utils', michael@0: 'trunk/src/utils/android', michael@0: 'trunk/src/utils/mac', michael@0: 'trunk/src/utils/win', michael@0: ] michael@0: michael@0: DEFINES['SK_A32_SHIFT'] = 24 michael@0: DEFINES['SK_R32_SHIFT'] = 16 michael@0: DEFINES['SK_G32_SHIFT'] = 8 michael@0: DEFINES['SK_B32_SHIFT'] = 0 michael@0: michael@0: if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3', 'qt', 'gonk', 'cocoa'): michael@0: DEFINES['SK_USE_POSIX_THREADS'] = 1 michael@0: michael@0: if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['HAVE_TOOLCHAIN_SUPPORT_MSSSE3']: michael@0: DEFINES['SK_BUILD_SSSE3'] = 1 michael@0: michael@0: if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gonk'): michael@0: DEFINES['SK_FONTHOST_CAIRO_STANDALONE'] = 0 michael@0: michael@0: if (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android') or \ michael@0: (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa') or \ michael@0: (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk') or \ michael@0: (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt') or \ michael@0: CONFIG['MOZ_WIDGET_GTK']: michael@0: DEFINES['SK_FONTHOST_DOES_NOT_USE_FONTMGR'] = 1 michael@0: michael@0: if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': michael@0: DEFINES['SKIA_DLL'] = 1 michael@0: DEFINES['GR_DLL'] = 1 michael@0: michael@0: if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['GNU_CC']: michael@0: SOURCES['trunk/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS'] michael@0: SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS'] michael@0: SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['-mssse3'] michael@0: SOURCES['trunk/src/opts/SkBlitRect_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS'] michael@0: SOURCES['trunk/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS'] michael@0: SOURCES['trunk/src/opts/SkBlurImage_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS'] michael@0: SOURCES['trunk/src/opts/SkMorphology_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS'] michael@0: SOURCES['trunk/src/opts/SkUtils_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS'] michael@0: elif CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC'] and CONFIG['BUILD_ARM_NEON']: michael@0: DEFINES['__ARM_HAVE_OPTIONAL_NEON_SUPPORT'] = 1 michael@0: DEFINES['USE_ANDROID_NDK_CPU_FEATURES'] = 0 michael@0: michael@0: DEFINES['SKIA_IMPLEMENTATION'] = 1 michael@0: DEFINES['GR_IMPLEMENTATION'] = 1 michael@0: michael@0: if CONFIG['GNU_CXX']: michael@0: CXXFLAGS += [ michael@0: '-Wno-overloaded-virtual', michael@0: '-Wno-unused-function', michael@0: ] michael@0: if not CONFIG['CLANG_CXX']: michael@0: CXXFLAGS += ['-Wno-logical-op'] michael@0: """ michael@0: michael@0: import json michael@0: michael@0: platforms = ['linux', 'mac', 'android', 'win'] michael@0: michael@0: custom_includes = { michael@0: 'trunk/src/ports/SkAtomics_android.h': True, michael@0: 'trunk/src/ports/SkAtomics_sync.h': True, michael@0: 'trunk/src/ports/SkAtomics_win.h': True, michael@0: 'trunk/src/ports/SkMutex_pthread.h': True, michael@0: 'trunk/src/ports/SkMutex_win.h': True michael@0: } michael@0: michael@0: def generate_includes(): michael@0: includes = {} michael@0: for root, dirs, files in os.walk('trunk/include'): michael@0: for name in files: michael@0: if name.endswith('.h'): michael@0: includes[os.path.join(root, name)] = True michael@0: michael@0: return dict(includes.items() + custom_includes.items()) michael@0: michael@0: def generate_opt_sources(): michael@0: opt_sources = {'opts': {''}} michael@0: for root, dirs, files in os.walk('trunk/src/opts'): michael@0: for name in files: michael@0: if name.endswith('.cpp'): michael@0: opt_sources['opts'].add(os.path.join(root, name)) michael@0: michael@0: return opt_sources michael@0: michael@0: def generate_platform_sources(): michael@0: sources = {} michael@0: michael@0: for plat in platforms: michael@0: if os.system("cd trunk && GYP_GENERATORS=dump_mozbuild ./gyp_skia -D OS=%s gyp/skia_lib.gyp" % plat) != 0: michael@0: print 'Failed to generate sources for ' + plat michael@0: continue michael@0: michael@0: michael@0: f = open('trunk/sources.json'); michael@0: sources[plat] = set(json.load(f)); michael@0: f.close() michael@0: michael@0: return dict(sources.items() + generate_opt_sources().items()) michael@0: michael@0: michael@0: def generate_separated_sources(platform_sources): michael@0: blacklist = [ michael@0: 'ChromeUtils', michael@0: 'SkImageDecoder_', michael@0: '_gif', michael@0: 'SkFontConfigParser_android', michael@0: 'SkJpeg', michael@0: 'SkXML', michael@0: 'SkCity', michael@0: 'GrGLCreateNativeInterface', michael@0: 'fontconfig', michael@0: 'SkThreadUtils_pthread_', michael@0: 'SkImage_Codec', michael@0: 'SkBitmapChecksummer', michael@0: 'SkNativeGLContext', michael@0: 'SkFontConfig', michael@0: 'SkFontHost_win_dw', michael@0: 'SkForceLinking', michael@0: 'SkMovie', michael@0: 'SkImageDecoder', michael@0: 'SkImageEncoder', michael@0: 'SkBitmapHasher', michael@0: 'SkWGL', michael@0: 'SkImages', michael@0: 'SkDiscardableMemory_ashmem', michael@0: 'SkMemory_malloc' michael@0: ] michael@0: michael@0: def isblacklisted(value): michael@0: for item in blacklist: michael@0: if value.find(item) >= 0: michael@0: return True michael@0: michael@0: return False michael@0: michael@0: separated = { michael@0: 'common': { michael@0: #'trunk/src/effects/gradients/SkGradientTileProc.cpp', michael@0: 'trunk/src/gpu/gl/GrGLCreateNativeInterface_none.cpp', michael@0: 'trunk/src/ports/SkDiscardableMemory_none.cpp', michael@0: 'trunk/src/ports/SkImageDecoder_empty.cpp', michael@0: 'trunk/src/ports/SkMemory_mozalloc.cpp', michael@0: # 'trunk/src/images/SkImages.cpp', michael@0: # 'trunk/src/images/SkImageRef.cpp', michael@0: # 'trunk/src/images/SkImageRef_GlobalPool.cpp', michael@0: # 'trunk/src/images/SkImageRefPool.cpp', michael@0: # 'trunk/src/images/SkImageDecoder.cpp', michael@0: # 'trunk/src/images/SkImageDecoder_Factory.cpp', michael@0: }, michael@0: 'android': { michael@0: # 'trunk/src/ports/SkDebug_android.cpp', michael@0: 'trunk/src/ports/SkFontHost_android_old.cpp', michael@0: 'trunk/src/ports/SkFontHost_cairo.cpp', michael@0: # 'trunk/src/ports/SkFontHost_FreeType.cpp', michael@0: # 'trunk/src/ports/SkFontHost_FreeType_common.cpp', michael@0: # 'trunk/src/ports/SkThread_pthread.cpp', michael@0: # 'trunk/src/ports/SkPurgeableMemoryBlock_android.cpp', michael@0: # 'trunk/src/ports/SkTime_Unix.cpp', michael@0: # 'trunk/src/utils/SkThreadUtils_pthread.cpp', michael@0: # 'trunk/src/images/SkImageRef_ashmem.cpp', michael@0: # 'trunk/src/utils/android/ashmem.cpp', michael@0: }, michael@0: 'linux': { michael@0: 'trunk/src/ports/SkFontHost_cairo.cpp', michael@0: }, michael@0: 'intel': { michael@0: 'trunk/src/opts/SkXfermode_opts_none.cpp', michael@0: }, michael@0: 'arm': { michael@0: 'trunk/src/opts/SkUtils_opts_arm.cpp', michael@0: 'trunk/src/core/SkUtilsArm.cpp', michael@0: }, michael@0: 'neon': { michael@0: 'trunk/src/opts/SkBitmapProcState_arm_neon.cpp', michael@0: }, michael@0: 'none': { michael@0: 'trunk/src/opts/SkUtils_opts_none.cpp', michael@0: } michael@0: } michael@0: michael@0: for plat in platform_sources.keys(): michael@0: if not separated.has_key(plat): michael@0: separated[plat] = set() michael@0: michael@0: for value in platform_sources[plat]: michael@0: if isblacklisted(value): michael@0: continue michael@0: michael@0: if value.find('_SSE') > 0 or value.find('_SSSE') > 0: #lol michael@0: separated['intel'].add(value) michael@0: continue michael@0: michael@0: if value.find('_neon') > 0: michael@0: separated['neon'].add(value) michael@0: continue michael@0: michael@0: if value.find('_arm') > 0: michael@0: separated['arm'].add(value) michael@0: continue michael@0: michael@0: if value.find('_none') > 0: michael@0: separated['none'].add(value) michael@0: continue michael@0: michael@0: found = True michael@0: for other in platforms: michael@0: if other == plat or not platform_sources.has_key(other): michael@0: continue michael@0: michael@0: if not value in platform_sources[other]: michael@0: found = False michael@0: break; michael@0: michael@0: if found: michael@0: separated['common'].add(value) michael@0: else: michael@0: separated[plat].add(value) michael@0: michael@0: return separated michael@0: michael@0: def uniq(seq): michael@0: seen = set() michael@0: seen_add = seen.add michael@0: return [ x for x in seq if x not in seen and not seen_add(x)] michael@0: michael@0: def write_cflags(f, values, subsearch, cflag, indent): michael@0: def write_indent(indent): michael@0: for _ in range(indent): michael@0: f.write(' ') michael@0: michael@0: val_list = uniq(sorted(map(lambda val: val.replace('../', 'trunk/'), values), key=lambda x: x.lower())) michael@0: michael@0: if len(val_list) == 0: michael@0: return michael@0: michael@0: for val in val_list: michael@0: if val.find(subsearch) > 0: michael@0: write_indent(indent) michael@0: f.write("SOURCES[\'" + val + "\'].flags += [\'" + cflag + "\']\n") michael@0: michael@0: michael@0: def write_list(f, name, values, indent): michael@0: def write_indent(indent): michael@0: for _ in range(indent): michael@0: f.write(' ') michael@0: michael@0: val_list = uniq(sorted(map(lambda val: val.replace('../', 'trunk/'), values), key=lambda x: x.lower())) michael@0: michael@0: if len(val_list) == 0: michael@0: return michael@0: michael@0: write_indent(indent) michael@0: f.write(name + ' += [\n') michael@0: for val in val_list: michael@0: write_indent(indent + 4) michael@0: f.write('\'' + val + '\',\n') michael@0: michael@0: write_indent(indent) michael@0: f.write(']\n') michael@0: michael@0: def write_mozbuild(includes, sources): michael@0: filename = 'moz.build' michael@0: f = open(filename, 'w') michael@0: michael@0: f.write(header) michael@0: michael@0: write_list(f, 'EXPORTS.skia', includes, 0) michael@0: michael@0: write_list(f, 'SOURCES', sources['common'], 0) michael@0: michael@0: f.write("if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gonk'):\n") michael@0: write_list(f, 'SOURCES', sources['android'], 4) michael@0: michael@0: f.write("if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':\n") michael@0: write_list(f, 'SOURCES', sources['mac'], 4) michael@0: michael@0: f.write("if CONFIG['MOZ_WIDGET_GTK']:\n") michael@0: write_list(f, 'SOURCES', sources['linux'], 4) michael@0: michael@0: f.write("if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt':\n") michael@0: write_list(f, 'SOURCES', sources['linux'], 4) michael@0: michael@0: f.write("if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':\n") michael@0: write_list(f, 'SOURCES', sources['win'], 4) michael@0: michael@0: f.write("\n\n") michael@0: f.write("if CONFIG['INTEL_ARCHITECTURE']:\n") michael@0: write_list(f, 'SOURCES', sources['intel'], 4) michael@0: michael@0: f.write("elif CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC']:\n") michael@0: write_list(f, 'SOURCES', sources['arm'], 4) michael@0: michael@0: f.write(" if CONFIG['BUILD_ARM_NEON']:\n") michael@0: write_list(f, 'SOURCES', sources['neon'], 8) michael@0: write_cflags(f, sources['neon'], 'neon', '-mfpu=neon', 8) michael@0: michael@0: f.write("else:\n") michael@0: write_list(f, 'SOURCES', sources['none'], 4) michael@0: michael@0: f.write(footer) michael@0: michael@0: f.close() michael@0: michael@0: print 'Wrote ' + filename michael@0: michael@0: def main(): michael@0: includes = generate_includes() michael@0: platform_sources = generate_platform_sources() michael@0: separated_sources = generate_separated_sources(platform_sources) michael@0: write_mozbuild(includes, separated_sources) michael@0: michael@0: michael@0: if __name__ == '__main__': michael@0: main()