File: BUILD.gn

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (98 lines) | stat: -rw-r--r-- 3,189 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Copyright 2021 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/android/rules.gni")

declare_args() {
  incremental_javac_test_toggle_gn = false
}

all_test_sources = [
  "../../java/test/NoSignatureChangeIncrementalJavacTestHelper.template",
  "../../java/test/NoSignatureChangeIncrementalJavacTestHelper2.java",
]

template("incremental_javac_prebuilt") {
  _out_jar = "${target_gen_dir}/${target_name}.jar"

  action(target_name) {
    script = "incremental_javac_test_android_library.py"
    forward_variables_from(invoker,
                           [
                             "sources",
                             "testonly",
                           ])
    deps = [ invoker.toggle_gn_target ]

    inputs = []
    if (defined(invoker.pydeps)) {
      foreach(_pydeps_file, invoker.pydeps) {
        _pydeps_file_lines = []
        _pydeps_file_lines = read_file(_pydeps_file, "list lines")
        _pydeps_entries = []
        _pydeps_entries = filter_exclude(_pydeps_file_lines, [ "#*" ])
        _pydeps_file_dir = get_path_info(_pydeps_file, "dir")
        inputs += rebase_path(_pydeps_entries, ".", _pydeps_file_dir)
      }
    }

    outputs = [ _out_jar ]

    args = [
      "--target-name",
      get_label_info("${invoker.toggle_gn_target}", "label_no_toolchain"),
      "--gn-args-path",
      "args.gn",
      "--out-dir",
      rebase_path("${target_out_dir}/${target_name}/incremental_javac_out",
                  root_build_dir),
      "--out-jar",
      rebase_path(_out_jar, root_build_dir),
    ]
  }
}

# Use jinja_template() instead of java_cpp_template() because incremental builds
# are not done when non-.java files change.
jinja_template("changing_javagen") {
  input = "../../java/test/NoSignatureChangeIncrementalJavacTestHelper.template"
  assert(filter_include(all_test_sources, [ input ]) != [])
  output =
      "${target_gen_dir}/test/NoSignatureChangeIncrementalJavacTestHelper.java"
  if (incremental_javac_test_toggle_gn) {
    variables = [ "foo_return_value=foo2" ]
  } else {
    variables = [ "foo_return_value=foo" ]
  }
}

android_library("changing_java") {
  testonly = true

  # Should not be re-compiled during incremental build.
  sources =
      [ "../../java/test/NoSignatureChangeIncrementalJavacTestHelper2.java" ]
  assert(filter_include(all_test_sources, sources) != [])

  # Should be recompiled during incremental build.
  sources += get_target_outputs(":changing_javagen")
  deps = [ ":changing_javagen" ]
}

# Compiles :changing_java with and without |incremental_javac_test_toggle_gn|.
incremental_javac_prebuilt("no_signature_change_prebuilt_generator") {
  testonly = true
  sources = all_test_sources
  toggle_gn_target = ":changing_java"
  pydeps = [ "//build/android/gyp/compile_java.pydeps" ]
}

android_java_prebuilt("no_signature_change_prebuilt_java") {
  testonly = true
  _generator_outputs =
      get_target_outputs(":no_signature_change_prebuilt_generator")
  jar_paths = filter_include(_generator_outputs, [ "*.jar" ])
  jar_path = jar_paths[0]
  deps = [ ":no_signature_change_prebuilt_generator" ]
}