| 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 import("//services/service_manager/public/constants.gni") |
| 7 | 7 |
| 8 if (is_android) { | 8 if (is_android) { |
| 9 import("//build/config/android/rules.gni") | 9 import("//build/config/android/rules.gni") |
| 10 import("//build/config/zip.gni") | 10 import("//build/config/zip.gni") |
| 11 } | 11 } |
| 12 | 12 |
| 13 # Generates a Service "package", which includes: | 13 # Generates a Service "package", which includes: |
| 14 # . A self-named subdirectory | |
| 15 # . A binary .library | |
| 16 # . A resources subdirectory alongside .library that contains the contents of | |
| 17 # "resources" | |
| 18 # | 14 # |
| 19 # The parameters of this template are those of a shared library. | 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 |
| 20 template("service") { | 21 template("service") { |
| 21 base_target_name = target_name | 22 base_target_name = target_name |
| 22 if (defined(invoker.output_name)) { | 23 if (defined(invoker.output_name)) { |
| 23 base_target_name = invoker.output_name | 24 base_target_name = invoker.output_name |
| 24 } | 25 } |
| 25 | 26 |
| 26 final_target_name = target_name | 27 final_target_name = target_name |
| 27 | 28 |
| 28 library_deps = [] | 29 service_deps = [] |
| 29 if (defined(invoker.deps)) { | 30 if (defined(invoker.deps)) { |
| 30 library_deps += invoker.deps | 31 service_deps += invoker.deps |
| 31 } | 32 } |
| 32 | 33 |
| 33 library_data_deps = [] | 34 service_data_deps = |
| 35 [ "//services/service_manager/public/cpp/standalone_service:main" ] |
| 34 | 36 |
| 35 if (defined(invoker.resources)) { | 37 if (defined(invoker.resources)) { |
| 36 copy_step_name = "${base_target_name}__copy_resources" | 38 copy_step_name = "${base_target_name}__copy_resources" |
| 37 copy(copy_step_name) { | 39 copy(copy_step_name) { |
| 38 sources = invoker.resources | 40 sources = invoker.resources |
| 39 outputs = [ | 41 outputs = [ |
| 40 "${root_out_dir}/${packages_directory}/${base_target_name}/resources/{{s
ource_file_part}}", | 42 "${root_out_dir}/${packages_directory}/${base_target_name}/resources/{{s
ource_file_part}}", |
| 41 ] | 43 ] |
| 42 if (defined(invoker.testonly)) { | 44 if (defined(invoker.testonly)) { |
| 43 testonly = invoker.testonly | 45 testonly = invoker.testonly |
| 44 } | 46 } |
| 45 deps = library_deps | 47 deps = service_deps |
| 46 } | 48 } |
| 47 library_data_deps += [ ":$copy_step_name" ] | 49 service_data_deps += [ ":$copy_step_name" ] |
| 48 } | 50 } |
| 49 | 51 |
| 50 output = base_target_name + ".library" | 52 if (defined(invoker.data_deps)) { |
| 51 library_target_name = base_target_name + "_library" | 53 service_data_deps += invoker.data_deps |
| 52 library_name = "${shlib_prefix}${library_target_name}${shlib_extension}" | 54 } |
| 53 | 55 |
| 54 shared_library(library_target_name) { | 56 executable_target_name = base_target_name + "_executable" |
| 57 executable_name = base_target_name + ".service" |
| 58 |
| 59 executable(executable_target_name) { |
| 60 output_name = base_target_name |
| 61 output_extension = "service" |
| 62 |
| 55 if (defined(invoker.cflags)) { | 63 if (defined(invoker.cflags)) { |
| 56 cflags = invoker.cflags | 64 cflags = invoker.cflags |
| 57 } | 65 } |
| 58 if (defined(invoker.cflags_c)) { | 66 if (defined(invoker.cflags_c)) { |
| 59 cflags_c = invoker.cflags_c | 67 cflags_c = invoker.cflags_c |
| 60 } | 68 } |
| 61 if (defined(invoker.cflags_cc)) { | 69 if (defined(invoker.cflags_cc)) { |
| 62 cflags_cc = invoker.cflags_cc | 70 cflags_cc = invoker.cflags_cc |
| 63 } | 71 } |
| 64 if (defined(invoker.cflags_objc)) { | 72 if (defined(invoker.cflags_objc)) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 76 if (defined(invoker.ldflags)) { | 84 if (defined(invoker.ldflags)) { |
| 77 ldflags = invoker.ldflags | 85 ldflags = invoker.ldflags |
| 78 } | 86 } |
| 79 if (defined(invoker.lib_dirs)) { | 87 if (defined(invoker.lib_dirs)) { |
| 80 lib_dirs = invoker.lib_dirs | 88 lib_dirs = invoker.lib_dirs |
| 81 } | 89 } |
| 82 if (defined(invoker.libs)) { | 90 if (defined(invoker.libs)) { |
| 83 libs = invoker.libs | 91 libs = invoker.libs |
| 84 } | 92 } |
| 85 | 93 |
| 86 data_deps = [] | 94 data_deps = service_data_deps |
| 87 if (!defined(invoker.avoid_runner_cycle) || !invoker.avoid_runner_cycle) { | |
| 88 # Give the user an out; as some Services are depended on by the runner. | |
| 89 data_deps += [ "//services/service_manager/standalone" ] | |
| 90 } | |
| 91 if (defined(invoker.data_deps)) { | |
| 92 data_deps += invoker.data_deps | |
| 93 } | |
| 94 data_deps += library_data_deps | |
| 95 | 95 |
| 96 deps = [ | 96 deps = [ |
| 97 "//mojo/public/c/system:set_thunks_for_app", | 97 "//services/service_manager/public/cpp/standalone_service:main", |
| 98 "//services/service_manager/public/cpp:application_support", | |
| 99 ] | 98 ] |
| 100 | 99 |
| 101 deps += library_deps | 100 deps += service_deps |
| 102 if (defined(invoker.public_deps)) { | 101 if (defined(invoker.public_deps)) { |
| 103 public_deps = invoker.public_deps | 102 public_deps = invoker.public_deps |
| 104 } | 103 } |
| 105 if (defined(invoker.all_dependent_configs)) { | 104 if (defined(invoker.all_dependent_configs)) { |
| 106 all_dependent_configs = invoker.all_dependent_configs | 105 all_dependent_configs = invoker.all_dependent_configs |
| 107 } | 106 } |
| 108 if (defined(invoker.public_configs)) { | 107 if (defined(invoker.public_configs)) { |
| 109 public_configs = invoker.public_configs | 108 public_configs = invoker.public_configs |
| 110 } | 109 } |
| 111 if (defined(invoker.check_includes)) { | 110 if (defined(invoker.check_includes)) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 131 } | 130 } |
| 132 } | 131 } |
| 133 | 132 |
| 134 copy(final_target_name) { | 133 copy(final_target_name) { |
| 135 forward_variables_from(invoker, | 134 forward_variables_from(invoker, |
| 136 [ | 135 [ |
| 137 "testonly", | 136 "testonly", |
| 138 "visibility", | 137 "visibility", |
| 139 ]) | 138 ]) |
| 140 deps = [ | 139 deps = [ |
| 141 ":${library_target_name}", | 140 ":${executable_target_name}", |
| 142 ] | 141 ] |
| 143 | 142 |
| 143 # NOTE: We have to explicitly inherit the same data_deps as the executable |
| 144 # target itself, rather than specifying a data depenedency on the executable |
| 145 # target. This avoids needless duplication of service binary artifacts in |
| 146 # test isolates, as the executable is unused in its original location. |
| 147 data_deps = service_data_deps |
| 148 |
| 144 sources = [ | 149 sources = [ |
| 145 "${root_shlib_dir}/${library_name}", | 150 "${root_out_dir}/${executable_name}", |
| 146 ] | 151 ] |
| 147 outputs = [ | 152 outputs = [ |
| 148 "${root_out_dir}/${packages_directory}/${base_target_name}/${output}", | 153 "${root_out_dir}/${packages_directory}/${base_target_name}/${executable_na
me}", |
| 149 ] | 154 ] |
| 150 } | 155 } |
| 151 } | 156 } |
| OLD | NEW |