Lines Matching +full:project +full:- +full:src +full:- +full:path
4 # Use of this source code is governed by a BSD-style license that can be
20 import action_helpers # build_utils adds //build to sys.path.
22 …https://chromium.googlesource.com/chromium/src/+/main/build/android/docs/lint.md' # pylint: disab…
27 "Assert", # R8 --force-enable-assertions is used to enable java asserts.
32 "MissingApplicationIcon", # False positive for non-production targets.
68 def _SrcRelative(path): argument
69 """Returns relative path to top-level src dir."""
70 return os.path.relpath(path, build_utils.DIR_SOURCE_ROOT)
84 project = ElementTree.Element('project')
85 root = ElementTree.SubElement(project, 'root')
88 sdk = ElementTree.SubElement(project, 'sdk')
89 # Lint requires that the sdk path be an absolute path.
90 sdk.set('dir', os.path.abspath(android_sdk_root))
92 baseline = ElementTree.SubElement(project, 'baseline')
94 cache = ElementTree.SubElement(project, 'cache')
96 main_module = ElementTree.SubElement(project, 'module')
106 src = ElementTree.SubElement(main_module, 'src')
107 src.set('file', srcjar_file)
110 src = ElementTree.SubElement(main_module, 'src')
111 src.set('file', source)
122 lint = ElementTree.SubElement(main_module, 'lint-checks')
128 return project
164 for path in extra_manifest_paths:
165 _, _, extra_app_node = manifest_utils.ParseManifest(path)
169 uses_sdk = manifest.find('./uses-sdk')
171 uses_sdk = ElementTree.Element('uses-sdk')
180 def _WriteXmlFile(root, path): argument
181 logging.info('Writing xml file %s', path)
182 build_utils.MakeDirectory(os.path.dirname(path))
183 with action_helpers.atomic_output(path) as f:
188 root, encoding='utf-8')).toprettyxml(indent=' ').encode('utf-8'))
215 # Occasionally lint may crash due to re-using intermediate files from older
221 if baseline and not os.path.exists(baseline):
231 # prefix. Path variable substitution is based off of prefix matching so custom
232 # path variables need to match exactly in order to show up in baseline files.
233 # e.g. lint_path=path/to/output/dir/../../file/in/src
235 pathvar_src = os.path.join(
236 root_path, os.path.relpath(build_utils.DIR_SOURCE_ROOT, start=root_path))
239 '-cp',
242 '--sdk-home',
244 '--jdk-home',
246 '--path-variables',
247 f'SRC={pathvar_src}',
248 '--quiet', # Silences lint's "." progress updates.
249 '--stacktrace', # Prints full stacktraces for internal lint errors.
250 '--disable',
255 cmd.extend(['--disable', ','.join(_DISABLED_FOR_TESTS)])
258 manifest_path = os.path.join(build_utils.DIR_SOURCE_ROOT, 'build',
264 generated_config_path = os.path.join(lint_gen_dir, 'config.xml')
266 cmd.extend(['--config', generated_config_path])
273 # Include the rebased manifest_path in the lint generated path so that it is
275 lint_android_manifest_path = os.path.join(lint_gen_dir, manifest_path)
278 resource_root_dir = os.path.join(lint_gen_dir, _RES_ZIP_DIR)
284 resource_dir = os.path.join(resource_root_dir, resource_zip)
288 build_utils.ExtractAll(resource_zip, path=resource_dir))
291 aar_root_dir = os.path.join(lint_gen_dir, _AAR_DIR)
297 aar_dir = os.path.join(aar_root_dir,
298 os.path.splitext(_SrcRelative(aar))[0])
301 aar_files = build_utils.ExtractAll(aar, path=aar_dir)
309 srcjar_root_dir = os.path.join(lint_gen_dir, _SRCJAR_DIR)
313 # Use path without extensions since otherwise the file name includes
315 srcjar_dir = os.path.join(srcjar_root_dir, os.path.splitext(srcjar)[0])
321 srcjar_sources.extend(build_utils.ExtractAll(srcjar, path=srcjar_dir))
323 logging.info('Generating project file')
331 project_xml_path = os.path.join(lint_gen_dir, 'project.xml')
333 cmd += ['--project', project_xml_path]
362 print('- For more help with lint in Chrome:', _LINT_MD_URL)
364 print('- DEBUG MODE: Here is the project.xml: {}'.format(
367 print('- Run with LINT_DEBUG=1 to enable lint configuration debugging')
369 end = time.time() - start
383 parser.add_argument('--target-name', help='Fully qualified GN target name.')
384 parser.add_argument('--skip-build-server',
387 parser.add_argument('--use-build-server',
390 parser.add_argument('--lint-jar-path',
392 help='Path to the lint jar.')
393 parser.add_argument('--custom-lint-jar-path',
395 help='Path to our custom lint jar.')
396 parser.add_argument('--backported-methods',
397 help='Path to backported methods file created by R8.')
398 parser.add_argument('--cache-dir',
400 help='Path to the directory in which the android cache '
402 parser.add_argument('--config-path', help='Path to lint suppressions file.')
403 parser.add_argument('--lint-gen-dir',
405 help='Path to store generated xml files.')
406 parser.add_argument('--stamp', help='Path to stamp upon success.')
407 parser.add_argument('--android-sdk-version',
410 parser.add_argument('--min-sdk-version',
413 parser.add_argument('--android-sdk-root',
415 help='Lint needs an explicit path to the android sdk.')
416 parser.add_argument('--testonly',
421 parser.add_argument('--create-cache',
424 parser.add_argument('--warnings-as-errors',
427 parser.add_argument('--sources',
430 parser.add_argument('--aars', help='GN list of included aars.')
431 parser.add_argument('--srcjars', help='GN list of included srcjars.')
432 parser.add_argument('--manifest-path',
433 help='Path to original AndroidManifest.xml')
434 parser.add_argument('--extra-manifest-paths',
436 help='GYP-list of manifest paths to merge into the '
438 parser.add_argument('--resource-sources',
441 help='GYP-list of resource sources files, similar to '
443 parser.add_argument('--resource-zips',
446 help='GYP-list of resource zips, zip files of generated '
448 parser.add_argument('--classpath',
450 parser.add_argument('--baseline',
465 assert os.path.basename(args.baseline) == 'lint-baseline.xml', (
466 'The baseline file needs to be named "lint-baseline.xml" in order for '