aboutsummaryrefslogtreecommitdiffhomepage
path: root/gn/gn_to_bp.py
diff options
context:
space:
mode:
authorGravatar Leon Scroggins III <scroggo@google.com>2017-01-26 17:21:27 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-27 20:02:23 +0000
commit6ccd2cabaac810edccab620d8a944f64b0432d44 (patch)
treee25c0c088be285e6b990a5824c016c5a986cac70 /gn/gn_to_bp.py
parent91af72703830f3946c538b47c6c7c96afc0adde2 (diff)
Generate Android build targets for dm and nanobench
Generate targets for dm and nanobench from ninja and add them to the generated Android.bp file. Remove nanobenchAndroid and SkAndroidSDKCanvas. These rely on HWUI internals and are currently unused. Update gyp file references to removed files, just in case. Change-Id: Ic6ae18a70bfd0c33804e7996d077f2081dfdfe07 Reviewed-on: https://skia-review.googlesource.com/7635 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'gn/gn_to_bp.py')
-rw-r--r--gn/gn_to_bp.py132
1 files changed, 121 insertions, 11 deletions
diff --git a/gn/gn_to_bp.py b/gn/gn_to_bp.py
index 517324626c..e0605c9d33 100644
--- a/gn/gn_to_bp.py
+++ b/gn/gn_to_bp.py
@@ -14,6 +14,36 @@ import string
import subprocess
import tempfile
+tool_cflags = [
+ '-Wno-unused-parameter',
+]
+
+# It's easier to maintain one list instead of separate lists.
+tool_shared_libs = [
+ 'liblog',
+ 'libGLESv2',
+ 'libEGL',
+ 'libvulkan',
+ 'libz',
+ 'libjpeg',
+ 'libpng',
+ 'libicuuc',
+ 'libicui18n',
+ 'libexpat',
+ 'libft2',
+ 'libdng_sdk',
+ 'libpiex',
+]
+
+# The ordering here is important: libsfntly needs to come after libskia.
+tool_static_libs = [
+ 'libjsoncpp',
+ 'libskia',
+ 'libsfntly',
+ 'libwebp-decode',
+ 'libwebp-encode',
+]
+
# First we start off with a template for Android.bp,
# with holes for source lists and include directories.
bp = string.Template('''// This file is autogenerated by gn_to_bp.py.
@@ -104,6 +134,54 @@ cc_library {
"libwebp-decode",
"libwebp-encode",
],
+}
+
+cc_test {
+ name: "skia_dm",
+
+ cflags: [
+ $tool_cflags
+ ],
+
+ local_include_dirs: [
+ $dm_includes
+ ],
+
+ srcs: [
+ $dm_srcs
+ ],
+
+ shared_libs: [
+ $tool_shared_libs
+ ],
+
+ static_libs: [
+ $tool_static_libs
+ ],
+}
+
+cc_test {
+ name: "skia_nanobench",
+
+ cflags: [
+ $tool_cflags
+ ],
+
+ local_include_dirs: [
+ $nanobench_includes
+ ],
+
+ srcs: [
+ $nanobench_srcs
+ ],
+
+ shared_libs: [
+ $tool_shared_libs
+ ],
+
+ static_libs: [
+ $tool_static_libs
+ ],
}''')
# We'll run GN to get the main source lists and include directories for Skia.
@@ -111,6 +189,9 @@ gn_args = {
'skia_enable_splicer': 'false',
'skia_enable_vulkan_debug_layers': 'false',
'skia_use_system_expat': 'true',
+ 'skia_use_system_jsoncpp': 'true',
+ 'skia_use_system_libpng': 'true',
+ 'skia_use_system_zlib': 'true',
'skia_use_vulkan': 'true',
'target_cpu': '"none"',
'target_os': '"android"',
@@ -129,16 +210,33 @@ 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.
- if 'none' in dep:
- continue # We'll handle all cpu-specific sources manually later.
- srcs.extend(strip_slashes(js['targets'][dep].get('sources', [])))
+dm_srcs = strip_slashes(js['targets']['//:dm']['sources'])
+dm_includes = strip_slashes(js['targets']['//:dm']['include_dirs'])
+
+nanobench_target = js['targets']['//:nanobench']
+nanobench_srcs = strip_slashes(nanobench_target['sources'])
+nanobench_includes = strip_slashes(nanobench_target['include_dirs'])
+
+def GrabDependentSrcs(name, srcs_to_extend, exclude):
+ # Grab the sources from other targets that $name depends on (e.g. optional
+ # Skia components, gms, tests, etc).
+ for dep in js['targets'][name]['deps']:
+ if 'third_party' in dep:
+ continue # We've handled all third-party DEPS as static or shared_libs.
+ if 'none' in dep:
+ continue # We'll handle all cpu-specific sources manually later.
+ if exclude and exclude in dep:
+ continue
+ srcs_to_extend.extend(strip_slashes(js['targets'][dep].get('sources', [])))
+
+GrabDependentSrcs('//:skia', srcs, None)
+GrabDependentSrcs('//:dm', dm_srcs, 'skia')
+GrabDependentSrcs('//:nanobench', nanobench_srcs, 'skia')
# No need to list headers.
-srcs = [s for s in srcs if not s.endswith('.h')]
+srcs = [s for s in srcs if not s.endswith('.h')]
+dm_srcs = [s for s in dm_srcs if not s.endswith('.h')]
+nanobench_srcs = [s for s in nanobench_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.
@@ -186,8 +284,10 @@ def scrub(lst):
return [os.path.relpath(p, '..') for p in lst]
# Turn a list of strings into the style bpfmt outputs.
-def bpfmt(indent, lst):
- return ('\n' + ' '*indent).join('"%s",' % v for v in sorted(lst))
+def bpfmt(indent, lst, sort=True):
+ if sort:
+ lst = sorted(lst)
+ return ('\n' + ' '*indent).join('"%s",' % v for v in lst)
# OK! We have everything to fill in Android.bp...
with open('Android.bp', 'w') as f:
@@ -206,7 +306,17 @@ with open('Android.bp', 'w') as f:
defs['sse41'] +
defs['sse42'] +
defs['avx' ] +
- defs['hsw' ]))
+ defs['hsw' ])),
+
+ 'tool_cflags' : bpfmt(8, tool_cflags),
+ 'tool_shared_libs' : bpfmt(8, tool_shared_libs),
+ 'tool_static_libs' : bpfmt(8, tool_static_libs, False),
+
+ 'dm_includes' : bpfmt(8, dm_includes),
+ 'dm_srcs' : bpfmt(8, dm_srcs),
+
+ 'nanobench_includes' : bpfmt(8, nanobench_includes),
+ 'nanobench_srcs' : bpfmt(8, nanobench_srcs),
})
#... and all the #defines we want to put in SkUserConfig.h.