| OLD | NEW |
| 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/toolchain/toolchain.gni") | 5 import("//build/toolchain/toolchain.gni") |
| 6 import("//services/service_manager/public/constants.gni") | |
| 7 | 6 |
| 8 if (is_android) { | 7 if (is_android) { |
| 9 import("//build/config/android/rules.gni") | 8 import("//build/config/android/rules.gni") |
| 10 import("//build/config/zip.gni") | 9 import("//build/config/zip.gni") |
| 11 } | 10 } |
| 12 | 11 |
| 13 # Generates a Service "package", which includes: | 12 # Generates a Service binary. The parameters of this template are those of an |
| 14 # | 13 # executable. |
| 15 # - A self-named subdirectory | |
| 16 # - A binary .service executable | |
| 17 # - A resources subdirectory alongside the executable, which contains the | |
| 18 # contents of "resources" | |
| 19 # | |
| 20 # The parameters of this template are those of an executable | |
| 21 template("service") { | 14 template("service") { |
| 22 base_target_name = target_name | 15 base_target_name = target_name |
| 23 if (defined(invoker.output_name)) { | 16 if (defined(invoker.output_name)) { |
| 24 base_target_name = invoker.output_name | 17 base_target_name = invoker.output_name |
| 25 } | 18 } |
| 26 | 19 |
| 27 final_target_name = target_name | |
| 28 | |
| 29 service_deps = [] | 20 service_deps = [] |
| 30 if (defined(invoker.deps)) { | 21 if (defined(invoker.deps)) { |
| 31 service_deps += invoker.deps | 22 service_deps += invoker.deps |
| 32 } | 23 } |
| 33 | 24 |
| 34 service_data_deps = | 25 service_data_deps = |
| 35 [ "//services/service_manager/public/cpp/standalone_service:main" ] | 26 [ "//services/service_manager/public/cpp/standalone_service:main" ] |
| 36 | 27 |
| 37 if (defined(invoker.resources)) { | 28 if (defined(invoker.data_deps)) { |
| 38 copy_step_name = "${base_target_name}__copy_resources" | 29 service_data_deps += invoker.data_deps |
| 39 copy(copy_step_name) { | |
| 40 sources = invoker.resources | |
| 41 outputs = [ | |
| 42 "${root_out_dir}/${packages_directory}/${base_target_name}/resources/{{s
ource_file_part}}", | |
| 43 ] | |
| 44 if (defined(invoker.testonly)) { | |
| 45 testonly = invoker.testonly | |
| 46 } | |
| 47 deps = service_deps | |
| 48 } | |
| 49 service_data_deps += [ ":$copy_step_name" ] | |
| 50 } | 30 } |
| 51 | 31 |
| 52 if (defined(invoker.data_deps)) { | 32 if (defined(invoker.resources)) { |
| 53 service_data_deps += invoker.data_deps | 33 # TODO(rockot): Remove this once all existing service targets have stopped |
| 34 # setting |resources|. This target serves no purpose other than to ensure |
| 35 # that |resources| is actually used, avoiding GN complaints. |
| 36 source_set("${target_name}__unused_resources_target") { |
| 37 testonly = true |
| 38 sources = invoker.resources |
| 39 deps = invoker.deps |
| 40 } |
| 54 } | 41 } |
| 55 | 42 |
| 56 if (is_win) { | 43 if (is_win) { |
| 57 executable_extension = "service.exe" | 44 executable_extension = "service.exe" |
| 58 } else { | 45 } else { |
| 59 executable_extension = "service" | 46 executable_extension = "service" |
| 60 } | 47 } |
| 61 | 48 |
| 62 executable_target_name = base_target_name + "_executable" | 49 executable(target_name) { |
| 63 executable_name = base_target_name + "." + executable_extension | |
| 64 | |
| 65 executable(executable_target_name) { | |
| 66 output_name = base_target_name | 50 output_name = base_target_name |
| 67 output_extension = executable_extension | 51 output_extension = executable_extension |
| 68 | 52 |
| 69 if (defined(invoker.cflags)) { | 53 if (defined(invoker.cflags)) { |
| 70 cflags = invoker.cflags | 54 cflags = invoker.cflags |
| 71 } | 55 } |
| 72 if (defined(invoker.cflags_c)) { | 56 if (defined(invoker.cflags_c)) { |
| 73 cflags_c = invoker.cflags_c | 57 cflags_c = invoker.cflags_c |
| 74 } | 58 } |
| 75 if (defined(invoker.cflags_cc)) { | 59 if (defined(invoker.cflags_cc)) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 if (defined(invoker.public)) { | 113 if (defined(invoker.public)) { |
| 130 public = invoker.public | 114 public = invoker.public |
| 131 } | 115 } |
| 132 if (defined(invoker.sources)) { | 116 if (defined(invoker.sources)) { |
| 133 sources = invoker.sources | 117 sources = invoker.sources |
| 134 } | 118 } |
| 135 if (defined(invoker.testonly)) { | 119 if (defined(invoker.testonly)) { |
| 136 testonly = invoker.testonly | 120 testonly = invoker.testonly |
| 137 } | 121 } |
| 138 } | 122 } |
| 139 | |
| 140 copy(final_target_name) { | |
| 141 forward_variables_from(invoker, | |
| 142 [ | |
| 143 "testonly", | |
| 144 "visibility", | |
| 145 ]) | |
| 146 deps = [ | |
| 147 ":${executable_target_name}", | |
| 148 ] | |
| 149 | |
| 150 # NOTE: We have to explicitly inherit the same data_deps as the executable | |
| 151 # target itself, rather than specifying a data depenedency on the executable | |
| 152 # target. This avoids needless duplication of service binary artifacts in | |
| 153 # test isolates, as the executable is unused in its original location. | |
| 154 data_deps = service_data_deps | |
| 155 | |
| 156 sources = [ | |
| 157 "${root_out_dir}/${executable_name}", | |
| 158 ] | |
| 159 outputs = [ | |
| 160 "${root_out_dir}/${packages_directory}/${base_target_name}/${executable_na
me}", | |
| 161 ] | |
| 162 } | |
| 163 } | 123 } |
| OLD | NEW |