Flutter Engine
The Flutter Engine
gen_javadoc.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2#
3# Copyright 2013 The Flutter Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7import argparse
8import os
9import subprocess
10import sys
11
12ANDROID_SRC_ROOT = 'flutter/shell/platform/android'
13
14SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
15
16
18 if sys.platform == 'darwin':
19 return os.path.join(
20 SCRIPT_DIR, '..', '..', '..', 'third_party', 'java', 'openjdk', 'Contents', 'Home', 'bin',
21 'javadoc'
22 )
23 elif sys.platform.startswith(('cygwin', 'win')):
24 return os.path.join(
25 SCRIPT_DIR, '..', '..', '..', 'third_party', 'java', 'openjdk', 'bin', 'javadoc.exe'
26 )
27 else:
28 return os.path.join(
29 SCRIPT_DIR, '..', '..', '..', 'third_party', 'java', 'openjdk', 'bin', 'javadoc'
30 )
31
32
33def main():
34 parser = argparse.ArgumentParser(description='Runs javadoc on Flutter Android libraries')
35 parser.add_argument('--out-dir', type=str, required=True)
36 parser.add_argument('--android-source-root', type=str, default=ANDROID_SRC_ROOT)
37 parser.add_argument('--build-config-path', type=str)
38 parser.add_argument('--src-dir', type=str, default='.')
39 parser.add_argument('--quiet', default=False, action='store_true')
40 args = parser.parse_args()
41
42 if not os.path.exists(args.android_source_root):
43 print(
44 'This script must be run at the root of the Flutter source tree, or '
45 'the --android-source-root must be set.'
46 )
47 return 1
48
49 if not os.path.exists(args.out_dir):
50 os.makedirs(args.out_dir)
51
52 android_jar_path = os.path.join(
53 args.src_dir, 'flutter', 'third_party', 'android_tools', 'sdk', 'platforms', 'android-34',
54 'android.jar'
55 )
56 if not os.path.exists(android_jar_path):
57 print('Android SDK not found at %s' % android_jar_path)
58 return 1
59
60 classpath = [
61 args.android_source_root,
62 android_jar_path,
63 os.path.join(args.src_dir, 'third_party', 'android_embedding_dependencies', 'lib', '*'),
64 ]
65 if args.build_config_path:
66 classpath.append(args.build_config_path)
67
68 packages = [
69 'io.flutter.app',
70 'io.flutter.embedding.android',
71 'io.flutter.embedding.engine',
72 'io.flutter.embedding.engine.dart',
73 'io.flutter.embedding.engine.loader',
74 'io.flutter.embedding.engine.mutatorsstack',
75 'io.flutter.embedding.engine.plugins',
76 'io.flutter.embedding.engine.plugins.activity',
77 'io.flutter.embedding.engine.plugins.broadcastreceiver',
78 'io.flutter.embedding.engine.plugins.contentprovider',
79 'io.flutter.embedding.engine.plugins.lifecycle',
80 'io.flutter.embedding.engine.plugins.service',
81 'io.flutter.embedding.engine.plugins.shim',
82 'io.flutter.embedding.engine.renderer',
83 'io.flutter.embedding.engine.systemchannels',
84 'io.flutter.plugin.common',
85 'io.flutter.plugin.editing',
86 'io.flutter.plugin.platform',
87 'io.flutter.util',
88 'io.flutter.view',
89 ]
90
91 android_package_list = os.path.join(SCRIPT_DIR, 'android_reference')
92
93 command = [
94 JavadocBin(),
95 '-classpath',
96 ':'.join(classpath),
97 '-d',
98 args.out_dir,
99 '-linkoffline',
100 'https://developer.android.com/reference/',
101 android_package_list,
102 '-source',
103 '1.8',
104 ] + packages
105
106 if not args.quiet:
107 print(' '.join(command))
108
109 try:
110 output = subprocess.check_output(command, stderr=subprocess.STDOUT)
111 if not args.quiet:
112 print(output)
113 except subprocess.CalledProcessError as e:
114 print(e.output.decode('utf-8'))
115 return e.returncode
116
117 return 0
118
119
120if __name__ == '__main__':
121 sys.exit(main())
def JavadocBin()
Definition: gen_javadoc.py:17
def main()
Definition: gen_javadoc.py:33
Definition: main.py:1
def print(*args, **kwargs)
Definition: run_tests.py:49
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741