Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
gn.gn_to_bp Namespace Reference

Functions

 generate_args (target_os, enable_gpu, renderengine=False)
 
 strip_slashes (lst)
 
 strip_non_srcs (sources)
 
 get_defines (json)
 
 mkdir_if_not_exists (path)
 
 disallow_platforms (config, desired)
 
 append_to_file (config, s)
 
 write_android_config (config_path, defines, isNDKConfig=False)
 
 write_config (config_path, defines, platform)
 
 bpfmt (indent, lst, sort=True)
 

Variables

 bp = string.Template()
 
 gn_args = generate_args('"android"', True)
 
 gn_args_linux = generate_args('"linux"', False)
 
 gn_args_mac = generate_args('"mac"', False)
 
 gn_args_win = generate_args('"win"', False)
 
 gn_args_renderengine = generate_args('"android"', True, True)
 
 js = gn_to_bp_utils.GenerateJSONFromGN(gn_args)
 
 android_srcs = strip_slashes(js['targets']['//:skia']['sources'])
 
 cflags = strip_slashes(js['targets']['//:skia']['cflags'])
 
 cflags_cc = strip_slashes(js['targets']['//:skia']['cflags_cc'])
 
 local_includes = strip_slashes(js['targets']['//:skia']['include_dirs'])
 
 export_includes = strip_slashes(js['targets']['//:public']['include_dirs'])
 
 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'])
 
 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'])
 
str VMA_DEP = "//src/gpu/vk/vulkanmemoryallocator:vulkanmemoryallocator"
 
 js_linux = gn_to_bp_utils.GenerateJSONFromGN(gn_args_linux)
 
 linux_srcs = strip_slashes(js_linux['targets']['//:skia']['sources'])
 
 js_mac = gn_to_bp_utils.GenerateJSONFromGN(gn_args_mac)
 
 mac_srcs = strip_slashes(js_mac['targets']['//:skia']['sources'])
 
 js_win = gn_to_bp_utils.GenerateJSONFromGN(gn_args_win)
 
 win_srcs = strip_slashes(js_win['targets']['//:skia']['sources'])
 
 srcs = android_srcs.intersection(linux_srcs).intersection(mac_srcs)
 
 test_minus_gm_includes = test_includes.difference(gm_includes)
 
 test_minus_gm_srcs = test_srcs.difference(gm_srcs)
 
 js_renderengine = gn_to_bp_utils.GenerateJSONFromGN(gn_args_renderengine)
 
 renderengine_srcs
 
int skqp_sdk_version = 26
 
 js_skqp
 
 skqp_srcs = strip_slashes(js_skqp['targets']['//:libskqp_jni']['sources'])
 
 skqp_includes = strip_slashes(js_skqp['targets']['//:libskqp_jni']['include_dirs'])
 
 skqp_cflags = strip_slashes(js_skqp['targets']['//:libskqp_jni']['cflags'])
 
 skqp_cflags_cc = strip_slashes(js_skqp['targets']['//:libskqp_jni']['cflags_cc'])
 
 skqp_defines = strip_slashes(js_skqp['targets']['//:libskqp_jni']['defines'])
 
 here = os.path.dirname(__file__)
 
 defs = gn_to_bp_utils.GetArchSources(os.path.join(here, 'opts.gni'))
 
 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)
 
dict platforms = { 'IOS', 'MAC', 'WIN', 'ANDROID', 'UNIX' }
 
 file
 

Function Documentation

◆ append_to_file()

gn.gn_to_bp.append_to_file (   config,
  s 
)

Definition at line 700 of file gn_to_bp.py.

700def append_to_file(config, s):
701 with open(config, 'a') as f:
702 print(s, file=f)
703
void print(void *str)
Definition bridge.cpp:126

◆ bpfmt()

gn.gn_to_bp.bpfmt (   indent,
  lst,
  sort = True 
)

Definition at line 738 of file gn_to_bp.py.

738def bpfmt(indent, lst, sort=True):
739 if sort:
740 lst = sorted(lst)
741 return ('\n' + ' '*indent).join('"%s",' % v for v in lst)
742
743# OK! We have everything to fill in Android.bp...

◆ disallow_platforms()

gn.gn_to_bp.disallow_platforms (   config,
  desired 
)

Definition at line 686 of file gn_to_bp.py.

686def disallow_platforms(config, desired):
687 with open(config, 'a') as f:
688 p = sorted(platforms.difference({ desired }))
689 s = '#if '
690 for i in range(len(p)):
691 s = s + 'defined(SK_BUILD_FOR_%s)' % p[i]
692 if i < len(p) - 1:
693 s += ' || '
694 if i % 2 == 1:
695 s += '\\\n '
696 print(s, file=f)
697 print(' #error "Only SK_BUILD_FOR_%s should be defined!"' % desired, file=f)
698 print('#endif', file=f)
699

◆ generate_args()

gn.gn_to_bp.generate_args (   target_os,
  enable_gpu,
  renderengine = False 
)

Definition at line 435 of file gn_to_bp.py.

435def generate_args(target_os, enable_gpu, renderengine = False):
436 d = {
437 'is_official_build': 'true',
438
439 # gn_to_bp_utils' GetArchSources will take care of architecture-specific
440 # files.
441 'target_cpu': '"none"',
442
443 # Use the custom FontMgr, as the framework will handle fonts.
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',
450
451 'skia_use_system_harfbuzz': 'false',
452 'skia_pdf_subset_harfbuzz': 'true',
453
454 # enable features used in skia_nanobench
455 'skia_tools_require_resources': 'true',
456
457 'skia_use_fontconfig': 'false',
458 'skia_include_multiframe_procs': 'true',
459
460 # Tracing-related flags:
461 'skia_disable_tracing': 'false',
462 # The two Perfetto integrations are currently mutually exclusive due to
463 # complexity.
464 'skia_use_perfetto': 'false',
465 }
466 d['target_os'] = target_os
467 if target_os == '"android"':
468 d['skia_enable_tools'] = 'true'
469 # Only enable for actual Android framework builds targeting Android devices.
470 # (E.g. disabled for host builds and SkQP)
471 d['skia_android_framework_use_perfetto'] = 'true'
472
473 if enable_gpu:
474 d['skia_use_vulkan'] = 'true'
475 d['skia_enable_ganesh'] = 'true'
476 if renderengine:
477 d['skia_enable_graphite'] = 'true'
478 else:
479 d['skia_use_vulkan'] = 'false'
480 d['skia_enable_ganesh'] = 'false'
481 d['skia_enable_graphite'] = 'false'
482
483 if target_os == '"win"':
484 # The Android Windows build system does not provide FontSub.h
485 d['skia_use_xps'] = 'false'
486
487 # BUILDCONFIG.gn expects these to be set when building for Windows, but
488 # we're just creating Android.bp, so we don't need them. Populate with
489 # some placeholder values.
490 d['win_vc'] = '"placeholder_version"'
491 d['win_sdk_version'] = '"placeholder_version"'
492 d['win_toolchain_version'] = '"placeholder_version"'
493
494 if target_os == '"android"' and not renderengine:
495 d['skia_use_libheif'] = 'true'
496 d['skia_use_jpeg_gainmaps'] = 'true'
497 else:
498 d['skia_use_libheif'] = 'false'
499
500 if renderengine:
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'
512 else:
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'
518
519 return d
520

◆ get_defines()

gn.gn_to_bp.get_defines (   json)

Definition at line 660 of file gn_to_bp.py.

660def get_defines(json):
661 return {str(d) for d in json['targets']['//:skia']['defines']}

◆ mkdir_if_not_exists()

gn.gn_to_bp.mkdir_if_not_exists (   path)

Definition at line 669 of file gn_to_bp.py.

669def mkdir_if_not_exists(path):
670 if not os.path.exists(path):
671 os.makedirs(path)

◆ strip_non_srcs()

gn.gn_to_bp.strip_non_srcs (   sources)

Definition at line 565 of file gn_to_bp.py.

565def strip_non_srcs(sources):
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}
568

◆ strip_slashes()

gn.gn_to_bp.strip_slashes (   lst)

Definition at line 529 of file gn_to_bp.py.

529def strip_slashes(lst):
530 return {str(p.lstrip('/')) for p in lst}
531

◆ write_android_config()

gn.gn_to_bp.write_android_config (   config_path,
  defines,
  isNDKConfig = False 
)

Definition at line 704 of file gn_to_bp.py.

704def write_android_config(config_path, defines, isNDKConfig = False):
705 gn_to_bp_utils.WriteUserConfig(config_path, defines)
706 append_to_file(config_path, '''
707#ifndef SK_BUILD_FOR_ANDROID
708 #error "SK_BUILD_FOR_ANDROID must be defined!"
709#endif''')
710 disallow_platforms(config_path, 'ANDROID')
711
712 if isNDKConfig:
713 append_to_file(config_path, '''
714#undef SK_BUILD_FOR_ANDROID_FRAMEWORK''')
715

◆ write_config()

gn.gn_to_bp.write_config (   config_path,
  defines,
  platform 
)

Definition at line 720 of file gn_to_bp.py.

720def write_config(config_path, defines, platform):
721 gn_to_bp_utils.WriteUserConfig(config_path, defines)
722 append_to_file(config_path, '''
723// Correct SK_BUILD_FOR flags that may have been set by
724// SkTypes.h/Android.bp
725#ifndef SK_BUILD_FOR_%s
726 #define SK_BUILD_FOR_%s
727#endif
728#ifdef SK_BUILD_FOR_ANDROID
729 #undef SK_BUILD_FOR_ANDROID
730#endif''' % (platform, platform))
731 disallow_platforms(config_path, platform)
732

Variable Documentation

◆ android_defines

gn.gn_to_bp.android_defines = get_defines(js)

Definition at line 662 of file gn_to_bp.py.

◆ android_srcs

gn.gn_to_bp.android_srcs = strip_slashes(js['targets']['//:skia']['sources'])

Definition at line 532 of file gn_to_bp.py.

◆ bp

gn.gn_to_bp.bp = string.Template()

Definition at line 24 of file gn_to_bp.py.

◆ cflags

gn.gn_to_bp.cflags = strip_slashes(js['targets']['//:skia']['cflags'])

Definition at line 533 of file gn_to_bp.py.

◆ cflags_cc

gn.gn_to_bp.cflags_cc = strip_slashes(js['targets']['//:skia']['cflags_cc'])

Definition at line 534 of file gn_to_bp.py.

◆ defs

gn.gn_to_bp.defs = gn_to_bp_utils.GetArchSources(os.path.join(here, 'opts.gni'))

Definition at line 658 of file gn_to_bp.py.

◆ dm_includes

gn.gn_to_bp.dm_includes = strip_slashes(js['targets']['//:dm']['include_dirs'])

Definition at line 545 of file gn_to_bp.py.

◆ dm_srcs

gn.gn_to_bp.dm_srcs = strip_slashes(js['targets']['//:dm']['sources'])

Definition at line 544 of file gn_to_bp.py.

◆ export_includes

gn.gn_to_bp.export_includes = strip_slashes(js['targets']['//:public']['include_dirs'])

Definition at line 536 of file gn_to_bp.py.

◆ file

gn.gn_to_bp.file

Definition at line 779 of file gn_to_bp.py.

◆ gm_includes

gn.gn_to_bp.gm_includes = strip_slashes(js['targets']['//:gm']['include_dirs'])

Definition at line 539 of file gn_to_bp.py.

◆ gm_srcs

gn.gn_to_bp.gm_srcs = strip_slashes(js['targets']['//:gm']['sources'])

Definition at line 538 of file gn_to_bp.py.

◆ gn_args

gn.gn_to_bp.gn_args = generate_args('"android"', True)

Definition at line 521 of file gn_to_bp.py.

◆ gn_args_linux

gn.gn_to_bp.gn_args_linux = generate_args('"linux"', False)

Definition at line 522 of file gn_to_bp.py.

◆ gn_args_mac

gn.gn_to_bp.gn_args_mac = generate_args('"mac"', False)

Definition at line 523 of file gn_to_bp.py.

◆ gn_args_renderengine

gn.gn_to_bp.gn_args_renderengine = generate_args('"android"', True, True)

Definition at line 525 of file gn_to_bp.py.

◆ gn_args_win

gn.gn_to_bp.gn_args_win = generate_args('"win"', False)

Definition at line 524 of file gn_to_bp.py.

◆ here

gn.gn_to_bp.here = os.path.dirname(__file__)

Definition at line 657 of file gn_to_bp.py.

◆ js

Definition at line 527 of file gn_to_bp.py.

◆ js_linux

Definition at line 574 of file gn_to_bp.py.

◆ js_mac

Definition at line 580 of file gn_to_bp.py.

◆ js_renderengine

Definition at line 612 of file gn_to_bp.py.

◆ js_skqp

gn.gn_to_bp.js_skqp
Initial value:
1= gn_to_bp_utils.GenerateJSONFromGN(skqp_gn_args.GetGNArgs(api_level=skqp_sdk_version,
2 debug=False,
3 is_android_bp=True))

Definition at line 621 of file gn_to_bp.py.

◆ js_win

Definition at line 586 of file gn_to_bp.py.

◆ linux_defines

gn.gn_to_bp.linux_defines = get_defines(js_linux)

Definition at line 663 of file gn_to_bp.py.

◆ linux_srcs

gn.gn_to_bp.linux_srcs = strip_slashes(js_linux['targets']['//:skia']['sources'])

Definition at line 575 of file gn_to_bp.py.

◆ local_includes

gn.gn_to_bp.local_includes = strip_slashes(js['targets']['//:skia']['include_dirs'])

Definition at line 535 of file gn_to_bp.py.

◆ mac_defines

gn.gn_to_bp.mac_defines = get_defines(js_mac)

Definition at line 664 of file gn_to_bp.py.

◆ mac_srcs

gn.gn_to_bp.mac_srcs = strip_slashes(js_mac['targets']['//:skia']['sources'])

Definition at line 581 of file gn_to_bp.py.

◆ nanobench_includes

gn.gn_to_bp.nanobench_includes = strip_slashes(nanobench_target['include_dirs'])

Definition at line 549 of file gn_to_bp.py.

◆ nanobench_srcs

gn.gn_to_bp.nanobench_srcs = strip_slashes(nanobench_target['sources'])

Definition at line 548 of file gn_to_bp.py.

◆ nanobench_target

gn.gn_to_bp.nanobench_target = js['targets']['//:nanobench']

Definition at line 547 of file gn_to_bp.py.

◆ platforms

dict gn.gn_to_bp.platforms = { 'IOS', 'MAC', 'WIN', 'ANDROID', 'UNIX' }

Definition at line 684 of file gn_to_bp.py.

◆ renderengine_defines

gn.gn_to_bp.renderengine_defines = get_defines(js_renderengine)

Definition at line 666 of file gn_to_bp.py.

◆ renderengine_srcs

gn.gn_to_bp.renderengine_srcs
Initial value:
1= strip_slashes(
2 js_renderengine['targets']['//:skia']['sources'])

Definition at line 613 of file gn_to_bp.py.

◆ skqp_cflags

gn.gn_to_bp.skqp_cflags = strip_slashes(js_skqp['targets']['//:libskqp_jni']['cflags'])

Definition at line 626 of file gn_to_bp.py.

◆ skqp_cflags_cc

gn.gn_to_bp.skqp_cflags_cc = strip_slashes(js_skqp['targets']['//:libskqp_jni']['cflags_cc'])

Definition at line 627 of file gn_to_bp.py.

◆ skqp_defines

gn.gn_to_bp.skqp_defines = strip_slashes(js_skqp['targets']['//:libskqp_jni']['defines'])

Definition at line 628 of file gn_to_bp.py.

◆ skqp_includes

gn.gn_to_bp.skqp_includes = strip_slashes(js_skqp['targets']['//:libskqp_jni']['include_dirs'])

Definition at line 625 of file gn_to_bp.py.

◆ skqp_sdk_version

int gn.gn_to_bp.skqp_sdk_version = 26

Definition at line 620 of file gn_to_bp.py.

◆ skqp_srcs

gn.gn_to_bp.skqp_srcs = strip_slashes(js_skqp['targets']['//:libskqp_jni']['sources'])

Definition at line 624 of file gn_to_bp.py.

◆ srcs

gn.gn_to_bp.srcs = android_srcs.intersection(linux_srcs).intersection(mac_srcs)

Definition at line 592 of file gn_to_bp.py.

◆ test_includes

gn.gn_to_bp.test_includes = strip_slashes(js['targets']['//:tests']['include_dirs'])

Definition at line 542 of file gn_to_bp.py.

◆ test_minus_gm_includes

gn.gn_to_bp.test_minus_gm_includes = test_includes.difference(gm_includes)

Definition at line 605 of file gn_to_bp.py.

◆ test_minus_gm_srcs

gn.gn_to_bp.test_minus_gm_srcs = test_srcs.difference(gm_srcs)

Definition at line 606 of file gn_to_bp.py.

◆ test_srcs

gn.gn_to_bp.test_srcs = strip_slashes(js['targets']['//:tests']['sources'])

Definition at line 541 of file gn_to_bp.py.

◆ VMA_DEP

str gn.gn_to_bp.VMA_DEP = "//src/gpu/vk/vulkanmemoryallocator:vulkanmemoryallocator"

Definition at line 569 of file gn_to_bp.py.

◆ win_defines

gn.gn_to_bp.win_defines = get_defines(js_win)

Definition at line 665 of file gn_to_bp.py.

◆ win_srcs

gn.gn_to_bp.win_srcs = strip_slashes(js_win['targets']['//:skia']['sources'])

Definition at line 587 of file gn_to_bp.py.