Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(671)

Side by Side Diff: build/config/android/internal_rules.gni

Issue 465713002: Add linting for java libraries/apks to gn (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lint-jar
Patch Set: Rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/gyp/lint.py ('k') | build/config/android/rules.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import("//build/config/android/config.gni") 5 import("//build/config/android/config.gni")
6 6
7 assert(is_android) 7 assert(is_android)
8 8
9 9
10 rebased_android_sdk = rebase_path(android_sdk, root_build_dir) 10 rebased_android_sdk = rebase_path(android_sdk, root_build_dir)
11 rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir) 11 rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir)
12 rebased_android_sdk_build_tools = rebase_path(android_sdk_build_tools, root_buil d_dir) 12 rebased_android_sdk_build_tools = rebase_path(android_sdk_build_tools, root_buil d_dir)
13 13
14 template("android_lint") {
15 jar_path = invoker.jar_path
16 android_manifest = invoker.android_manifest
17 java_files = invoker.java_files
18 base_path = "$target_gen_dir/$target_name"
19
20 action(target_name) {
21 script = "//build/android/gyp/lint.py"
22 result_path = base_path + "/result.xml"
23 config_path = base_path + "/config.xml"
24 suppressions_file = "//build/android/lint/suppressions.xml"
25 inputs = [
26 suppressions_file,
27 android_manifest,
28 jar_path,
29 ] + java_files
30
31 outputs = [
32 config_path,
33 result_path
34 ]
35
36 rebased_java_files = rebase_path(java_files, root_build_dir)
37
38 args = [
39 "--lint-path=$rebased_android_sdk_root/tools/lint",
40 "--config-path", rebase_path(suppressions_file, root_build_dir),
newt (away) 2014/08/18 16:12:16 Why is the suppressions file passed via the --conf
cjhopman 2014/08/20 21:44:59 It is passes as the lint executable's --config arg
41 "--manifest-path", rebase_path(android_manifest, root_build_dir),
42 "--product-dir=.",
43 "--jar-path", rebase_path(jar_path, root_build_dir),
44 "--processed-config-path", rebase_path(config_path, root_build_dir),
45 "--result-path", rebase_path(result_path, root_build_dir),
46 "--java-files=$rebased_java_files",
47 "--enable",
48 ]
49 }
50 }
51
14 52
15 # Write the target's .build_config file. This is a json file that contains a 53 # Write the target's .build_config file. This is a json file that contains a
16 # dictionary of information about how to build this target (things that 54 # dictionary of information about how to build this target (things that
17 # require knowledge about this target's dependencies and cannot be calculated 55 # require knowledge about this target's dependencies and cannot be calculated
18 # at gn-time). There is a special syntax to add a value in that dictionary to 56 # at gn-time). There is a special syntax to add a value in that dictionary to
19 # an action/action_foreachs args: 57 # an action/action_foreachs args:
20 # --python-arg=@FileArg($rebased_build_config_path:key0:key1) 58 # --python-arg=@FileArg($rebased_build_config_path:key0:key1)
21 # At runtime, such an arg will be replaced by the value in the build_config. 59 # At runtime, such an arg will be replaced by the value in the build_config.
22 # See build/android/gyp/write_build_config.py and 60 # See build/android/gyp/write_build_config.py and
23 # build/android/gyp/util/build_utils.py:ExpandFileArgs 61 # build/android/gyp/util/build_utils.py:ExpandFileArgs
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 # Compiles and jars a set of java files. 324 # Compiles and jars a set of java files.
287 # 325 #
288 # Outputs: 326 # Outputs:
289 # $jar_path.jar 327 # $jar_path.jar
290 # $jar_path.jar.TOC 328 # $jar_path.jar.TOC
291 # 329 #
292 # Variables 330 # Variables
293 # java_files: List of .java files to compile. 331 # java_files: List of .java files to compile.
294 # java_deps: List of java dependencies. These should all have a .jar output 332 # java_deps: List of java dependencies. These should all have a .jar output
295 # at "${target_gen_dir}/${target_name}.jar. 333 # at "${target_gen_dir}/${target_name}.jar.
296 # chromium_code: If 1, enable extra warnings. 334 # chromium_code: If true, enable extra warnings.
297 # srcjar_deps: List of srcjar dependencies. The .java files contained in the 335 # srcjar_deps: List of srcjar dependencies. The .java files contained in the
298 # dependencies srcjar outputs will be compiled and added to the output jar. 336 # dependencies srcjar outputs will be compiled and added to the output jar.
299 # jar_path: Use this to explicitly set the output jar path. Defaults to 337 # jar_path: Use this to explicitly set the output jar path. Defaults to
300 # "${target_gen_dir}/${target_name}.jar. 338 # "${target_gen_dir}/${target_name}.jar.
301 template("java_library") { 339 template("java_library") {
302 assert(defined(invoker.java_files)) 340 assert(defined(invoker.java_files))
303 assert(defined(invoker.build_config)) 341 assert(defined(invoker.build_config))
304 assert(defined(invoker.jar_path)) 342 assert(defined(invoker.jar_path))
305 343
306 java_files = invoker.java_files 344 java_files = invoker.java_files
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 # Dexes the output jar for inclusion in an APK. 439 # Dexes the output jar for inclusion in an APK.
402 template("android_java_library") { 440 template("android_java_library") {
403 assert(defined(invoker.java_files)) 441 assert(defined(invoker.java_files))
404 assert(defined(invoker.build_config)) 442 assert(defined(invoker.build_config))
405 assert(defined(invoker.jar_path)) 443 assert(defined(invoker.jar_path))
406 assert(defined(invoker.dex_path)) 444 assert(defined(invoker.dex_path))
407 445
408 _jar_path = invoker.jar_path 446 _jar_path = invoker.jar_path
409 _dex_path = invoker.dex_path 447 _dex_path = invoker.dex_path
410 448
449 _android_manifest = "//build/android/AndroidManifest.xml"
450 if (defined(invoker.android_manifest)) {
451 _android_manifest = invoker.android_manifest
452 }
453 assert(_android_manifest != "")
454
455 _final_deps = []
456
411 java_library("${target_name}__java_library") { 457 java_library("${target_name}__java_library") {
412 jar_path = _jar_path 458 jar_path = _jar_path
413 if (defined(invoker.jar_excluded_patterns)) { 459 if (defined(invoker.jar_excluded_patterns)) {
414 jar_excluded_patterns = invoker.jar_excluded_patterns 460 jar_excluded_patterns = invoker.jar_excluded_patterns
415 } 461 }
416 build_config = invoker.build_config 462 build_config = invoker.build_config
417 java_files = invoker.java_files 463 java_files = invoker.java_files
418 464
419 if (defined(invoker.srcjar_deps)) { 465 if (defined(invoker.srcjar_deps)) {
420 srcjar_deps = invoker.srcjar_deps 466 srcjar_deps = invoker.srcjar_deps
421 } 467 }
422 } 468 }
423 469
424 # TODO(cjhopman): lint 470 if (defined(invoker.chromium_code) && invoker.chromium_code) {
425 471 _final_deps += [ ":${target_name}__lint" ]
472 android_lint("${target_name}__lint") {
473 android_manifest = _android_manifest
474 jar_path = _jar_path
475 java_files = invoker.java_files
476 }
477 }
426 478
427 dex("${target_name}__dex") { 479 dex("${target_name}__dex") {
428 sources = [_jar_path] 480 sources = [_jar_path]
429 output = _dex_path 481 output = _dex_path
430 } 482 }
431 483
432 group(target_name) { 484 group(target_name) {
433 deps = [ 485 deps = [
434 ":${target_name}__java_library", 486 ":${target_name}__java_library",
435 ":${target_name}__dex", 487 ":${target_name}__dex",
436 ] 488 ] + _final_deps
437 } 489 }
438 } 490 }
439 491
440 492
441 # Runs process_resources.py 493 # Runs process_resources.py
442 template("process_resources") { 494 template("process_resources") {
443 zip_path = invoker.zip_path 495 zip_path = invoker.zip_path
444 srcjar_path = invoker.srcjar_path 496 srcjar_path = invoker.srcjar_path
445 build_config = invoker.build_config 497 build_config = invoker.build_config
446 resource_dirs = invoker.resource_dirs 498 resource_dirs = invoker.resource_dirs
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 args += [ 560 args += [
509 "--all-resources-zip-out", rebase_path(all_resources_zip, root_build_dir ) 561 "--all-resources-zip-out", rebase_path(all_resources_zip, root_build_dir )
510 ] 562 ]
511 } 563 }
512 564
513 if (defined(invoker.args)) { 565 if (defined(invoker.args)) {
514 args += invoker.args 566 args += invoker.args
515 } 567 }
516 } 568 }
517 } 569 }
OLDNEW
« no previous file with comments | « build/android/gyp/lint.py ('k') | build/config/android/rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698