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