diff options
author | Mike Klein <mtklein@chromium.org> | 2016-12-07 12:27:56 -0500 |
---|---|---|
committer | Mike Klein <mtklein@chromium.org> | 2016-12-07 18:01:54 +0000 |
commit | 27eb22b994736318ae3d832bf16f4fad0e7e1383 (patch) | |
tree | dde0d7f055c293b627561acd24948ddfd8a758ce /gn/gn_to_bp.py | |
parent | 78e8165ec3a408a88c394095bfbc43df2051449d (diff) |
gn_to_bp.py fixes
- no u"" strings
- more pervasive sorting
- include sources from optional Skia components (e.g. gpu, codec, pdf)
- cosmetic nits
Change-Id: Ief0f293117dbfbc97584db185c067a8297067b74
Reviewed-on: https://skia-review.googlesource.com/5643
Reviewed-by: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'gn/gn_to_bp.py')
-rw-r--r-- | gn/gn_to_bp.py | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/gn/gn_to_bp.py b/gn/gn_to_bp.py index 170cfb017b..bb75b8394a 100644 --- a/gn/gn_to_bp.py +++ b/gn/gn_to_bp.py @@ -30,16 +30,20 @@ cc_library { ], export_include_dirs: $export_includes, + local_include_dirs: $local_includes, + srcs: $srcs, arch: { arm: { srcs: $arm_srcs, + armv7_a_neon: { srcs: $arm_neon_srcs, }, }, + arm64: { srcs: $arm64_srcs, }, @@ -47,6 +51,7 @@ cc_library { mips: { srcs: $mips_srcs, }, + mips64: { srcs: $mips64_srcs, }, @@ -54,10 +59,11 @@ cc_library { x86: { srcs: $x86_srcs, }, + x86_64: { srcs: $x86_srcs, }, - } + }, shared_libs: [ "libEGL", @@ -87,6 +93,7 @@ cc_library { gn_args = { 'skia_enable_vulkan_debug_layers': 'false', 'skia_use_vulkan': 'true', + 'target_cpu': '"none"', 'target_os': '"android"', } gn_args = ' '.join(sorted('%s=%s' % (k,v) for (k,v) in gn_args.iteritems())) @@ -97,11 +104,21 @@ subprocess.check_call(['gn', 'gen', tmp, '--args=%s' % gn_args, '--ide=json']) js = json.load(open(os.path.join(tmp, 'project.json'))) def strip_slashes(lst): - return [p.lstrip('/') for p in lst] + return [str(p.lstrip('/')) for p in lst] + srcs = strip_slashes(js['targets']['//:skia']['sources']) local_includes = strip_slashes(js['targets']['//:skia']['include_dirs']) export_includes = strip_slashes(js['targets']['//:public']['include_dirs']) +# Grab the sources from targets :skia depends on (optional Skia components). +for dep in js['targets']['//:skia']['deps']: + if 'third_party' in dep: + continue # We've handled all third-party DEPS as static or shared_libs. + srcs.extend(strip_slashes(js['targets'][dep].get('sources', []))) + +# No need to list headers. +srcs = [s for s in srcs if not s.endswith('.h')] + # Most defines go into SkUserConfig.h, where they're seen by Skia and its users. # Start with the defines :skia uses, minus a couple. We'll add more in a bit. defines = [str(d) for d in js['targets']['//:skia']['defines']] @@ -137,9 +154,9 @@ defines.extend([ 'SK_IGNORE_ETC1_SUPPORT', 'SK_USE_FREETYPE_EMBOLDEN', ]) -defines.sort() +# TODO: move these all to android_framework_defines.gni? -# Turns paths from opts.gni into paths relative to external/skia. +# Turn paths from opts.gni into paths relative to external/skia. def scrub(lst): # Perform any string substitutions. for var in defs: @@ -150,7 +167,7 @@ def scrub(lst): # Turn a list of strings into a pretty string version of a list of strings. def pretty(lst): - return pprint.pformat(lst).replace("'", '"') + return pprint.pformat(sorted(lst)).replace("'", '"') # OK! We have everything to fill in Android.bp... with open('Android.bp', 'w') as f: @@ -178,6 +195,6 @@ with open('SkUserConfig.h', 'w') as f: print >>f, '// This file is autogenerated by gn_to_bp.py.' print >>f, '#ifndef SkUserConfig_DEFINED' print >>f, '#define SkUserConfig_DEFINED' - for define in defines: + for define in sorted(defines): print >>f, ' #define', define print >>f, '#endif//SkUserConfig_DEFINED' |