10from __future__
import print_function
24bp = string.Template(
'''// This file is autogenerated by gn_to_bp.py.
25// To make changes to this file, follow the instructions on skia.org for
26// downloading Skia and submitting changes. Modify gn_to_bp.py (or the build
27// files it uses) and submit to skia-review.googlesource.com, NOT to AOSP or
28// Android Internal. The autoroller will then create the updated Android.bp
29// and submit it to Android Internal, which will eventually merge to AOSP.
30// You can also ask a Skia engineer for help.
33 default_applicable_licenses: ["external_skia_license"],
36// Added automatically by a large-scale-change that took the approach of
37//
'apply every license found to every target'. While this makes sure we respect
38// every license restriction, it may
not be entirely correct.
40// e.g. GPL
in an MIT project might only apply to the contrib/ directory.
42// Please consider splitting the single license below into multiple licenses,
43// taking care
not to lose any license_kind information,
and overriding the
44// default license using the
'licenses: [...]' property on targets
as needed.
46// For unused files, consider creating a
'fileGroup' with "//visibility:private"
47// to attach the license to,
and including a comment whether the files may be
48// used
in the current project.
50// large-scale-change included anything that looked like it might be a license
51// text
as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
53// Please consider removing redundant
or irrelevant files
from 'license_text:'.
55// large-scale-change filtered out the below license kinds
as false-positives:
56// SPDX-license-identifier-CC-BY-NC
57// SPDX-license-identifier-GPL-2.0
58// SPDX-license-identifier-LGPL-2.1
59// SPDX-license-identifier-OFL:by_exception_only
60// See: http://go/android-license-faq
62 name:
"external_skia_license",
63 visibility: [
":__subpackages__"],
65 "SPDX-license-identifier-Apache-2.0",
66 "SPDX-license-identifier-BSD",
67 "SPDX-license-identifier-CC0-1.0",
68 "SPDX-license-identifier-FTL",
69 "SPDX-license-identifier-MIT",
70 "legacy_unencumbered",
79 name:
"skia_arch_defaults",
106 "src/gpu/vk/vulkanmemoryallocator/VulkanMemoryAllocatorWrapper.cpp",
108 local_include_dirs: [
109 "src/gpu/vk/vulkanmemoryallocator",
110 "vma_android/include",
117 name:
"skia_defaults",
118 defaults: [
"skia_arch_defaults"],
127 export_include_dirs: [
131 local_include_dirs: [
137 // Smaller version of Skia, without e.g. codecs, intended
for use by RenderEngine.
138 name:
"libskia_renderengine",
139 defaults: [
"skia_defaults",
140 "skia_renderengine_deps"],
144 local_include_dirs: [
147 export_include_dirs: [
154 host_supported: true,
156 // Exceptions are necessary
for SkRawCodec.
157 // FIXME: Should we split SkRawCodec into a separate target so the rest
158 // of Skia need
not be compiled
with exceptions?
171 local_include_dirs: [
174 export_include_dirs: [
182 local_include_dirs: [
185 export_include_dirs: [
193 local_include_dirs: [
196 export_include_dirs: [
203 "-Wno-unknown-pragmas",
208 local_include_dirs: [
211 export_include_dirs: [
217 defaults: [
"skia_deps",
223 // Subset of the larger
"skia_deps", which includes only the dependencies
224 // needed
for libskia_renderengine. Note that it includes libpng
and libz
225 //
for the purposes of MSKP captures, but we could instead leave it up to
226 // RenderEngine to provide its own SkSerializerProcs
if another client
227 // wants an even smaller version of libskia.
228 name:
"skia_renderengine_deps",
247 "libperfetto_client_experimental",
249 export_shared_lib_headers: [
258 defaults: [
"skia_renderengine_deps"],
265 "libharfbuzz_subset",
270 "libwuffs_mirror_release_c",
273 "-DSK_PDF_USE_HARFBUZZ_SUBSET",
300 name:
"skia_tool_deps",
312 "-DSK_SHAPER_HARFBUZZ_AVAILABLE",
313 "-DSK_SHAPER_UNICODE_AVAILABLE",
314 "-DSK_UNICODE_AVAILABLE",
315 "-DSK_UNICODE_ICU_IMPLEMENTATION",
316 "-Wno-implicit-fallthrough",
317 "-Wno-unused-parameter",
318 "-Wno-unused-variable",
332 name:
"skia_gm_srcs",
333 local_include_dirs: [
343 name:
"skia_test_minus_gm_srcs",
344 local_include_dirs: [
345 $test_minus_gm_includes
355 sdk_version:
"$skqp_sdk_version",
356 stl:
"libc++_static",
357 compile_multilib:
"both",
360 "skia_arch_defaults",
365 "-Wno-unused-parameter",
366 "-Wno-unused-variable",
373 local_include_dirs: [
378 export_include_dirs: [
386 header_libs: [
"jni_headers"],
398 "libjpeg_static_ndk",
402 "libwuffs_mirror_release_c",
407 name:
"CtsSkQPTestCases",
408 defaults: [
"cts_defaults"],
414 libs: [
"android.test.runner.stubs"],
415 jni_libs: [
"libskqp_jni"],
416 compile_multilib:
"both",
419 "android-support-design",
422 manifest:
"platform_tools/android/apps/skqp/src/main/AndroidManifest.xml",
423 test_config:
"platform_tools/android/apps/skqp/src/main/AndroidTest.xml",
425 asset_dirs: [
"platform_tools/android/apps/skqp/src/main/assets",
"resources"],
426 resource_dirs: [
"platform_tools/android/apps/skqp/src/main/res"],
427 srcs: [
"platform_tools/android/apps/skqp/src/main/java/**/*.java"],
429 sdk_version:
"test_current",
434# We'll run GN to get the main source lists and include directories for Skia.
435def generate_args(target_os, enable_gpu, renderengine = False):
437 'is_official_build':
'true',
441 'target_cpu':
'"none"',
444 'skia_enable_fontmgr_custom_directory':
'false',
445 'skia_enable_fontmgr_custom_embedded':
'false',
446 'skia_enable_fontmgr_android':
'false',
447 'skia_enable_fontmgr_win':
'false',
448 'skia_enable_fontmgr_win_gdi':
'false',
449 'skia_use_fonthost_mac':
'false',
451 'skia_use_system_harfbuzz':
'false',
452 'skia_pdf_subset_harfbuzz':
'true',
455 'skia_tools_require_resources':
'true',
457 'skia_use_fontconfig':
'false',
458 'skia_include_multiframe_procs':
'true',
461 'skia_disable_tracing':
'false',
464 'skia_use_perfetto':
'false',
466 d[
'target_os'] = target_os
467 if target_os ==
'"android"':
468 d[
'skia_enable_tools'] =
'true'
471 d[
'skia_android_framework_use_perfetto'] =
'true'
474 d[
'skia_use_vulkan'] =
'true'
475 d[
'skia_enable_ganesh'] =
'true'
477 d[
'skia_enable_graphite'] =
'true'
479 d[
'skia_use_vulkan'] =
'false'
480 d[
'skia_enable_ganesh'] =
'false'
481 d[
'skia_enable_graphite'] =
'false'
483 if target_os ==
'"win"':
485 d[
'skia_use_xps'] =
'false'
490 d[
'win_vc'] =
'"placeholder_version"'
491 d[
'win_sdk_version'] =
'"placeholder_version"'
492 d[
'win_toolchain_version'] =
'"placeholder_version"'
494 if target_os ==
'"android"' and not renderengine:
495 d[
'skia_use_libheif'] =
'true'
496 d[
'skia_use_jpeg_gainmaps'] =
'true'
498 d[
'skia_use_libheif'] =
'false'
501 d[
'skia_use_libpng_decode'] =
'false'
502 d[
'skia_use_libjpeg_turbo_decode'] =
'false'
503 d[
'skia_use_libjpeg_turbo_encode'] =
'false'
504 d[
'skia_use_libwebp_decode'] =
'false'
505 d[
'skia_use_libwebp_encode'] =
'false'
506 d[
'skia_use_wuffs'] =
'false'
507 d[
'skia_enable_pdf'] =
'false'
508 d[
'skia_use_freetype'] =
'false'
509 d[
'skia_use_fixed_gamma_text'] =
'false'
510 d[
'skia_use_expat'] =
'false'
511 d[
'skia_enable_fontmgr_custom_empty'] =
'false'
513 d[
'skia_enable_android_utils'] =
'true'
514 d[
'skia_use_freetype'] =
'true'
515 d[
'skia_use_fixed_gamma_text'] =
'true'
516 d[
'skia_enable_fontmgr_custom_empty'] =
'true'
517 d[
'skia_use_wuffs'] =
'true'
527js = gn_to_bp_utils.GenerateJSONFromGN(gn_args)
530 return {str(p.lstrip(
'/'))
for p
in lst}
547nanobench_target = js[
'targets'][
'//:nanobench']
552gn_to_bp_utils.GrabDependentValues(js,
'//:gm',
'sources', gm_srcs,
'//:skia')
553gn_to_bp_utils.GrabDependentValues(js,
'//:tests',
'sources', test_srcs,
'//:skia')
554gn_to_bp_utils.GrabDependentValues(js,
'//:dm',
'sources',
555 dm_srcs, [
'//:skia',
'//:gm',
'//:tests'])
556gn_to_bp_utils.GrabDependentValues(js,
'//:nanobench',
'sources',
557 nanobench_srcs, [
'//:skia',
'//:gm'])
560local_includes.add(
"modules/skcms")
561gm_includes .add(
"modules/skcms")
566 src_extensions = [
'.s',
'.S',
'.c',
'.cpp',
'.cc',
'.cxx',
'.mm']
567 return {s
for s
in sources
if os.path.splitext(s)[1]
in src_extensions}
569VMA_DEP =
"//src/gpu/vk/vulkanmemoryallocator:vulkanmemoryallocator"
571gn_to_bp_utils.GrabDependentValues(js,
'//:skia',
'sources', android_srcs, VMA_DEP)
574js_linux = gn_to_bp_utils.GenerateJSONFromGN(gn_args_linux)
576gn_to_bp_utils.GrabDependentValues(js_linux,
'//:skia',
'sources', linux_srcs,
580js_mac = gn_to_bp_utils.GenerateJSONFromGN(gn_args_mac)
582gn_to_bp_utils.GrabDependentValues(js_mac,
'//:skia',
'sources', mac_srcs,
586js_win = gn_to_bp_utils.GenerateJSONFromGN(gn_args_win)
588gn_to_bp_utils.GrabDependentValues(js_win,
'//:skia',
'sources', win_srcs,
592srcs = android_srcs.intersection(linux_srcs).intersection(mac_srcs)
593srcs = srcs.intersection(win_srcs)
595android_srcs = android_srcs.difference(srcs)
596linux_srcs = linux_srcs.difference(srcs)
597mac_srcs = mac_srcs.difference(srcs)
598win_srcs = win_srcs.difference(srcs)
605test_minus_gm_includes = test_includes.difference(gm_includes)
606test_minus_gm_srcs = test_srcs.difference(gm_srcs)
608cflags = gn_to_bp_utils.CleanupCFlags(cflags)
609cflags_cc = gn_to_bp_utils.CleanupCCFlags(cflags_cc)
612js_renderengine = gn_to_bp_utils.GenerateJSONFromGN(gn_args_renderengine)
614 js_renderengine[
'targets'][
'//:skia'][
'sources'])
615gn_to_bp_utils.GrabDependentValues(js_renderengine,
'//:skia',
'sources',
616 renderengine_srcs, VMA_DEP)
621js_skqp = gn_to_bp_utils.GenerateJSONFromGN(skqp_gn_args.GetGNArgs(api_level=skqp_sdk_version,
625skqp_includes =
strip_slashes(js_skqp[
'targets'][
'//:libskqp_jni'][
'include_dirs'])
627skqp_cflags_cc =
strip_slashes(js_skqp[
'targets'][
'//:libskqp_jni'][
'cflags_cc'])
628skqp_defines =
strip_slashes(js_skqp[
'targets'][
'//:libskqp_jni'][
'defines'])
630skqp_includes.update(
strip_slashes(js_skqp[
'targets'][
'//:public'][
'include_dirs']))
632gn_to_bp_utils.GrabDependentValues(js_skqp,
'//:libskqp_jni',
'sources',
637gn_to_bp_utils.GrabDependentValues(js_skqp,
'//:libskqp_jni',
'include_dirs',
638 skqp_includes, [
'//:gif',
'//:gpu'])
639gn_to_bp_utils.GrabDependentValues(js_skqp,
'//:libskqp_jni',
'cflags',
641gn_to_bp_utils.GrabDependentValues(js_skqp,
'//:libskqp_jni',
'cflags_cc',
642 skqp_cflags_cc,
None)
643gn_to_bp_utils.GrabDependentValues(js_skqp,
'//:libskqp_jni',
'defines',
646skqp_defines.add(
"GR_TEST_UTILS=1")
647skqp_defines.add(
"GRAPHITE_TEST_UTILS=1")
648skqp_defines.add(
"SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1")
649skqp_defines.add(
"SK_BUILD_FOR_SKQP")
650skqp_defines.add(
"SK_ENABLE_DUMP_GPU")
651skqp_defines.remove(
"SK_USE_PERFETTO")
654skqp_cflags = gn_to_bp_utils.CleanupCFlags(skqp_cflags)
655skqp_cflags_cc = gn_to_bp_utils.CleanupCCFlags(skqp_cflags_cc)
657here = os.path.dirname(__file__)
658defs = gn_to_bp_utils.GetArchSources(os.path.join(here,
'opts.gni'))
661 return {str(d)
for d
in json[
'targets'][
'//:skia'][
'defines']}
667renderengine_defines.add(
'SK_IN_RENDERENGINE')
670 if not os.path.exists(path):
680shutil.copy(
'third_party/externals/vulkanmemoryallocator/include/vk_mem_alloc.h',
681 'vma_android/include')
682shutil.copy(
'third_party/externals/vulkanmemoryallocator/LICENSE.txt',
'vma_android/')
684platforms = {
'IOS',
'MAC',
'WIN',
'ANDROID',
'UNIX' }
687 with open(config,
'a')
as f:
688 p = sorted(platforms.difference({ desired }))
690 for i
in range(
len(p)):
691 s = s +
'defined(SK_BUILD_FOR_%s)' % p[i]
697 print(
' #error "Only SK_BUILD_FOR_%s should be defined!"' % desired, file=f)
698 print(
'#endif', file=f)
701 with open(config,
'a')
as f:
705 gn_to_bp_utils.WriteUserConfig(config_path, defines)
707#ifndef SK_BUILD_FOR_ANDROID
714#undef SK_BUILD_FOR_ANDROID_FRAMEWORK''')
721 gn_to_bp_utils.WriteUserConfig(config_path, defines)
723// Correct SK_BUILD_FOR flags that may have been set by
724// SkTypes.h/Android.bp
725#ifndef SK_BUILD_FOR_%s
733write_config(
'linux/include/config/SkUserConfig.h', linux_defines,
'UNIX')
734write_config(
'mac/include/config/SkUserConfig.h', mac_defines,
'MAC')
735write_config(
'win/include/config/SkUserConfig.h', win_defines,
'WIN')
741 return (
'\n' +
' '*indent).
join(
'"%s",' % v
for v
in lst)
744with open(
'Android.bp',
'w')
as Android_bp:
745 print(bp.substitute({
746 'export_includes':
bpfmt(8, export_includes),
747 'local_includes':
bpfmt(8, local_includes),
748 'srcs':
bpfmt(8, srcs),
749 'cflags':
bpfmt(8, cflags,
False),
750 'cflags_cc':
bpfmt(8, cflags_cc),
755 'gm_includes' :
bpfmt(8, gm_includes),
756 'gm_srcs' :
bpfmt(8, gm_srcs),
758 'test_minus_gm_includes' :
bpfmt(8, test_minus_gm_includes),
759 'test_minus_gm_srcs' :
bpfmt(8, test_minus_gm_srcs),
761 'dm_includes' :
bpfmt(8, dm_includes),
762 'dm_srcs' :
bpfmt(8, dm_srcs),
764 'nanobench_includes' :
bpfmt(8, nanobench_includes),
765 'nanobench_srcs' :
bpfmt(8, nanobench_srcs),
767 'skqp_sdk_version': skqp_sdk_version,
768 'skqp_includes':
bpfmt(8, skqp_includes),
769 'skqp_srcs':
bpfmt(8, skqp_srcs),
770 'skqp_cflags':
bpfmt(8, skqp_cflags,
False),
771 'skqp_cflags_cc':
bpfmt(8, skqp_cflags_cc),
773 'android_srcs':
bpfmt(10, android_srcs),
774 'linux_srcs':
bpfmt(10, linux_srcs),
775 'mac_srcs':
bpfmt(10, mac_srcs),
776 'win_srcs':
bpfmt(10, win_srcs),
778 'renderengine_srcs':
bpfmt(8, renderengine_srcs),
static size_t difference(size_t minuend, size_t subtrahend)
def disallow_platforms(config, desired)
def bpfmt(indent, lst, sort=True)
def append_to_file(config, s)
def generate_args(target_os, enable_gpu, renderengine=False)
def write_config(config_path, defines, platform)
def write_android_config(config_path, defines, isNDKConfig=False)
def strip_non_srcs(sources)
def mkdir_if_not_exists(path)
def print(*args, **kwargs)
static SkString join(const CommandLineFlags::StringArray &)