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") |
6 | 7 |
7 if (is_android) { | 8 if (is_android) { |
8 import("//build/config/android/rules.gni") | 9 import("//build/config/android/rules.gni") |
9 import("//build/config/zip.gni") | 10 import("//build/config/zip.gni") |
10 } | 11 } |
11 | 12 |
12 # Generates a Service binary. The parameters of this template are those of an | 13 # Generates a Service "package", which includes: |
13 # executable. | 14 # |
| 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 |
14 template("service") { | 21 template("service") { |
15 base_target_name = target_name | 22 base_target_name = target_name |
16 if (defined(invoker.output_name)) { | 23 if (defined(invoker.output_name)) { |
17 base_target_name = invoker.output_name | 24 base_target_name = invoker.output_name |
18 } | 25 } |
19 | 26 |
| 27 final_target_name = target_name |
| 28 |
20 service_deps = [] | 29 service_deps = [] |
21 if (defined(invoker.deps)) { | 30 if (defined(invoker.deps)) { |
22 service_deps += invoker.deps | 31 service_deps += invoker.deps |
23 } | 32 } |
24 | 33 |
25 service_data_deps = | 34 service_data_deps = |
26 [ "//services/service_manager/public/cpp/standalone_service:main" ] | 35 [ "//services/service_manager/public/cpp/standalone_service:main" ] |
27 | 36 |
| 37 if (defined(invoker.resources)) { |
| 38 copy_step_name = "${base_target_name}__copy_resources" |
| 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 } |
| 51 |
28 if (defined(invoker.data_deps)) { | 52 if (defined(invoker.data_deps)) { |
29 service_data_deps += invoker.data_deps | 53 service_data_deps += invoker.data_deps |
30 } | 54 } |
31 | 55 |
32 if (defined(invoker.resources)) { | |
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 } | |
41 } | |
42 | |
43 if (is_win) { | 56 if (is_win) { |
44 executable_extension = "service.exe" | 57 executable_extension = "service.exe" |
45 } else { | 58 } else { |
46 executable_extension = "service" | 59 executable_extension = "service" |
47 } | 60 } |
48 | 61 |
49 executable(target_name) { | 62 executable_target_name = base_target_name + "_executable" |
| 63 executable_name = base_target_name + "." + executable_extension |
| 64 |
| 65 executable(executable_target_name) { |
50 output_name = base_target_name | 66 output_name = base_target_name |
51 output_extension = executable_extension | 67 output_extension = executable_extension |
52 | 68 |
53 if (defined(invoker.cflags)) { | 69 if (defined(invoker.cflags)) { |
54 cflags = invoker.cflags | 70 cflags = invoker.cflags |
55 } | 71 } |
56 if (defined(invoker.cflags_c)) { | 72 if (defined(invoker.cflags_c)) { |
57 cflags_c = invoker.cflags_c | 73 cflags_c = invoker.cflags_c |
58 } | 74 } |
59 if (defined(invoker.cflags_cc)) { | 75 if (defined(invoker.cflags_cc)) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 if (defined(invoker.public)) { | 129 if (defined(invoker.public)) { |
114 public = invoker.public | 130 public = invoker.public |
115 } | 131 } |
116 if (defined(invoker.sources)) { | 132 if (defined(invoker.sources)) { |
117 sources = invoker.sources | 133 sources = invoker.sources |
118 } | 134 } |
119 if (defined(invoker.testonly)) { | 135 if (defined(invoker.testonly)) { |
120 testonly = invoker.testonly | 136 testonly = invoker.testonly |
121 } | 137 } |
122 } | 138 } |
| 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 } |
123 } | 163 } |
OLD | NEW |