| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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/dcheck_always_on.gni") | 5 import("//build/config/dcheck_always_on.gni") |
| 6 import("//services/service_manager/public/constants.gni") | |
| 7 | 6 |
| 8 # Generates a static catalog manifest to be loaded at runtime. This manifest | 7 # Generates a static catalog manifest to be loaded at runtime. This manifest |
| 9 # contains the union of all individual service manifests specified by the | 8 # contains the union of all individual service manifests specified by the |
| 10 # template parameters. | 9 # template parameters. |
| 11 # | 10 # |
| 12 # The output of a catalog rule is always a file named: | 11 # The output of a catalog rule is always a file named: |
| 13 # | 12 # |
| 14 # ${target_gen_dir}/${target_name}.json | 13 # ${target_gen_dir}/${target_name}.json |
| 15 # | 14 # |
| 16 # A Service Manager embedder uses a catalog manifest as its singular source of | 15 # A Service Manager embedder uses a catalog manifest as its singular source of |
| 17 # truth regarding available services in the system. | 16 # truth regarding available services in the system. |
| 18 # | 17 # |
| 19 # Parameters: | 18 # Parameters: |
| 20 # | 19 # |
| 21 # embedded_services (optional) | 20 # embedded_services (optional) |
| 22 # A list of names of services which must be embedded by the Service | 21 # A list of service manifest targets whose outputs correspond to services |
| 23 # Manager embedder's binary in order to function. Services listed here | 22 # embedded by the Service Manager embedder's binary. Outputs of targets |
| 24 # should have a corresponding service_manifest rule entry in deps. | 23 # listed here will be embedded in the catalog within its |
| 24 # "embedded_services" list. |
| 25 # | 25 # |
| 26 # standalone_services (optional) | 26 # standalone_services (optional) |
| 27 # A list of names of services which must be available to the Service | 27 # A list of service manifest targets whose outputs correspond to services |
| 28 # Manager at runtime, in a Packages/ directory relative to the Service | 28 # with standalone binaries which must be available to the Service Manager |
| 29 # Manager embedder's binary. | 29 # at runtime. Outputs of targets listed here will be embedded in the |
| 30 # catalog within its "standalone_services" list. |
| 31 # |
| 32 # Typically a standalone service binary is expected to live next to |
| 33 # the Service Manager embedder's binary, with the name |
| 34 # "${service_name}.service", with an additional ".exe" suffix on Windows. |
| 35 # Binaries following this naming scheme are typically output by "service" |
| 36 # targets (see //services/service_manager/public/cpp/service.gni). |
| 30 # | 37 # |
| 31 # executable_overrides (optional) | 38 # executable_overrides (optional) |
| 32 # A list of overrides to apply in catalog metadata for individual | 39 # A list of overrides to apply in catalog metadata for individual |
| 33 # services. An override string must be of the form | 40 # services. An override string must be of the form |
| 34 # | 41 # |
| 35 # "<service_name>:<executable_path>" | 42 # "<service_name>:<executable_path>" |
| 36 # | 43 # |
| 37 # The special token @EXE_DIR may be used in |executable_path| to denote | 44 # The special token @EXE_DIR may be used in |executable_path| to denote |
| 38 # a path relative to the Service Manager embedder's binary, substituted | 45 # a path relative to the Service Manager embedder's binary, substituted |
| 39 # at runtime. For example: | 46 # at runtime. For example: |
| 40 # | 47 # |
| 41 # "content_browser:@EXE_DIR/chrome" | 48 # "content_browser:@EXE_DIR/chrome" |
| 42 # | 49 # |
| 43 # would indicate to the Service Manager embedder that the | 50 # would indicate to the Service Manager embedder that the |
| 44 # "content_browser" service can be started by running the "chrome" | 51 # "content_browser" service can be started by running the "chrome" |
| 45 # executable in the embedder's own directory. | 52 # executable in the embedder's own directory. |
| 46 # | 53 # |
| 47 # included_catalogs (optional) | 54 # This overrides the default binary name expectation described in |
| 48 # A list of other catalog files to be included within this catalog. | 55 # |standalone_services| above. |
| 56 # |
| 57 # catalog_deps (optional) |
| 58 # A list of other catalog targets whose outputs will be included within |
| 59 # this catalog. Targets in this list |
| 49 # | 60 # |
| 50 template("catalog") { | 61 template("catalog") { |
| 51 output_filename = "$target_gen_dir/${target_name}.json" | 62 output_filename = "$target_gen_dir/${target_name}.json" |
| 52 action(target_name) { | 63 action(target_name) { |
| 53 testonly = defined(invoker.testonly) && invoker.testonly | 64 testonly = defined(invoker.testonly) && invoker.testonly |
| 54 | 65 |
| 55 script = "//services/catalog/public/tools/generate_manifest.py" | 66 script = "//services/catalog/public/tools/generate_manifest.py" |
| 56 | 67 |
| 68 inputs = [] |
| 57 outputs = [ | 69 outputs = [ |
| 58 output_filename, | 70 output_filename, |
| 59 ] | 71 ] |
| 60 | 72 |
| 61 args = [ | 73 args = [ "--output=" + rebase_path(output_filename) ] |
| 62 "--output=" + rebase_path(output_filename), | |
| 63 "--packages-dir=" + rebase_path("$root_out_dir/$packages_directory"), | |
| 64 ] | |
| 65 | 74 |
| 66 if (is_debug || dcheck_always_on) { | 75 if (is_debug || dcheck_always_on) { |
| 67 args += [ "--pretty" ] | 76 args += [ "--pretty" ] |
| 68 } | 77 } |
| 69 | 78 |
| 79 deps = [] |
| 80 if (defined(invoker.deps)) { |
| 81 deps += invoker.deps |
| 82 } |
| 83 |
| 70 if (defined(invoker.embedded_services)) { | 84 if (defined(invoker.embedded_services)) { |
| 71 args += [ "--embedded-services" ] + invoker.embedder_services | 85 args += [ "--embedded-services" ] |
| 86 foreach(manifest_target, invoker.embedded_services) { |
| 87 manifest_target_dir = get_label_info(manifest_target, "target_gen_dir") |
| 88 manifest_target_name = get_label_info(manifest_target, "name") |
| 89 manifest_filename = "$manifest_target_dir/${manifest_target_name}.json" |
| 90 |
| 91 inputs += [ "$manifest_filename" ] |
| 92 deps += [ manifest_target ] |
| 93 args += [ rebase_path(manifest_filename, root_build_dir) ] |
| 94 |
| 95 # Ensure that each entry does in fact reference a service manifest rule. |
| 96 label_no_toolchain = |
| 97 get_label_info(manifest_target, "label_no_toolchain") |
| 98 toolchain = get_label_info(manifest_target, "toolchain") |
| 99 deps += [ "${label_no_toolchain}__is_service_manifest(${toolchain})" ] |
| 100 } |
| 72 } | 101 } |
| 73 | 102 |
| 74 if (defined(invoker.standalone_services)) { | 103 if (defined(invoker.standalone_services)) { |
| 75 args += [ "--standalone-services" ] + invoker.standalone_services | 104 args += [ "--standalone-services" ] |
| 105 foreach(manifest_target, invoker.standalone_services) { |
| 106 manifest_target_dir = get_label_info(manifest_target, "target_gen_dir") |
| 107 manifest_target_name = get_label_info(manifest_target, "name") |
| 108 manifest_filename = "$manifest_target_dir/${manifest_target_name}.json" |
| 109 |
| 110 inputs += [ "$manifest_filename" ] |
| 111 deps += [ manifest_target ] |
| 112 args += [ rebase_path(manifest_filename, root_build_dir) ] |
| 113 |
| 114 # Ensure that each entry does in fact reference a service manifest rule. |
| 115 label_no_toolchain = |
| 116 get_label_info(manifest_target, "label_no_toolchain") |
| 117 toolchain = get_label_info(manifest_target, "toolchain") |
| 118 deps += [ "${label_no_toolchain}__is_service_manifest(${toolchain})" ] |
| 119 } |
| 76 } | 120 } |
| 77 | 121 |
| 78 if (defined(invoker.executable_overrides)) { | 122 if (defined(invoker.executable_overrides)) { |
| 79 args += | 123 args += |
| 80 [ "--override-service-executables" ] + invoker.executable_overrides | 124 [ "--override-service-executables" ] + invoker.executable_overrides |
| 81 } | 125 } |
| 82 | 126 |
| 83 if (defined(invoker.included_catalogs)) { | 127 if (defined(invoker.catalog_deps)) { |
| 84 args += [ "--include-catalogs" ] | 128 args += [ "--include-catalogs" ] |
| 85 foreach(catalog_filename, invoker.included_catalogs) { | 129 foreach(catalog_target, invoker.catalog_deps) { |
| 86 args += [ rebase_path(catalog_filename) ] | 130 catalog_target_dir = get_label_info(catalog_target, "target_gen_dir") |
| 131 catalog_target_name = get_label_info(catalog_target, "name") |
| 132 catalog_filename = "$catalog_target_dir/${catalog_target_name}.json" |
| 133 |
| 134 inputs += [ "$catalog_filename" ] |
| 135 deps += [ catalog_target ] |
| 136 args += [ rebase_path(catalog_filename, root_build_dir) ] |
| 87 } | 137 } |
| 88 } | 138 } |
| 89 | |
| 90 if (defined(invoker.deps)) { | |
| 91 deps = invoker.deps | |
| 92 } | |
| 93 } | 139 } |
| 94 } | 140 } |
| OLD | NEW |