aboutsummaryrefslogtreecommitdiffhomepage
path: root/gn/gn_to_bp.py
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2016-12-12 14:09:38 -0500
committerGravatar Mike Klein <mtklein@chromium.org>2016-12-12 19:32:27 +0000
commitee43f6f25e4ebd0a91ee208484f576dc9991a8e8 (patch)
treeffe37b839ca727b27e93b2fb2fe88caa12c62a8e /gn/gn_to_bp.py
parent3fc97d75ac14b323aa3365039fd35c0c643dd84d (diff)
Just make Android.bp bpfmt compliant to begin with.
Change-Id: I0fe833b4af4b68f97fe3feefc76503cb6473eb7b Reviewed-on: https://skia-review.googlesource.com/5847 Reviewed-by: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'gn/gn_to_bp.py')
-rw-r--r--gn/gn_to_bp.py187
1 files changed, 103 insertions, 84 deletions
diff --git a/gn/gn_to_bp.py b/gn/gn_to_bp.py
index 3e81042ace..39bac2f944 100644
--- a/gn/gn_to_bp.py
+++ b/gn/gn_to_bp.py
@@ -20,73 +20,92 @@ import tempfile
bp = string.Template('''// This file is autogenerated by gn_to_bp.py.
cc_library {
- name: "libskia",
- cflags: [
- "-fexceptions",
- "-Wno-unused-parameter",
- "-U_FORTIFY_SOURCE",
- "-D_FORTIFY_SOURCE=1",
- "-DSKIA_IMPLEMENTATION=1",
- ],
-
- 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,
+ name: "libskia",
+ cflags: [
+ "-fexceptions",
+ "-Wno-unused-parameter",
+ "-U_FORTIFY_SOURCE",
+ "-D_FORTIFY_SOURCE=1",
+ "-DSKIA_IMPLEMENTATION=1",
+ ],
+
+ 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
+ ],
+ },
+
+ mips: {
+ srcs: [
+ $mips_srcs
+ ],
+ },
+
+ mips64: {
+ srcs: [
+ $mips64_srcs
+ ],
+ },
+
+ x86: {
+ srcs: [
+ $x86_srcs
+ ],
+ },
+
+ x86_64: {
+ srcs: [
+ $x86_srcs
+ ],
+ },
},
- mips: {
- srcs: $mips_srcs,
- },
-
- mips64: {
- srcs: $mips64_srcs,
- },
-
- x86: {
- srcs: $x86_srcs,
- },
-
- x86_64: {
- srcs: $x86_srcs,
- },
- },
-
- shared_libs: [
- "libEGL",
- "libGLESv2",
- "libdng_sdk",
- "libexpat",
- "libft2",
- "libicui18n",
- "libicuuc",
- "libjpeg",
- "liblog",
- "libpiex",
- "libpng",
- "libvulkan",
- "libz",
- ],
- static_libs: [
- "libsfntly",
- "libwebp-decode",
- "libwebp-encode",
- ],
-}
-''')
+ shared_libs: [
+ "libEGL",
+ "libGLESv2",
+ "libdng_sdk",
+ "libexpat",
+ "libft2",
+ "libicui18n",
+ "libicuuc",
+ "libjpeg",
+ "liblog",
+ "libpiex",
+ "libpng",
+ "libvulkan",
+ "libz",
+ ],
+ static_libs: [
+ "libsfntly",
+ "libwebp-decode",
+ "libwebp-encode",
+ ],
+}''')
# We'll run GN to get the main source lists and include directories for Skia.
gn_args = {
@@ -166,29 +185,29 @@ def scrub(lst):
# Relativize paths to top-level skia/ directory.
return [os.path.relpath(p, '..') for p in lst]
-# Turn a list of strings into a pretty string version of a list of strings.
-def pretty(lst):
- return pprint.pformat(sorted(lst)).replace("'", '"')
+# 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))
# OK! We have everything to fill in Android.bp...
with open('Android.bp', 'w') as f:
print >>f, bp.substitute({
- 'export_includes': pretty(export_includes),
- 'local_includes': pretty(local_includes),
- 'srcs': pretty(srcs),
-
- 'arm_srcs': pretty(scrub(defs['armv7'])),
- 'arm_neon_srcs': pretty(scrub(defs['neon'])),
- 'arm64_srcs': pretty(scrub(defs['arm64'] +
- defs['crc32'])),
- 'mips_srcs': pretty(scrub(defs['mips_dsp'])),
- 'mips64_srcs': pretty(scrub(defs['none'])),
- 'x86_srcs': pretty(scrub(defs['sse2'] +
- defs['ssse3'] +
- defs['sse41'] +
- defs['sse42'] +
- defs['avx' ] +
- defs['hsw' ]))
+ 'export_includes': bpfmt(8, export_includes),
+ 'local_includes': bpfmt(8, local_includes),
+ 'srcs': bpfmt(8, srcs),
+
+ 'arm_srcs': bpfmt(16, scrub(defs['armv7'])),
+ 'arm_neon_srcs': bpfmt(20, scrub(defs['neon'])),
+ 'arm64_srcs': bpfmt(16, scrub(defs['arm64'] +
+ defs['crc32'])),
+ 'mips_srcs': bpfmt(16, scrub(defs['mips_dsp'])),
+ 'mips64_srcs': bpfmt(16, scrub(defs['none'])),
+ 'x86_srcs': bpfmt(16, scrub(defs['sse2'] +
+ defs['ssse3'] +
+ defs['sse41'] +
+ defs['sse42'] +
+ defs['avx' ] +
+ defs['hsw' ]))
})
#... and all the #defines we want to put in SkUserConfig.h.