1fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#!/usr/bin/env python 2fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot# 3fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot# Copyright 2016 Google Inc. 4fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot# 5fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot# Use of this source code is governed by a BSD-style license that can be 6fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot# found in the LICENSE file. 7fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 8fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot# Generate Android.bp for Skia from GN configuration. 9fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 10fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotimport json 11fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotimport os 12fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotimport pprint 13fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotimport string 14fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotimport subprocess 15fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotimport tempfile 16fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 17fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotimport gn_to_bp_utils 18fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 19fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot# First we start off with a template for Android.bp, 20fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot# with holes for source lists and include directories. 21fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotbp = string.Template('''// This file is autogenerated by gn_to_bp.py. 22fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 23fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotcc_library_static { 24fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot name: "libskia", 25fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot cflags: [ 26fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot $cflags 27fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 28fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 29fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot cppflags:[ 30fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot $cflags_cc 31fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 32fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 33fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot export_include_dirs: [ 34fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot $export_includes 35fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 36fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 37fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot local_include_dirs: [ 38fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot $local_includes 39fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 40fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 41fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot srcs: [ 42fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot $srcs 43fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 44fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 45fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot arch: { 46fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot arm: { 47fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot srcs: [ 48fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot $arm_srcs 49fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 50fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 51fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot neon: { 52fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot srcs: [ 53fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot $arm_neon_srcs 54fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 55fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot }, 56fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot }, 57fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 58fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot arm64: { 59fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot srcs: [ 60fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot $arm64_srcs 61fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 62fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot }, 63fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 64fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot mips: { 65fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot srcs: [ 66fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot $none_srcs 67fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 68fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot }, 69fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 70fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot mips64: { 71fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot srcs: [ 72fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot $none_srcs 73fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 74fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot }, 75fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 76fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot x86: { 77fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot srcs: [ 78fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot $x86_srcs 79fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 80fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot cflags: [ 81fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot // Clang seems to think new/malloc will only be 4-byte aligned 82fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot // on x86 Android. We're pretty sure it's actually 8-byte 83fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot // alignment. tests/OverAlignedTest.cpp has more information, 84fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot // and should fail if we're wrong. 85fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "-Wno-over-aligned" 86fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 87fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot }, 88fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 89fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot x86_64: { 90fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot srcs: [ 91fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot $x86_srcs 92fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 93fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot }, 94fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot }, 95fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 96fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot defaults: ["skia_deps", 97fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "skia_pgo", 98fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 99fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot} 100fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 101fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot// Build libskia with PGO by default. 102fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot// Location of PGO profile data is defined in build/soong/cc/pgo.go 103fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot// and is separate from skia. 104fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot// To turn it off, set ANDROID_PGO_NO_PROFILE_USE environment variable 105fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot// or set enable_profile_use property to false. 106fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotcc_defaults { 107fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot name: "skia_pgo", 108fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot pgo: { 109fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot instrumentation: true, 110fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot profile_file: "skia/skia.profdata", 111fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot benchmarks: ["hwui", "skia"], 112fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot enable_profile_use: true, 113fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot }, 114fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot} 115fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 116fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot// "defaults" property to disable profile use for Skia tools and benchmarks. 117fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotcc_defaults { 118fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot name: "skia_pgo_no_profile_use", 119fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot defaults: [ 120fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "skia_pgo", 121fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 122fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot pgo: { 123fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot enable_profile_use: false, 124fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot }, 125fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot} 126fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 127fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotcc_defaults { 128fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot name: "skia_deps", 129fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot shared_libs: [ 130fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libEGL", 131fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libGLESv2", 132fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libdng_sdk", 133fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libexpat", 134fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libft2", 135fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libheif", 136fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libicui18n", 137fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libicuuc", 138fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libjpeg", 139fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "liblog", 140fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libpiex", 141fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libpng", 142fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libvulkan", 143fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libz", 144fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libcutils", 145fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libnativewindow", 146fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 147fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot static_libs: [ 148fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libarect", 149fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libsfntly", 150fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libwebp-decode", 151fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libwebp-encode", 152fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 153fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot group_static_libs: true, 154fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot} 155fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 156fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotcc_defaults { 157fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot name: "skia_tool_deps", 158fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot defaults: [ 159fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "skia_deps", 160fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "skia_pgo_no_profile_use" 161fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 162fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot static_libs: [ 163fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libjsoncpp", 164fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "libskia", 165fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 166fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot cflags: [ 167fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "-Wno-unused-parameter", 168fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "-Wno-unused-variable", 169fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 170fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot} 171fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 172fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotcc_test { 173fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot name: "skia_dm", 174fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 175fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot defaults: [ 176fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "skia_tool_deps" 177fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 178fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 179fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot local_include_dirs: [ 180fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot $dm_includes 181fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 182fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 183fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot srcs: [ 184fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot $dm_srcs 185fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 186fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot} 187fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 188fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotcc_test { 189fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot name: "skia_nanobench", 190fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 191fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot defaults: [ 192fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "skia_tool_deps" 193fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 194fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 195fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot local_include_dirs: [ 196fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot $nanobench_includes 197fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 198fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 199fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot srcs: [ 200fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot $nanobench_srcs 201fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 202fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 203fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot data: [ 204fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "resources/*", 205fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ], 206fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot}''') 207fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 208fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot# We'll run GN to get the main source lists and include directories for Skia. 209fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotgn_args = { 210fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'is_official_build': 'true', 211fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'skia_enable_tools': 'true', 212fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'skia_use_libheif': 'true', 213fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'skia_use_vulkan': 'true', 214fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'target_cpu': '"none"', 215fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'target_os': '"android"', 216fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'skia_vulkan_header': '"Skia_Vulkan_Android.h"', 217fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot} 218fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 219fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotjs = gn_to_bp_utils.GenerateJSONFromGN(gn_args) 220fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 221fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotdef strip_slashes(lst): 222fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot return {str(p.lstrip('/')) for p in lst} 223fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 224fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotsrcs = strip_slashes(js['targets']['//:skia']['sources']) 225fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotcflags = strip_slashes(js['targets']['//:skia']['cflags']) 226fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotcflags_cc = strip_slashes(js['targets']['//:skia']['cflags_cc']) 227fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotlocal_includes = strip_slashes(js['targets']['//:skia']['include_dirs']) 228fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotexport_includes = strip_slashes(js['targets']['//:public']['include_dirs']) 229fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotdefines = [str(d) for d in js['targets']['//:skia']['defines']] 230fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 231fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotdm_srcs = strip_slashes(js['targets']['//:dm']['sources']) 232fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotdm_includes = strip_slashes(js['targets']['//:dm']['include_dirs']) 233fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 234fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotnanobench_target = js['targets']['//:nanobench'] 235fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotnanobench_srcs = strip_slashes(nanobench_target['sources']) 236fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotnanobench_includes = strip_slashes(nanobench_target['include_dirs']) 237fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 238fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotgn_to_bp_utils.GrabDependentValues(js, '//:skia', 'sources', srcs, None) 239fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotgn_to_bp_utils.GrabDependentValues(js, '//:dm', 'sources', dm_srcs, 'skia') 240fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotgn_to_bp_utils.GrabDependentValues(js, '//:nanobench', 'sources', 241fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot nanobench_srcs, 'skia') 242fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 243fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot# No need to list headers. 244fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotsrcs = {s for s in srcs if not s.endswith('.h')} 245fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotdm_srcs = {s for s in dm_srcs if not s.endswith('.h')} 246fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotnanobench_srcs = {s for s in nanobench_srcs if not s.endswith('.h')} 247fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 248fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotcflags = gn_to_bp_utils.CleanupCFlags(cflags) 249fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotcflags_cc = gn_to_bp_utils.CleanupCCFlags(cflags_cc) 250fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 251fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot# We need to add the include path to the vulkan defines and header file set in 252fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot# then skia_vulkan_header gn arg that is used for framework builds. 253fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotlocal_includes.add("platform_tools/android/vulkan") 254fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotexport_includes.add("platform_tools/android/vulkan") 255fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 256fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robothere = os.path.dirname(__file__) 257fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotdefs = gn_to_bp_utils.GetArchSources(os.path.join(here, 'opts.gni')) 258fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 259fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotgn_to_bp_utils.WriteUserConfig('include/config/SkUserConfig.h', defines) 260fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 261fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot# Turn a list of strings into the style bpfmt outputs. 262fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotdef bpfmt(indent, lst, sort=True): 263fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot if sort: 264fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot lst = sorted(lst) 265fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot return ('\n' + ' '*indent).join('"%s",' % v for v in lst) 266fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 267fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot# OK! We have everything to fill in Android.bp... 268fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotwith open('Android.bp', 'w') as f: 269fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot print >>f, bp.substitute({ 270fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'export_includes': bpfmt(8, export_includes), 271fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'local_includes': bpfmt(8, local_includes), 272fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'srcs': bpfmt(8, srcs), 273fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'cflags': bpfmt(8, cflags, False), 274fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'cflags_cc': bpfmt(8, cflags_cc), 275fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 276fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'arm_srcs': bpfmt(16, defs['armv7']), 277fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'arm_neon_srcs': bpfmt(20, defs['neon']), 278fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'arm64_srcs': bpfmt(16, defs['arm64'] + 279fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot defs['crc32']), 280fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'none_srcs': bpfmt(16, defs['none']), 281fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'x86_srcs': bpfmt(16, defs['sse2'] + 282fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot defs['ssse3'] + 283fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot defs['sse41'] + 284fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot defs['sse42'] + 285fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot defs['avx' ]), 286fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 287fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'dm_includes' : bpfmt(8, dm_includes), 288fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'dm_srcs' : bpfmt(8, dm_srcs), 289fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 290fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'nanobench_includes' : bpfmt(8, nanobench_includes), 291fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 'nanobench_srcs' : bpfmt(8, nanobench_srcs), 292fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot }) 293