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.
|
|
|
|
|
2020-03-03 06:53:20 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2016-12-06 21:03:52 +00:00
|
|
|
import os
|
|
|
|
import pprint
|
2022-04-28 22:24:17 +00:00
|
|
|
import shutil
|
2016-12-06 21:03:52 +00:00
|
|
|
import string
|
|
|
|
import subprocess
|
|
|
|
import tempfile
|
|
|
|
|
2022-01-06 21:39:39 +00:00
|
|
|
import skqp_gn_args
|
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.
|
2020-11-10 22:53:19 +00:00
|
|
|
// To make changes to this file, follow the instructions on skia.org for
|
|
|
|
// downloading Skia and submitting changes. Modify gn_to_bp.py (or the build
|
|
|
|
// files it uses) and submit. The autoroller will then create the updated
|
|
|
|
// Android.bp. Or ask a Skia engineer for help.
|
2016-12-06 21:03:52 +00:00
|
|
|
|
2021-04-30 19:12:36 +00:00
|
|
|
package {
|
|
|
|
default_applicable_licenses: ["external_skia_license"],
|
|
|
|
}
|
|
|
|
|
|
|
|
// Added automatically by a large-scale-change that took the approach of
|
|
|
|
// 'apply every license found to every target'. While this makes sure we respect
|
|
|
|
// every license restriction, it may not be entirely correct.
|
|
|
|
//
|
|
|
|
// e.g. GPL in an MIT project might only apply to the contrib/ directory.
|
|
|
|
//
|
|
|
|
// Please consider splitting the single license below into multiple licenses,
|
|
|
|
// taking care not to lose any license_kind information, and overriding the
|
|
|
|
// default license using the 'licenses: [...]' property on targets as needed.
|
|
|
|
//
|
|
|
|
// For unused files, consider creating a 'fileGroup' with "//visibility:private"
|
|
|
|
// to attach the license to, and including a comment whether the files may be
|
|
|
|
// used in the current project.
|
|
|
|
//
|
|
|
|
// large-scale-change included anything that looked like it might be a license
|
|
|
|
// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
|
|
|
|
//
|
|
|
|
// Please consider removing redundant or irrelevant files from 'license_text:'.
|
|
|
|
//
|
|
|
|
// large-scale-change filtered out the below license kinds as false-positives:
|
|
|
|
// SPDX-license-identifier-CC-BY-NC
|
|
|
|
// SPDX-license-identifier-GPL-2.0
|
|
|
|
// SPDX-license-identifier-LGPL-2.1
|
|
|
|
// SPDX-license-identifier-OFL:by_exception_only
|
|
|
|
// See: http://go/android-license-faq
|
|
|
|
license {
|
|
|
|
name: "external_skia_license",
|
|
|
|
visibility: [":__subpackages__"],
|
|
|
|
license_kinds: [
|
|
|
|
"SPDX-license-identifier-Apache-2.0",
|
|
|
|
"SPDX-license-identifier-BSD",
|
|
|
|
"SPDX-license-identifier-CC0-1.0",
|
|
|
|
"SPDX-license-identifier-FTL",
|
|
|
|
"SPDX-license-identifier-MIT",
|
|
|
|
"legacy_unencumbered",
|
|
|
|
],
|
|
|
|
license_text: [
|
|
|
|
"LICENSE",
|
|
|
|
"NOTICE",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
2021-01-29 20:33:00 +00:00
|
|
|
cc_defaults {
|
2022-01-06 21:39:39 +00:00
|
|
|
name: "skia_arch_defaults",
|
2016-12-12 19:09:38 +00:00
|
|
|
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
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
x86: {
|
|
|
|
srcs: [
|
|
|
|
$x86_srcs
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
x86_64: {
|
|
|
|
srcs: [
|
|
|
|
$x86_srcs
|
|
|
|
],
|
|
|
|
},
|
2016-12-06 21:03:52 +00:00
|
|
|
},
|
|
|
|
|
2018-11-15 20:54:59 +00:00
|
|
|
target: {
|
|
|
|
android: {
|
|
|
|
srcs: [
|
|
|
|
"third_party/vulkanmemoryallocator/GrVulkanMemoryAllocator.cpp",
|
|
|
|
],
|
|
|
|
local_include_dirs: [
|
|
|
|
"third_party/vulkanmemoryallocator/",
|
2022-04-28 22:24:17 +00:00
|
|
|
"vma_android/include",
|
2018-11-15 20:54:59 +00:00
|
|
|
],
|
2021-01-29 20:33:00 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-01-06 21:39:39 +00:00
|
|
|
cc_defaults {
|
|
|
|
name: "skia_defaults",
|
|
|
|
defaults: ["skia_arch_defaults"],
|
|
|
|
cflags: [
|
|
|
|
$cflags
|
|
|
|
],
|
|
|
|
|
|
|
|
cppflags:[
|
|
|
|
$cflags_cc
|
|
|
|
],
|
|
|
|
|
|
|
|
export_include_dirs: [
|
|
|
|
$export_includes
|
|
|
|
],
|
|
|
|
|
|
|
|
local_include_dirs: [
|
|
|
|
$local_includes
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2021-01-29 20:33:00 +00:00
|
|
|
cc_library_static {
|
|
|
|
// Smaller version of Skia, without e.g. codecs, intended for use by RenderEngine.
|
|
|
|
name: "libskia_renderengine",
|
|
|
|
defaults: ["skia_defaults",
|
|
|
|
"skia_renderengine_deps"],
|
|
|
|
srcs: [
|
|
|
|
$renderengine_srcs
|
|
|
|
],
|
|
|
|
local_include_dirs: [
|
|
|
|
"renderengine",
|
|
|
|
],
|
|
|
|
export_include_dirs: [
|
|
|
|
"renderengine",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_static {
|
|
|
|
name: "libskia",
|
|
|
|
host_supported: true,
|
|
|
|
cppflags:[
|
|
|
|
// Exceptions are necessary for SkRawCodec.
|
|
|
|
// FIXME: Should we split SkRawCodec into a separate target so the rest
|
|
|
|
// of Skia need not be compiled with exceptions?
|
|
|
|
"-fexceptions",
|
|
|
|
],
|
|
|
|
|
|
|
|
srcs: [
|
|
|
|
$srcs
|
|
|
|
],
|
|
|
|
|
|
|
|
target: {
|
|
|
|
android: {
|
|
|
|
srcs: [
|
|
|
|
$android_srcs
|
|
|
|
],
|
|
|
|
local_include_dirs: [
|
|
|
|
"android",
|
|
|
|
],
|
2018-11-15 20:54:59 +00:00
|
|
|
export_include_dirs: [
|
2019-04-23 17:05:21 +00:00
|
|
|
"android",
|
2018-11-15 20:54:59 +00:00
|
|
|
],
|
|
|
|
},
|
2022-03-18 17:12:38 +00:00
|
|
|
host_linux: {
|
2018-11-15 20:54:59 +00:00
|
|
|
srcs: [
|
|
|
|
$linux_srcs
|
|
|
|
],
|
|
|
|
local_include_dirs: [
|
2019-04-23 17:05:21 +00:00
|
|
|
"linux",
|
2018-11-15 20:54:59 +00:00
|
|
|
],
|
|
|
|
export_include_dirs: [
|
2019-04-23 17:05:21 +00:00
|
|
|
"linux",
|
2018-11-15 20:54:59 +00:00
|
|
|
],
|
|
|
|
},
|
2018-11-28 13:58:47 +00:00
|
|
|
darwin: {
|
|
|
|
srcs: [
|
|
|
|
$mac_srcs
|
|
|
|
],
|
|
|
|
local_include_dirs: [
|
2019-04-23 17:05:21 +00:00
|
|
|
"mac",
|
2018-11-28 13:58:47 +00:00
|
|
|
],
|
|
|
|
export_include_dirs: [
|
2019-04-23 17:05:21 +00:00
|
|
|
"mac",
|
2018-11-28 13:58:47 +00:00
|
|
|
],
|
|
|
|
},
|
2019-02-27 15:59:11 +00:00
|
|
|
windows: {
|
2020-11-10 22:53:19 +00:00
|
|
|
enabled: true,
|
2019-02-27 15:59:11 +00:00
|
|
|
cflags: [
|
|
|
|
"-Wno-unknown-pragmas",
|
|
|
|
],
|
|
|
|
srcs: [
|
|
|
|
$win_srcs
|
|
|
|
],
|
|
|
|
local_include_dirs: [
|
2019-04-23 17:05:21 +00:00
|
|
|
"win",
|
2019-02-27 15:59:11 +00:00
|
|
|
],
|
|
|
|
export_include_dirs: [
|
2019-04-23 17:05:21 +00:00
|
|
|
"win",
|
2019-02-27 15:59:11 +00:00
|
|
|
],
|
|
|
|
},
|
2018-11-15 20:54:59 +00:00
|
|
|
},
|
|
|
|
|
2017-12-11 18:37:44 +00:00
|
|
|
defaults: ["skia_deps",
|
2021-01-29 20:33:00 +00:00
|
|
|
"skia_defaults",
|
2017-12-11 18:37:44 +00:00
|
|
|
],
|
|
|
|
}
|
|
|
|
|
2017-09-21 18:25:14 +00:00
|
|
|
cc_defaults {
|
2021-01-29 20:33:00 +00:00
|
|
|
// Subset of the larger "skia_deps", which includes only the dependencies
|
|
|
|
// needed for libskia_renderengine. Note that it includes libpng and libz
|
|
|
|
// for the purposes of MSKP captures, but we could instead leave it up to
|
|
|
|
// RenderEngine to provide its own SkSerializerProcs if another client
|
|
|
|
// wants an even smaller version of libskia.
|
|
|
|
name: "skia_renderengine_deps",
|
2016-12-12 19:09:38 +00:00
|
|
|
shared_libs: [
|
2020-10-27 13:35:00 +00:00
|
|
|
"libcutils",
|
2016-12-12 19:09:38 +00:00
|
|
|
"liblog",
|
|
|
|
"libpng",
|
|
|
|
"libz",
|
|
|
|
],
|
|
|
|
static_libs: [
|
2017-02-20 17:50:52 +00:00
|
|
|
"libarect",
|
2016-12-12 19:09:38 +00:00
|
|
|
],
|
2017-09-21 18:25:14 +00:00
|
|
|
group_static_libs: true,
|
2018-11-15 20:54:59 +00:00
|
|
|
target: {
|
|
|
|
android: {
|
|
|
|
shared_libs: [
|
|
|
|
"libEGL",
|
|
|
|
"libGLESv2",
|
|
|
|
"libvulkan",
|
|
|
|
"libnativewindow",
|
|
|
|
],
|
2019-03-11 17:33:02 +00:00
|
|
|
export_shared_lib_headers: [
|
|
|
|
"libvulkan",
|
|
|
|
],
|
2018-11-15 20:54:59 +00:00
|
|
|
},
|
2021-01-29 20:33:00 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_defaults {
|
|
|
|
name: "skia_deps",
|
|
|
|
defaults: ["skia_renderengine_deps"],
|
|
|
|
shared_libs: [
|
|
|
|
"libdng_sdk",
|
|
|
|
"libjpeg",
|
|
|
|
"libpiex",
|
|
|
|
"libexpat",
|
|
|
|
"libft2",
|
|
|
|
],
|
|
|
|
static_libs: [
|
|
|
|
"libwebp-decode",
|
|
|
|
"libwebp-encode",
|
|
|
|
"libsfntly",
|
2021-12-08 00:09:10 +00:00
|
|
|
"libwuffs_mirror_release_c",
|
2021-01-29 20:33:00 +00:00
|
|
|
],
|
|
|
|
target: {
|
|
|
|
android: {
|
|
|
|
shared_libs: [
|
|
|
|
"libheif",
|
|
|
|
],
|
|
|
|
},
|
2018-11-28 13:58:47 +00:00
|
|
|
darwin: {
|
|
|
|
host_ldlibs: [
|
|
|
|
"-framework AppKit",
|
|
|
|
],
|
|
|
|
},
|
2019-02-27 15:59:11 +00:00
|
|
|
windows: {
|
|
|
|
host_ldlibs: [
|
|
|
|
"-lgdi32",
|
|
|
|
"-loleaut32",
|
|
|
|
"-lole32",
|
|
|
|
"-lopengl32",
|
|
|
|
"-luuid",
|
|
|
|
"-lwindowscodecs",
|
|
|
|
],
|
|
|
|
},
|
2018-11-15 20:54:59 +00:00
|
|
|
},
|
2017-09-21 18:25:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_defaults {
|
|
|
|
name: "skia_tool_deps",
|
|
|
|
defaults: [
|
2017-12-13 19:07:39 +00:00
|
|
|
"skia_deps",
|
2017-09-21 18:25:14 +00:00
|
|
|
],
|
2020-05-27 20:49:23 +00:00
|
|
|
shared_libs: [
|
2020-11-23 19:26:59 +00:00
|
|
|
"libicu",
|
2020-05-27 20:49:23 +00:00
|
|
|
"libharfbuzz_ng",
|
|
|
|
],
|
2017-09-21 18:25:14 +00:00
|
|
|
static_libs: [
|
|
|
|
"libskia",
|
|
|
|
],
|
|
|
|
cflags: [
|
2020-05-27 20:49:23 +00:00
|
|
|
"-DSK_SHAPER_HARFBUZZ_AVAILABLE",
|
2020-08-26 14:22:48 +00:00
|
|
|
"-DSK_UNICODE_AVAILABLE",
|
2018-09-11 18:48:36 +00:00
|
|
|
"-Wno-implicit-fallthrough",
|
2017-12-14 18:01:30 +00:00
|
|
|
"-Wno-unused-parameter",
|
|
|
|
"-Wno-unused-variable",
|
2017-09-21 18:25:14 +00:00
|
|
|
],
|
2020-11-10 22:53:19 +00:00
|
|
|
target: {
|
|
|
|
windows: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
},
|
2022-01-05 15:58:20 +00:00
|
|
|
|
|
|
|
data: [
|
|
|
|
"resources/**/*",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_defaults {
|
|
|
|
name: "skia_gm_srcs",
|
|
|
|
local_include_dirs: [
|
|
|
|
$gm_includes
|
|
|
|
],
|
|
|
|
|
|
|
|
srcs: [
|
|
|
|
$gm_srcs
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_defaults {
|
|
|
|
name: "skia_test_minus_gm_srcs",
|
|
|
|
local_include_dirs: [
|
|
|
|
$test_minus_gm_includes
|
|
|
|
],
|
|
|
|
|
|
|
|
srcs: [
|
|
|
|
$test_minus_gm_srcs
|
|
|
|
],
|
2017-01-26 22:21:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_test {
|
|
|
|
name: "skia_dm",
|
|
|
|
|
2017-09-21 18:25:14 +00:00
|
|
|
defaults: [
|
2022-01-05 15:58:20 +00:00
|
|
|
"skia_gm_srcs",
|
|
|
|
"skia_test_minus_gm_srcs",
|
|
|
|
"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: [
|
2022-01-05 15:58:20 +00:00
|
|
|
"skia_gm_srcs",
|
2017-09-21 18:25:14 +00:00
|
|
|
"skia_tool_deps"
|
2017-01-26 22:21:27 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
local_include_dirs: [
|
|
|
|
$nanobench_includes
|
|
|
|
],
|
|
|
|
|
|
|
|
srcs: [
|
|
|
|
$nanobench_srcs
|
|
|
|
],
|
2022-01-15 08:05:22 +00:00
|
|
|
|
|
|
|
lto: {
|
|
|
|
never: true,
|
|
|
|
},
|
2022-01-05 15:58:20 +00:00
|
|
|
}
|
2018-01-10 05:05:55 +00:00
|
|
|
|
2022-01-06 21:39:39 +00:00
|
|
|
cc_library_shared {
|
|
|
|
name: "libskqp_jni",
|
|
|
|
sdk_version: "$skqp_sdk_version",
|
|
|
|
stl: "libc++_static",
|
|
|
|
compile_multilib: "both",
|
|
|
|
|
|
|
|
defaults: [
|
|
|
|
"skia_arch_defaults",
|
|
|
|
],
|
|
|
|
|
|
|
|
cflags: [
|
|
|
|
$skqp_cflags
|
|
|
|
"-Wno-unused-parameter",
|
|
|
|
"-Wno-unused-variable",
|
|
|
|
],
|
|
|
|
|
|
|
|
cppflags:[
|
|
|
|
$skqp_cflags_cc
|
|
|
|
],
|
|
|
|
|
|
|
|
local_include_dirs: [
|
|
|
|
"skqp",
|
|
|
|
$skqp_includes
|
|
|
|
],
|
|
|
|
|
|
|
|
export_include_dirs: [
|
|
|
|
"skqp",
|
|
|
|
],
|
|
|
|
|
|
|
|
srcs: [
|
|
|
|
$skqp_srcs
|
|
|
|
],
|
|
|
|
|
|
|
|
header_libs: ["jni_headers"],
|
|
|
|
|
|
|
|
shared_libs: [
|
|
|
|
"libandroid",
|
|
|
|
"libEGL",
|
|
|
|
"libGLESv2",
|
|
|
|
"liblog",
|
|
|
|
"libvulkan",
|
|
|
|
"libz",
|
|
|
|
],
|
|
|
|
static_libs: [
|
|
|
|
"libexpat",
|
|
|
|
"libjpeg_static_ndk",
|
|
|
|
"libpng_ndk",
|
|
|
|
"libwebp-decode",
|
|
|
|
"libwebp-encode",
|
|
|
|
"libwuffs_mirror_release_c",
|
|
|
|
]
|
|
|
|
}
|
2022-02-10 20:43:00 +00:00
|
|
|
|
|
|
|
android_test {
|
|
|
|
name: "CtsSkQPTestCases",
|
|
|
|
defaults: ["cts_defaults"],
|
2022-03-04 21:03:05 +00:00
|
|
|
test_suites: [
|
|
|
|
"general-tests",
|
|
|
|
"cts",
|
|
|
|
],
|
2022-02-10 20:43:00 +00:00
|
|
|
|
|
|
|
libs: ["android.test.runner.stubs"],
|
|
|
|
jni_libs: ["libskqp_jni"],
|
|
|
|
compile_multilib: "both",
|
|
|
|
|
|
|
|
static_libs: [
|
|
|
|
"android-support-design",
|
|
|
|
"ctstestrunner-axt",
|
|
|
|
],
|
|
|
|
manifest: "platform_tools/android/apps/skqp/src/main/AndroidManifest.xml",
|
|
|
|
test_config: "platform_tools/android/apps/skqp/src/main/AndroidTest.xml",
|
|
|
|
|
|
|
|
asset_dirs: ["platform_tools/android/apps/skqp/src/main/assets", "resources"],
|
|
|
|
resource_dirs: ["platform_tools/android/apps/skqp/src/main/res"],
|
|
|
|
srcs: ["platform_tools/android/apps/skqp/src/main/java/**/*.java"],
|
|
|
|
|
|
|
|
sdk_version: "test_current",
|
2022-03-01 17:18:50 +00:00
|
|
|
|
2022-02-10 20:43:00 +00:00
|
|
|
}
|
2022-01-05 15:58:20 +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.
|
2021-01-29 20:33:00 +00:00
|
|
|
def generate_args(target_os, enable_gpu, renderengine = False):
|
2018-11-28 21:09:35 +00:00
|
|
|
d = {
|
2020-06-03 17:20:37 +00:00
|
|
|
'is_official_build': 'true',
|
2018-11-28 21:09:35 +00:00
|
|
|
|
|
|
|
# gn_to_bp_utils' GetArchSources will take care of architecture-specific
|
|
|
|
# files.
|
2020-06-03 17:20:37 +00:00
|
|
|
'target_cpu': '"none"',
|
2018-11-28 21:09:35 +00:00
|
|
|
|
|
|
|
# Use the custom FontMgr, as the framework will handle fonts.
|
2020-06-03 17:20:37 +00:00
|
|
|
'skia_enable_fontmgr_custom_directory': 'false',
|
|
|
|
'skia_enable_fontmgr_custom_embedded': 'false',
|
|
|
|
'skia_enable_fontmgr_android': 'false',
|
|
|
|
'skia_enable_fontmgr_win': 'false',
|
|
|
|
'skia_enable_fontmgr_win_gdi': 'false',
|
|
|
|
'skia_use_fonthost_mac': 'false',
|
2018-11-28 21:09:35 +00:00
|
|
|
|
2019-10-16 15:21:47 +00:00
|
|
|
# enable features used in skia_nanobench
|
2020-06-03 17:20:37 +00:00
|
|
|
'skia_tools_require_resources': 'true',
|
|
|
|
|
|
|
|
'skia_use_fontconfig': 'false',
|
|
|
|
'skia_include_multiframe_procs': 'false',
|
2022-04-12 12:23:07 +00:00
|
|
|
# Required for some SKSL tests
|
|
|
|
'skia_enable_sksl_tracing': 'true',
|
2018-11-28 21:09:35 +00:00
|
|
|
}
|
|
|
|
d['target_os'] = target_os
|
|
|
|
if target_os == '"android"':
|
|
|
|
d['skia_enable_tools'] = 'true'
|
2019-06-25 19:48:47 +00:00
|
|
|
d['skia_include_multiframe_procs'] = 'true'
|
2018-11-28 21:09:35 +00:00
|
|
|
|
|
|
|
if enable_gpu:
|
|
|
|
d['skia_use_vulkan'] = 'true'
|
|
|
|
else:
|
|
|
|
d['skia_use_vulkan'] = 'false'
|
|
|
|
d['skia_enable_gpu'] = 'false'
|
2019-02-27 15:59:11 +00:00
|
|
|
|
|
|
|
if target_os == '"win"':
|
|
|
|
# The Android Windows build system does not provide FontSub.h
|
|
|
|
d['skia_use_xps'] = 'false'
|
|
|
|
|
|
|
|
# BUILDCONFIG.gn expects these to be set when building for Windows, but
|
|
|
|
# we're just creating Android.bp, so we don't need them. Populate with
|
2021-01-29 16:05:41 +00:00
|
|
|
# some placeholder values.
|
|
|
|
d['win_vc'] = '"placeholder_version"'
|
|
|
|
d['win_sdk_version'] = '"placeholder_version"'
|
|
|
|
d['win_toolchain_version'] = '"placeholder_version"'
|
2021-01-29 20:33:00 +00:00
|
|
|
|
|
|
|
if target_os == '"android"' and not renderengine:
|
|
|
|
d['skia_use_libheif'] = 'true'
|
|
|
|
else:
|
|
|
|
d['skia_use_libheif'] = 'false'
|
|
|
|
|
|
|
|
if renderengine:
|
|
|
|
d['skia_use_libpng_decode'] = 'false'
|
|
|
|
d['skia_use_libjpeg_turbo_decode'] = 'false'
|
|
|
|
d['skia_use_libjpeg_turbo_encode'] = 'false'
|
|
|
|
d['skia_use_libwebp_decode'] = 'false'
|
|
|
|
d['skia_use_libwebp_encode'] = 'false'
|
|
|
|
d['skia_use_libgifcodec'] = 'false'
|
|
|
|
d['skia_enable_pdf'] = 'false'
|
|
|
|
d['skia_use_freetype'] = 'false'
|
|
|
|
d['skia_use_fixed_gamma_text'] = 'false'
|
|
|
|
d['skia_use_expat'] = 'false'
|
|
|
|
d['skia_enable_fontmgr_custom_empty'] = 'false'
|
|
|
|
else:
|
|
|
|
d['skia_enable_android_utils'] = 'true'
|
|
|
|
d['skia_use_freetype'] = 'true'
|
|
|
|
d['skia_use_fixed_gamma_text'] = 'true'
|
|
|
|
d['skia_enable_fontmgr_custom_empty'] = 'true'
|
2021-12-08 00:09:10 +00:00
|
|
|
d['skia_use_wuffs'] = 'true'
|
2021-01-29 20:33:00 +00:00
|
|
|
|
2018-11-28 21:09:35 +00:00
|
|
|
return d
|
|
|
|
|
|
|
|
gn_args = generate_args('"android"', True)
|
|
|
|
gn_args_linux = generate_args('"linux"', False)
|
|
|
|
gn_args_mac = generate_args('"mac"', False)
|
2019-02-27 15:59:11 +00:00
|
|
|
gn_args_win = generate_args('"win"', False)
|
2021-01-29 20:33:00 +00:00
|
|
|
gn_args_renderengine = generate_args('"android"', True, True)
|
2018-11-28 13:58:47 +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
|
|
|
|
2018-11-15 20:54:59 +00:00
|
|
|
android_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'])
|
|
|
|
|
2022-01-05 15:58:20 +00:00
|
|
|
gm_srcs = strip_slashes(js['targets']['//:gm']['sources'])
|
|
|
|
gm_includes = strip_slashes(js['targets']['//:gm']['include_dirs'])
|
|
|
|
|
|
|
|
test_srcs = strip_slashes(js['targets']['//:tests']['sources'])
|
|
|
|
test_includes = strip_slashes(js['targets']['//:tests']['include_dirs'])
|
|
|
|
|
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'])
|
|
|
|
|
2022-01-05 15:58:20 +00:00
|
|
|
|
|
|
|
gn_to_bp_utils.GrabDependentValues(js, '//:gm', 'sources', gm_srcs, '//:skia')
|
|
|
|
gn_to_bp_utils.GrabDependentValues(js, '//:tests', 'sources', test_srcs, '//:skia')
|
|
|
|
gn_to_bp_utils.GrabDependentValues(js, '//:dm', 'sources',
|
|
|
|
dm_srcs, ['//:skia', '//:gm', '//:tests'])
|
2018-02-01 14:22:53 +00:00
|
|
|
gn_to_bp_utils.GrabDependentValues(js, '//:nanobench', 'sources',
|
2022-01-05 15:58:20 +00:00
|
|
|
nanobench_srcs, ['//:skia', '//:gm'])
|
2016-12-07 17:27:56 +00:00
|
|
|
|
2018-05-01 14:36:42 +00:00
|
|
|
# skcms is a little special, kind of a second-party library.
|
2019-05-01 15:03:36 +00:00
|
|
|
local_includes.add("include/third_party/skcms")
|
2022-01-05 15:58:20 +00:00
|
|
|
gm_includes .add("include/third_party/skcms")
|
2018-05-01 14:36:42 +00:00
|
|
|
|
2018-09-05 19:55:25 +00:00
|
|
|
# Android's build will choke if we list headers.
|
|
|
|
def strip_headers(sources):
|
|
|
|
return {s for s in sources if not s.endswith('.h')}
|
|
|
|
|
2018-11-15 20:54:59 +00:00
|
|
|
gn_to_bp_utils.GrabDependentValues(js, '//:skia', 'sources', android_srcs, None)
|
|
|
|
android_srcs = strip_headers(android_srcs)
|
|
|
|
|
|
|
|
js_linux = gn_to_bp_utils.GenerateJSONFromGN(gn_args_linux)
|
|
|
|
linux_srcs = strip_slashes(js_linux['targets']['//:skia']['sources'])
|
|
|
|
gn_to_bp_utils.GrabDependentValues(js_linux, '//:skia', 'sources', linux_srcs,
|
|
|
|
None)
|
|
|
|
linux_srcs = strip_headers(linux_srcs)
|
|
|
|
|
2018-11-28 13:58:47 +00:00
|
|
|
js_mac = gn_to_bp_utils.GenerateJSONFromGN(gn_args_mac)
|
|
|
|
mac_srcs = strip_slashes(js_mac['targets']['//:skia']['sources'])
|
|
|
|
gn_to_bp_utils.GrabDependentValues(js_mac, '//:skia', 'sources', mac_srcs,
|
|
|
|
None)
|
|
|
|
mac_srcs = strip_headers(mac_srcs)
|
|
|
|
|
2019-02-27 15:59:11 +00:00
|
|
|
js_win = gn_to_bp_utils.GenerateJSONFromGN(gn_args_win)
|
|
|
|
win_srcs = strip_slashes(js_win['targets']['//:skia']['sources'])
|
|
|
|
gn_to_bp_utils.GrabDependentValues(js_win, '//:skia', 'sources', win_srcs,
|
|
|
|
None)
|
|
|
|
win_srcs = strip_headers(win_srcs)
|
|
|
|
|
2018-11-28 13:58:47 +00:00
|
|
|
srcs = android_srcs.intersection(linux_srcs).intersection(mac_srcs)
|
2019-02-27 15:59:11 +00:00
|
|
|
srcs = srcs.intersection(win_srcs)
|
2018-11-15 20:54:59 +00:00
|
|
|
android_srcs = android_srcs.difference(srcs)
|
|
|
|
linux_srcs = linux_srcs.difference(srcs)
|
2019-02-27 15:59:11 +00:00
|
|
|
mac_srcs = mac_srcs.difference(srcs)
|
|
|
|
win_srcs = win_srcs.difference(srcs)
|
2021-01-29 20:33:00 +00:00
|
|
|
|
2022-01-05 15:58:20 +00:00
|
|
|
gm_srcs = strip_headers(gm_srcs)
|
|
|
|
test_srcs = strip_headers(test_srcs)
|
|
|
|
dm_srcs = strip_headers(dm_srcs).difference(gm_srcs).difference(test_srcs)
|
|
|
|
nanobench_srcs = strip_headers(nanobench_srcs).difference(gm_srcs)
|
|
|
|
|
|
|
|
test_minus_gm_includes = test_includes.difference(gm_includes)
|
|
|
|
test_minus_gm_srcs = test_srcs.difference(gm_srcs)
|
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
|
|
|
|
2022-01-06 21:39:39 +00:00
|
|
|
# Execute GN for specialized RenderEngine target
|
|
|
|
js_renderengine = gn_to_bp_utils.GenerateJSONFromGN(gn_args_renderengine)
|
|
|
|
renderengine_srcs = strip_slashes(
|
|
|
|
js_renderengine['targets']['//:skia']['sources'])
|
|
|
|
gn_to_bp_utils.GrabDependentValues(js_renderengine, '//:skia', 'sources',
|
|
|
|
renderengine_srcs, None)
|
|
|
|
renderengine_srcs = strip_headers(renderengine_srcs)
|
|
|
|
|
|
|
|
# Execute GN for specialized SkQP target
|
|
|
|
skqp_sdk_version = 26
|
|
|
|
js_skqp = gn_to_bp_utils.GenerateJSONFromGN(skqp_gn_args.GetGNArgs(api_level=skqp_sdk_version,
|
|
|
|
debug=False,
|
|
|
|
is_android_bp=True))
|
|
|
|
skqp_srcs = strip_slashes(js_skqp['targets']['//:libskqp_app']['sources'])
|
|
|
|
skqp_includes = strip_slashes(js_skqp['targets']['//:libskqp_app']['include_dirs'])
|
|
|
|
skqp_cflags = strip_slashes(js_skqp['targets']['//:libskqp_app']['cflags'])
|
|
|
|
skqp_cflags_cc = strip_slashes(js_skqp['targets']['//:libskqp_app']['cflags_cc'])
|
|
|
|
skqp_defines = strip_slashes(js_skqp['targets']['//:libskqp_app']['defines'])
|
|
|
|
|
|
|
|
skqp_includes.update(strip_slashes(js_skqp['targets']['//:public']['include_dirs']))
|
|
|
|
|
|
|
|
gn_to_bp_utils.GrabDependentValues(js_skqp, '//:libskqp_app', 'sources',
|
|
|
|
skqp_srcs, None)
|
2022-04-28 22:24:17 +00:00
|
|
|
# We are exlcuding gpu here to get rid of the includes that are being added from
|
|
|
|
# vulkanmemoryallocator. This does not seem to remove any other incldues from gpu so things
|
|
|
|
# should work out fine for now
|
2022-01-06 21:39:39 +00:00
|
|
|
gn_to_bp_utils.GrabDependentValues(js_skqp, '//:libskqp_app', 'include_dirs',
|
2022-04-28 22:24:17 +00:00
|
|
|
skqp_includes, ['//:gif', '//:gpu'])
|
2022-01-06 21:39:39 +00:00
|
|
|
gn_to_bp_utils.GrabDependentValues(js_skqp, '//:libskqp_app', 'cflags',
|
|
|
|
skqp_cflags, None)
|
|
|
|
gn_to_bp_utils.GrabDependentValues(js_skqp, '//:libskqp_app', 'cflags_cc',
|
|
|
|
skqp_cflags_cc, None)
|
|
|
|
gn_to_bp_utils.GrabDependentValues(js_skqp, '//:libskqp_app', 'defines',
|
|
|
|
skqp_defines, None)
|
|
|
|
|
2022-02-23 15:54:40 +00:00
|
|
|
skqp_defines.add("SK_ENABLE_DUMP_GPU")
|
|
|
|
skqp_defines.add("SK_BUILD_FOR_SKQP")
|
|
|
|
skqp_defines.add("SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1")
|
|
|
|
|
2022-01-06 21:39:39 +00:00
|
|
|
skqp_srcs = strip_headers(skqp_srcs)
|
|
|
|
skqp_cflags = gn_to_bp_utils.CleanupCFlags(skqp_cflags)
|
|
|
|
skqp_cflags_cc = gn_to_bp_utils.CleanupCCFlags(skqp_cflags_cc)
|
|
|
|
|
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-11-15 20:54:59 +00:00
|
|
|
def get_defines(json):
|
|
|
|
return {str(d) for d in json['targets']['//:skia']['defines']}
|
2021-01-29 20:33:00 +00:00
|
|
|
android_defines = get_defines(js)
|
|
|
|
linux_defines = get_defines(js_linux)
|
|
|
|
mac_defines = get_defines(js_mac)
|
|
|
|
win_defines = get_defines(js_win)
|
|
|
|
renderengine_defines = get_defines(js_renderengine)
|
2021-12-28 18:21:56 +00:00
|
|
|
renderengine_defines.add('SK_IN_RENDERENGINE')
|
2018-11-15 20:54:59 +00:00
|
|
|
|
|
|
|
def mkdir_if_not_exists(path):
|
|
|
|
if not os.path.exists(path):
|
2019-04-23 17:05:21 +00:00
|
|
|
os.makedirs(path)
|
|
|
|
mkdir_if_not_exists('android/include/config/')
|
|
|
|
mkdir_if_not_exists('linux/include/config/')
|
|
|
|
mkdir_if_not_exists('mac/include/config/')
|
|
|
|
mkdir_if_not_exists('win/include/config/')
|
2021-01-29 20:33:00 +00:00
|
|
|
mkdir_if_not_exists('renderengine/include/config/')
|
2022-01-06 21:39:39 +00:00
|
|
|
mkdir_if_not_exists('skqp/include/config/')
|
2022-04-28 22:24:17 +00:00
|
|
|
mkdir_if_not_exists('vma_android/include')
|
|
|
|
|
|
|
|
shutil.copy('third_party/externals/vulkanmemoryallocator/include/vk_mem_alloc.h',
|
|
|
|
'vma_android/include')
|
|
|
|
shutil.copy('third_party/externals/vulkanmemoryallocator/LICENSE.txt', 'vma_android/')
|
2018-11-15 20:54:59 +00:00
|
|
|
|
|
|
|
platforms = { 'IOS', 'MAC', 'WIN', 'ANDROID', 'UNIX' }
|
|
|
|
|
|
|
|
def disallow_platforms(config, desired):
|
|
|
|
with open(config, 'a') as f:
|
|
|
|
p = sorted(platforms.difference({ desired }))
|
|
|
|
s = '#if '
|
|
|
|
for i in range(len(p)):
|
|
|
|
s = s + 'defined(SK_BUILD_FOR_%s)' % p[i]
|
|
|
|
if i < len(p) - 1:
|
|
|
|
s += ' || '
|
|
|
|
if i % 2 == 1:
|
|
|
|
s += '\\\n '
|
2020-03-03 06:53:20 +00:00
|
|
|
print(s, file=f)
|
|
|
|
print(' #error "Only SK_BUILD_FOR_%s should be defined!"' % desired, file=f)
|
|
|
|
print('#endif', file=f)
|
2018-11-15 20:54:59 +00:00
|
|
|
|
|
|
|
def append_to_file(config, s):
|
|
|
|
with open(config, 'a') as f:
|
2020-03-03 06:53:20 +00:00
|
|
|
print(s, file=f)
|
2018-11-15 20:54:59 +00:00
|
|
|
|
2022-01-06 21:39:39 +00:00
|
|
|
def write_android_config(config_path, defines, isNDKConfig = False):
|
2021-01-29 20:33:00 +00:00
|
|
|
gn_to_bp_utils.WriteUserConfig(config_path, defines)
|
|
|
|
append_to_file(config_path, '''
|
2018-11-15 20:54:59 +00:00
|
|
|
#ifndef SK_BUILD_FOR_ANDROID
|
|
|
|
#error "SK_BUILD_FOR_ANDROID must be defined!"
|
|
|
|
#endif''')
|
2021-01-29 20:33:00 +00:00
|
|
|
disallow_platforms(config_path, 'ANDROID')
|
|
|
|
|
2022-01-06 21:39:39 +00:00
|
|
|
if isNDKConfig:
|
|
|
|
append_to_file(config_path, '''
|
|
|
|
#undef SK_BUILD_FOR_ANDROID_FRAMEWORK''')
|
|
|
|
|
2021-01-29 20:33:00 +00:00
|
|
|
write_android_config('android/include/config/SkUserConfig.h', android_defines)
|
|
|
|
write_android_config('renderengine/include/config/SkUserConfig.h', renderengine_defines)
|
2022-01-06 21:39:39 +00:00
|
|
|
write_android_config('skqp/include/config/SkUserConfig.h', skqp_defines, True)
|
2018-11-15 20:54:59 +00:00
|
|
|
|
2018-11-28 13:58:47 +00:00
|
|
|
def write_config(config_path, defines, platform):
|
|
|
|
gn_to_bp_utils.WriteUserConfig(config_path, defines)
|
|
|
|
append_to_file(config_path, '''
|
2018-11-15 20:54:59 +00:00
|
|
|
// Correct SK_BUILD_FOR flags that may have been set by
|
2020-02-05 16:17:57 +00:00
|
|
|
// SkTypes.h/Android.bp
|
2018-11-28 13:58:47 +00:00
|
|
|
#ifndef SK_BUILD_FOR_%s
|
|
|
|
#define SK_BUILD_FOR_%s
|
2018-11-15 20:54:59 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SK_BUILD_FOR_ANDROID
|
|
|
|
#undef SK_BUILD_FOR_ANDROID
|
2018-11-28 13:58:47 +00:00
|
|
|
#endif''' % (platform, platform))
|
|
|
|
disallow_platforms(config_path, platform)
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
write_config('linux/include/config/SkUserConfig.h', linux_defines, 'UNIX')
|
|
|
|
write_config('mac/include/config/SkUserConfig.h', mac_defines, 'MAC')
|
|
|
|
write_config('win/include/config/SkUserConfig.h', win_defines, 'WIN')
|
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...
|
2018-11-15 20:54:59 +00:00
|
|
|
with open('Android.bp', 'w') as Android_bp:
|
2020-03-03 06:53:20 +00:00
|
|
|
print(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-09-05 19:55:25 +00:00
|
|
|
'arm_srcs': bpfmt(16, strip_headers(defs['armv7'])),
|
|
|
|
'arm_neon_srcs': bpfmt(20, strip_headers(defs['neon'])),
|
|
|
|
'arm64_srcs': bpfmt(16, strip_headers(defs['arm64'] +
|
|
|
|
defs['crc32'])),
|
|
|
|
'x86_srcs': bpfmt(16, strip_headers(defs['sse2'] +
|
|
|
|
defs['ssse3'] +
|
|
|
|
defs['sse41'] +
|
|
|
|
defs['sse42'] +
|
|
|
|
defs['avx' ] +
|
2020-06-05 11:57:30 +00:00
|
|
|
defs['hsw' ] +
|
|
|
|
defs['skx' ])),
|
2017-01-26 22:21:27 +00:00
|
|
|
|
2022-01-05 15:58:20 +00:00
|
|
|
'gm_includes' : bpfmt(8, gm_includes),
|
|
|
|
'gm_srcs' : bpfmt(8, gm_srcs),
|
|
|
|
|
|
|
|
'test_minus_gm_includes' : bpfmt(8, test_minus_gm_includes),
|
|
|
|
'test_minus_gm_srcs' : bpfmt(8, test_minus_gm_srcs),
|
|
|
|
|
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),
|
2018-11-15 20:54:59 +00:00
|
|
|
|
2022-01-06 21:39:39 +00:00
|
|
|
'skqp_sdk_version': skqp_sdk_version,
|
|
|
|
'skqp_includes': bpfmt(8, skqp_includes),
|
|
|
|
'skqp_srcs': bpfmt(8, skqp_srcs),
|
|
|
|
'skqp_cflags': bpfmt(8, skqp_cflags, False),
|
|
|
|
'skqp_cflags_cc': bpfmt(8, skqp_cflags_cc),
|
|
|
|
|
2018-11-15 20:54:59 +00:00
|
|
|
'android_srcs': bpfmt(10, android_srcs),
|
|
|
|
'linux_srcs': bpfmt(10, linux_srcs),
|
2018-11-28 13:58:47 +00:00
|
|
|
'mac_srcs': bpfmt(10, mac_srcs),
|
2019-02-27 15:59:11 +00:00
|
|
|
'win_srcs': bpfmt(10, win_srcs),
|
2021-01-29 20:33:00 +00:00
|
|
|
|
|
|
|
'renderengine_srcs': bpfmt(8, renderengine_srcs),
|
2020-03-03 06:53:20 +00:00
|
|
|
}), file=Android_bp)
|