File: module_desc_java.gni

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (76 lines) | stat: -rw-r--r-- 2,701 bytes parent folder | download | duplicates (8)
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
# Copyright 2019 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")
import("//build/config/python.gni")

# Writes an implementation of
# |org.chromium.components.module_installer.builder.ModuleDescriptor| for a
# particular module to Java. The module loader backend expects such an
# implementation for each module to automate module setup on first access.
# Instantiations of this template can be depended on like |android_library|
# targets.
#
# Supports the following variables:
#   module_name: Name of the module.
#   shared_libraries: (Optional) List of shared_library targets the module
#     requires at runtime. Will consider all transitively depended on
#     shared_libraries.
#   paks: (Optional) PAK files going into the module.
#   load_native_on_get_impl: (Optional) Whether the module's native libraries /
#     resources are automatically loaded when Module.getImpl() is called.
template("module_desc_java") {
  _target_name = target_name

  _libraries_file = "${target_gen_dir}/${_target_name}.libraries"
  generated_file("${_target_name}__libraries") {
    if (defined(invoker.shared_libraries)) {
      deps = invoker.shared_libraries
    }
    outputs = [ _libraries_file ]
    data_keys = [ "shared_libraries" ]
    walk_keys = [ "shared_libraries_barrier" ]
    rebase = root_build_dir
    output_conversion = "value"
  }

  _srcjar = "$target_gen_dir/${_target_name}__srcjar.srcjar"
  action_with_pydeps("${_target_name}__srcjar") {
    script = "//components/module_installer/android/module_desc_java.py"
    outputs = [ _srcjar ]

    # Do not add a dep on the generated_file target in order to avoid having
    # to build the native libraries before this target. The dependency is
    # instead captured via a depfile.
    depfile = "$target_gen_dir/$target_name.d"
    args = [
      "--module",
      invoker.module_name,
      "--libraries-file",
      rebase_path(_libraries_file, root_out_dir),
      "--output",
      rebase_path(_srcjar, root_out_dir),
      "--depfile",
      rebase_path(depfile, root_out_dir),
    ]

    if (defined(invoker.load_native_on_get_impl) &&
        invoker.load_native_on_get_impl) {
      args += [ "--load-native-on-get-impl" ]
    }

    if (defined(invoker.paks)) {
      _rebased_paks = []
      foreach(_pak, invoker.paks) {
        _rebased_paks += [ rebase_path(_pak, root_out_dir) ]
      }
      args += [ "--paks=$_rebased_paks" ]
    }
  }

  android_library(_target_name) {
    deps = [ "//components/module_installer/android:module_installer_java" ]
    srcjar_deps = [ ":${_target_name}__srcjar" ]
  }
}