2016-12-06 21:03:52 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
# Copyright 2016 Google Inc.
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
# Generate Android.bp for Skia from GN configuration.
|
|
|
|
|
|
|
|
import json
|
|
|
|
import os
|
|
|
|
import pprint
|
|
|
|
import string
|
|
|
|
import subprocess
|
|
|
|
import tempfile
|
|
|
|
|
2018-02-01 14:22:53 +00:00
|
|
|
import gn_to_bp_utils
|
|
|
|
|
2016-12-06 21:03:52 +00:00
|
|
|
# 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.
|
|
|
|
|
2017-09-21 18:25:14 +00:00
|
|
|
cc_library_static {
|
2016-12-12 19:09:38 +00:00
|
|
|
name: "libskia",
|
|
|
|
cflags: [
|
2017-10-06 15:53:53 +00:00
|
|
|
$cflags
|
|
|
|
],
|
|
|
|
|
|
|
|
cppflags:[
|
|
|
|
$cflags_cc
|
2016-12-12 19:09:38 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
export_include_dirs: [
|
|
|
|
$export_includes
|
|
|
|
],
|
|
|
|
|
|
|
|
local_include_dirs: [
|
|
|
|
$local_includes
|
|
|
|
],
|
|
|
|
|
|
|
|
srcs: [
|
|
|
|
$srcs
|
|
|
|
],
|
|
|
|
|
|
|
|
arch: {
|
|
|
|
arm: {
|
|
|
|
srcs: [
|
|
|
|
$arm_srcs
|
|
|
|
],
|
|
|
|
|
2017-08-10 13:09:54 +00:00
|
|
|
neon: {
|
2016-12-12 19:09:38 +00:00
|
|
|
srcs: [
|
|
|
|
$arm_neon_srcs
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
arm64: {
|
|
|
|
srcs: [
|
|
|
|
$arm64_srcs
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
mips: {
|
|
|
|
srcs: [
|
2016-12-20 22:34:29 +00:00
|
|
|
$none_srcs
|
2016-12-12 19:09:38 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
mips64: {
|
|
|
|
srcs: [
|
2016-12-20 22:34:29 +00:00
|
|
|
$none_srcs
|
2016-12-12 19:09:38 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
x86: {
|
|
|
|
srcs: [
|
|
|
|
$x86_srcs
|
|
|
|
],
|
2017-11-30 19:42:58 +00:00
|
|
|
cflags: [
|
2017-12-01 14:48:10 +00:00
|
|
|
// Clang seems to think new/malloc will only be 4-byte aligned
|
|
|
|
// on x86 Android. We're pretty sure it's actually 8-byte
|
|
|
|
// alignment. tests/OverAlignedTest.cpp has more information,
|
|
|
|
// and should fail if we're wrong.
|
2017-11-30 19:42:58 +00:00
|
|
|
"-Wno-over-aligned"
|
|
|
|
],
|
2016-12-12 19:09:38 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
x86_64: {
|
|
|
|
srcs: [
|
|
|
|
$x86_srcs
|
|
|
|
],
|
|
|
|
},
|
2016-12-06 21:03:52 +00:00
|
|
|
},
|
|
|
|
|
2017-12-11 18:37:44 +00:00
|
|
|
defaults: ["skia_deps",
|
|
|
|
"skia_pgo",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
// Build libskia with PGO by default.
|
|
|
|
// Location of PGO profile data is defined in build/soong/cc/pgo.go
|
|
|
|
// and is separate from skia.
|
|
|
|
// To turn it off, set ANDROID_PGO_NO_PROFILE_USE environment variable
|
|
|
|
// or set enable_profile_use property to false.
|
|
|
|
cc_defaults {
|
|
|
|
name: "skia_pgo",
|
|
|
|
pgo: {
|
|
|
|
instrumentation: true,
|
2018-03-05 18:20:38 +00:00
|
|
|
profile_file: "hwui/hwui.profdata",
|
2017-12-11 18:37:44 +00:00
|
|
|
benchmarks: ["hwui", "skia"],
|
2018-03-05 18:20:38 +00:00
|
|
|
enable_profile_use: true,
|
2017-12-11 18:37:44 +00:00
|
|
|
},
|
2017-09-21 18:25:14 +00:00
|
|
|
}
|
|
|
|
|
2017-12-13 19:07:39 +00:00
|
|
|
// "defaults" property to disable profile use for Skia tools and benchmarks.
|
|
|
|
cc_defaults {
|
|
|
|
name: "skia_pgo_no_profile_use",
|
|
|
|
defaults: [
|
|
|
|
"skia_pgo",
|
|
|
|
],
|
|
|
|
pgo: {
|
|
|
|
enable_profile_use: false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-09-21 18:25:14 +00:00
|
|
|
cc_defaults {
|
|
|
|
name: "skia_deps",
|
2016-12-12 19:09:38 +00:00
|
|
|
shared_libs: [
|
|
|
|
"libEGL",
|
|
|
|
"libGLESv2",
|
|
|
|
"libdng_sdk",
|
|
|
|
"libexpat",
|
|
|
|
"libft2",
|
2017-08-17 19:13:20 +00:00
|
|
|
"libheif",
|
2016-12-12 19:09:38 +00:00
|
|
|
"libicui18n",
|
|
|
|
"libicuuc",
|
|
|
|
"libjpeg",
|
|
|
|
"liblog",
|
|
|
|
"libpiex",
|
|
|
|
"libpng",
|
|
|
|
"libvulkan",
|
|
|
|
"libz",
|
2017-03-03 20:48:33 +00:00
|
|
|
"libcutils",
|
2017-06-02 14:29:21 +00:00
|
|
|
"libnativewindow",
|
2016-12-12 19:09:38 +00:00
|
|
|
],
|
|
|
|
static_libs: [
|
2017-02-20 17:50:52 +00:00
|
|
|
"libarect",
|
2016-12-12 19:09:38 +00:00
|
|
|
"libsfntly",
|
|
|
|
"libwebp-decode",
|
|
|
|
"libwebp-encode",
|
|
|
|
],
|
2017-09-21 18:25:14 +00:00
|
|
|
group_static_libs: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_defaults {
|
|
|
|
name: "skia_tool_deps",
|
|
|
|
defaults: [
|
2017-12-13 19:07:39 +00:00
|
|
|
"skia_deps",
|
|
|
|
"skia_pgo_no_profile_use"
|
2017-09-21 18:25:14 +00:00
|
|
|
],
|
|
|
|
static_libs: [
|
|
|
|
"libjsoncpp",
|
|
|
|
"libskia",
|
|
|
|
],
|
|
|
|
cflags: [
|
2017-12-14 18:01:30 +00:00
|
|
|
"-Wno-unused-parameter",
|
|
|
|
"-Wno-unused-variable",
|
2017-09-21 18:25:14 +00:00
|
|
|
],
|
2017-01-26 22:21:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_test {
|
|
|
|
name: "skia_dm",
|
|
|
|
|
2017-09-21 18:25:14 +00:00
|
|
|
defaults: [
|
|
|
|
"skia_tool_deps"
|
2017-01-26 22:21:27 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
local_include_dirs: [
|
|
|
|
$dm_includes
|
|
|
|
],
|
|
|
|
|
|
|
|
srcs: [
|
|
|
|
$dm_srcs
|
|
|
|
],
|
2018-02-16 18:55:21 +00:00
|
|
|
|
|
|
|
shared_libs: [
|
|
|
|
"libbinder",
|
|
|
|
"libutils",
|
|
|
|
],
|
2017-01-26 22:21:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_test {
|
|
|
|
name: "skia_nanobench",
|
|
|
|
|
2017-09-21 18:25:14 +00:00
|
|
|
defaults: [
|
|
|
|
"skia_tool_deps"
|
2017-01-26 22:21:27 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
local_include_dirs: [
|
|
|
|
$nanobench_includes
|
|
|
|
],
|
|
|
|
|
|
|
|
srcs: [
|
|
|
|
$nanobench_srcs
|
|
|
|
],
|
2018-01-10 05:05:55 +00:00
|
|
|
|
|
|
|
data: [
|
|
|
|
"resources/*",
|
|
|
|
],
|
2016-12-12 19:09:38 +00:00
|
|
|
}''')
|
2016-12-06 21:03:52 +00:00
|
|
|
|
|
|
|
# We'll run GN to get the main source lists and include directories for Skia.
|
|
|
|
gn_args = {
|
2017-03-03 14:21:30 +00:00
|
|
|
'is_official_build': 'true',
|
|
|
|
'skia_enable_tools': 'true',
|
2017-08-17 19:13:20 +00:00
|
|
|
'skia_use_libheif': 'true',
|
2017-03-03 14:21:30 +00:00
|
|
|
'skia_use_vulkan': 'true',
|
|
|
|
'target_cpu': '"none"',
|
|
|
|
'target_os': '"android"',
|
2017-12-07 17:48:30 +00:00
|
|
|
'skia_vulkan_header': '"Skia_Vulkan_Android.h"',
|
2016-12-06 21:03:52 +00:00
|
|
|
}
|
|
|
|
|
2018-02-01 14:22:53 +00:00
|
|
|
js = gn_to_bp_utils.GenerateJSONFromGN(gn_args)
|
2016-12-06 21:03:52 +00:00
|
|
|
|
|
|
|
def strip_slashes(lst):
|
2017-02-23 23:00:06 +00:00
|
|
|
return {str(p.lstrip('/')) for p in lst}
|
2016-12-07 17:27:56 +00:00
|
|
|
|
2016-12-06 21:03:52 +00:00
|
|
|
srcs = strip_slashes(js['targets']['//:skia']['sources'])
|
2017-10-06 15:53:53 +00:00
|
|
|
cflags = strip_slashes(js['targets']['//:skia']['cflags'])
|
|
|
|
cflags_cc = strip_slashes(js['targets']['//:skia']['cflags_cc'])
|
2016-12-06 21:03:52 +00:00
|
|
|
local_includes = strip_slashes(js['targets']['//:skia']['include_dirs'])
|
|
|
|
export_includes = strip_slashes(js['targets']['//:public']['include_dirs'])
|
2018-02-01 14:22:53 +00:00
|
|
|
defines = [str(d) for d in js['targets']['//:skia']['defines']]
|
2016-12-06 21:03:52 +00:00
|
|
|
|
2017-01-26 22:21:27 +00:00
|
|
|
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'])
|
|
|
|
|
2018-02-01 14:22:53 +00:00
|
|
|
gn_to_bp_utils.GrabDependentValues(js, '//:skia', 'sources', srcs, None)
|
|
|
|
gn_to_bp_utils.GrabDependentValues(js, '//:dm', 'sources', dm_srcs, 'skia')
|
|
|
|
gn_to_bp_utils.GrabDependentValues(js, '//:nanobench', 'sources',
|
|
|
|
nanobench_srcs, 'skia')
|
2016-12-07 17:27:56 +00:00
|
|
|
|
|
|
|
# No need to list headers.
|
2017-02-23 23:00:06 +00:00
|
|
|
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')}
|
2016-12-07 17:27:56 +00:00
|
|
|
|
2018-02-01 14:22:53 +00:00
|
|
|
cflags = gn_to_bp_utils.CleanupCFlags(cflags)
|
|
|
|
cflags_cc = gn_to_bp_utils.CleanupCCFlags(cflags_cc)
|
2017-10-06 15:53:53 +00:00
|
|
|
|
2017-12-07 17:48:30 +00:00
|
|
|
# We need to add the include path to the vulkan defines and header file set in
|
|
|
|
# then skia_vulkan_header gn arg that is used for framework builds.
|
|
|
|
local_includes.add("platform_tools/android/vulkan")
|
|
|
|
export_includes.add("platform_tools/android/vulkan")
|
|
|
|
|
2016-12-19 14:32:21 +00:00
|
|
|
here = os.path.dirname(__file__)
|
2018-02-01 14:22:53 +00:00
|
|
|
defs = gn_to_bp_utils.GetArchSources(os.path.join(here, 'opts.gni'))
|
2016-12-06 21:03:52 +00:00
|
|
|
|
2018-02-01 14:22:53 +00:00
|
|
|
gn_to_bp_utils.WriteUserConfig('include/config/SkUserConfig.h', defines)
|
2016-12-06 21:03:52 +00:00
|
|
|
|
2016-12-12 19:09:38 +00:00
|
|
|
# Turn a list of strings into the style bpfmt outputs.
|
2017-01-26 22:21:27 +00:00
|
|
|
def bpfmt(indent, lst, sort=True):
|
|
|
|
if sort:
|
|
|
|
lst = sorted(lst)
|
|
|
|
return ('\n' + ' '*indent).join('"%s",' % v for v in lst)
|
2016-12-06 21:03:52 +00:00
|
|
|
|
|
|
|
# OK! We have everything to fill in Android.bp...
|
|
|
|
with open('Android.bp', 'w') as f:
|
|
|
|
print >>f, bp.substitute({
|
2016-12-12 19:09:38 +00:00
|
|
|
'export_includes': bpfmt(8, export_includes),
|
|
|
|
'local_includes': bpfmt(8, local_includes),
|
|
|
|
'srcs': bpfmt(8, srcs),
|
2017-10-06 15:53:53 +00:00
|
|
|
'cflags': bpfmt(8, cflags, False),
|
|
|
|
'cflags_cc': bpfmt(8, cflags_cc),
|
2016-12-12 19:09:38 +00:00
|
|
|
|
2018-02-01 14:22:53 +00:00
|
|
|
'arm_srcs': bpfmt(16, defs['armv7']),
|
|
|
|
'arm_neon_srcs': bpfmt(20, defs['neon']),
|
|
|
|
'arm64_srcs': bpfmt(16, defs['arm64'] +
|
|
|
|
defs['crc32']),
|
|
|
|
'none_srcs': bpfmt(16, defs['none']),
|
|
|
|
'x86_srcs': bpfmt(16, defs['sse2'] +
|
|
|
|
defs['ssse3'] +
|
|
|
|
defs['sse41'] +
|
|
|
|
defs['sse42'] +
|
Reland "Reland "make SkJumper stages normal Skia code""
This is a reland of 78cb579f33943421afc8423a39867fcfd69fed44
This time, lowp stages are controlled by !defined(JUMPER_IS_SCALAR), not
by defined(__clang__). The two are usually the same, except when we opt
Clang builds into JUMPER_IS_SCALAR artificially.
Some Google3 builds use compilers old enough that they barf when
compiling our NEON code. It's conceivably also possible to define
JUMPER_IS_SCALAR yourself, but I don't think anyone does that.
Original change's description:
> Reland "make SkJumper stages normal Skia code"
>
> This is a reland of 22e536e3a1a09405d1c0e6f071717a726d86e8d4
>
> Now with fixed #include paths in SkRasterPipeline_opts.h,
> and -ffp-contract=fast for the :hsw target to minimize
> diffs on non-Windows Clang AVX2/AVX-512 bots.
>
> Original change's description:
> > make SkJumper stages normal Skia code
> >
> > Enough clients are using Clang now that we can say, use Clang to build
> > if you want these software pipeline stages to go fast.
> >
> > This lets us drop the offline build aspect of SkJumper stages, instead
> > building as part of Skia using the SkOpts framework.
> >
> > I think everything should work, except I've (temporarily) removed
> > AVX-512 support. I will put this back in a follow up.
> >
> > I have had to drop Windows down to __vectorcall and our narrower
> > stage calling convention that keeps the d-registers on the stack.
> > I tried forcing sysv_abi, but that crashed Clang. :/
> >
> > Added a TODO to up the same narrower stage calling convention
> > for lowp stages... we just *don't* today, for no good reason.
> >
> > Change-Id: Iaaa792ffe4deab3508d2dc5d0008c163c24b3383
> > Reviewed-on: https://skia-review.googlesource.com/110641
> > Commit-Queue: Mike Klein <mtklein@chromium.org>
> > Reviewed-by: Herb Derby <herb@google.com>
> > Reviewed-by: Florin Malita <fmalita@chromium.org>
>
> Change-Id: I44f2c03d33958e3807747e40904b6351957dd448
> Reviewed-on: https://skia-review.googlesource.com/112742
> Reviewed-by: Mike Klein <mtklein@chromium.org>
Change-Id: I3d71197d4bbb19ca4a94961a97fa2e54d5cbfb0d
Reviewed-on: https://skia-review.googlesource.com/112744
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2018-02-27 15:37:40 +00:00
|
|
|
defs['avx' ] +
|
|
|
|
defs['hsw' ]),
|
2017-01-26 22:21:27 +00:00
|
|
|
|
|
|
|
'dm_includes' : bpfmt(8, dm_includes),
|
|
|
|
'dm_srcs' : bpfmt(8, dm_srcs),
|
|
|
|
|
|
|
|
'nanobench_includes' : bpfmt(8, nanobench_includes),
|
|
|
|
'nanobench_srcs' : bpfmt(8, nanobench_srcs),
|
2016-12-06 21:03:52 +00:00
|
|
|
})
|