Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: build/config/mac/rules.gni

Issue 1910133002: [iOS/Mac/GN] The framework_bundle template should not force dependencies to link it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/config/ios/rules.gni ('k') | ios/third_party/earl_grey/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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("//build/config/mac/mac_sdk.gni") 6 import("//build/config/mac/mac_sdk.gni")
7 7
8 # This is used as the base template for both iOS and Mac frameworks.. 8 # This is used as the base template for both iOS and Mac frameworks..
9 # 9 #
10 # By default, the bundle target this template generates does not link the
11 # resulting framework into anything that depends on it. If a dependency wants
12 # a link-time (as well as build-time) dependency on the framework bundle,
13 # depend against "$target_name+link". If only the build-time dependency is
14 # required (e.g., for copying into another bundle), then use "$target_name".
15 #
10 # Arguments 16 # Arguments
11 # 17 #
12 # output_name: 18 # output_name:
13 # (optional) string, name of the generated framework without the 19 # (optional) string, name of the generated framework without the
14 # .framework suffix. If omitted, defaults to target_name. 20 # .framework suffix. If omitted, defaults to target_name.
15 # 21 #
16 # framework_version: 22 # framework_version:
17 # (optional) string, version of the framework. Typically this is a 23 # (optional) string, version of the framework. Typically this is a
18 # single letter, like "A". If omitted, the Versions/ subdirectory 24 # single letter, like "A". If omitted, the Versions/ subdirectory
19 # structure will not be created, and build output will go directly 25 # structure will not be created, and build output will go directly
20 # into the framework subdirectory. 26 # into the framework subdirectory.
21 # 27 #
28 # This template provides two targets for the resulting framework bundle. The
29 # link-time behavior varies depending on which of the two targets below is
30 # added as a dependency:
31 # - $target_name only adds a build-time dependency. Targets that depend on
32 # it will not link against the framework.
33 # - $target_name+link adds a build-time and link-time dependency. Targets
34 # that depend on it will link against the framework.
35 #
36 # The build-time-only dependency is used for when a target needs to use the
37 # framework either only for resources, or because the target loads it at run-
38 # time, via dlopen() or NSBundle. The link-time dependency will cause the
39 # dependee to have the framework loaded by dyld at launch.
40 #
41 # Example of build-time only dependency:
42 #
43 # framework_bundle("CoreTeleportation") {
44 # sources = [ ... ]
45 # }
46 #
47 # bundle_data("core_teleportation_bundle_data") {
48 # deps = [ ":CoreTeleportation" ]
49 # sources = [ "$root_out_dir/CoreTeleportation.framework" ]
50 # outputs = [ "{{bundle_root_dir}}/Frameworks/{{source_file_part}}" ]
51 # }
52 #
53 # app_bundle("GoatTeleporter") {
54 # sources = [ ... ]
55 # deps = [
56 # ":core_teleportation_bundle_data",
57 # ]
58 # }
59 #
60 # The GoatTeleporter.app will not directly link against
61 # CoreTeleportation.framework, but it will be included in the bundle's
62 # Frameworks directory.
63 #
64 # Example of link-time dependency:
65 #
66 # framework_bundle("CoreTeleportation") {
67 # sources = [ ... ]
68 # ldflags = [
69 # "-install_name",
70 # "@executable_path/../Frameworks/$target_name.framework"
71 # ]
72 # }
73 #
74 # bundle_data("core_teleportation_bundle_data") {
75 # deps = [ ":CoreTeleportation+link" ]
76 # sources = [ "$root_out_dir/CoreTeleportation.framework" ]
77 # outputs = [ "{{bundle_root_dir}}/Frameworks/{{source_file_part}}" ]
78 # }
79 #
80 # app_bundle("GoatTeleporter") {
81 # sources = [ ... ]
82 # deps = [
83 # ":core_teleportation_bundle_data",
84 # ]
85 # }
86 #
87 # Note that the framework is still copied to the app's bundle, but dyld will
88 # load this library when the app is launched because it uses the "+link"
89 # target as a dependency. This also requires that the framework set its
90 # install_name so that dyld can locate it.
91 #
22 # See "gn help shared_library" for more information on arguments supported 92 # See "gn help shared_library" for more information on arguments supported
23 # by shared library target. 93 # by shared library target.
24 template("framework_bundle") { 94 template("framework_bundle") {
25 _target_name = target_name 95 _target_name = target_name
26 _output_name = target_name 96 _output_name = target_name
27 if (defined(invoker.output_name)) { 97 if (defined(invoker.output_name)) {
28 _output_name = invoker.output_name 98 _output_name = invoker.output_name
29 } 99 }
30 100
31 # If the framework is unversionned, the final _target_name will be the 101 # If the framework is unversionned, the final _target_name will be the
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 public_deps = [ 143 public_deps = [
74 ":$_shared_library_target", 144 ":$_shared_library_target",
75 ] 145 ]
76 } 146 }
77 147
78 _framework_public_config = _target_name + "_public_config" 148 _framework_public_config = _target_name + "_public_config"
79 config(_framework_public_config) { 149 config(_framework_public_config) {
80 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs 150 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs
81 # and include_dirs to avoid duplicate values on the command-line. 151 # and include_dirs to avoid duplicate values on the command-line.
82 visibility = [ ":$_framework_target" ] 152 visibility = [ ":$_framework_target" ]
83 common_flags = [ "-F" + rebase_path("$root_out_dir/.", root_out_dir) ] 153 ldflags = [ "-F" + rebase_path("$root_out_dir/.", root_out_dir) ]
84 cflags_objc = common_flags
85 cflags_objcc = common_flags
86 ldflags = common_flags
87 lib_dirs = [ root_out_dir ] 154 lib_dirs = [ root_out_dir ]
88 libs = [ _framework_name ] 155 libs = [ _framework_name ]
89 } 156 }
90 157
91 create_bundle(_framework_target) { 158 create_bundle(_framework_target) {
92 forward_variables_from(invoker, 159 forward_variables_from(invoker,
93 [ 160 [
94 "data_deps", 161 "data_deps",
95 "deps", 162 "deps",
96 "public_deps", 163 "public_deps",
97 "testonly", 164 "testonly",
98 ]) 165 ])
99 166
100 if (defined(_framework_version)) { 167 if (defined(_framework_version)) {
101 visibility = [ ":$_target_name" ] 168 visibility = [ ":$_target_name" ]
102 } else { 169 } else {
103 forward_variables_from(invoker, [ "visibility" ]) 170 if (defined(invoker.visibility)) {
171 visibility = invoker.visibility
172 visibility += [ ":$_target_name+link" ]
173 }
104 } 174 }
105 175
106 if (!defined(public_deps)) { 176 if (!defined(public_deps)) {
107 public_deps = [] 177 public_deps = []
108 } 178 }
109 public_deps += [ ":$_shared_library_bundle_data" ] 179 public_deps += [ ":$_shared_library_bundle_data" ]
110 180
111 public_configs = [ ":$_framework_public_config" ]
112
113 bundle_root_dir = _framework_root_dir 181 bundle_root_dir = _framework_root_dir
114 bundle_resources_dir = "$bundle_root_dir/Resources" 182 bundle_resources_dir = "$bundle_root_dir/Resources"
115 bundle_executable_dir = "$bundle_root_dir" 183 bundle_executable_dir = "$bundle_root_dir"
116 } 184 }
117 185
118 if (defined(_framework_version)) { 186 if (defined(_framework_version)) {
119 action(_target_name) { 187 action(_target_name) {
120 forward_variables_from(invoker, 188 forward_variables_from(invoker, [ "testonly" ])
121 [ 189
122 "visibility", 190 if (defined(invoker.visibility)) {
123 "testonly", 191 visibility = invoker.visibility
124 ]) 192 visibility += [ ":$_target_name+link" ]
193 }
194
125 script = "$root_out_dir/gyp-mac-tool" 195 script = "$root_out_dir/gyp-mac-tool"
126 outputs = [ 196 outputs = [
127 "$root_out_dir/$_framework_name/Versions/Current", 197 "$root_out_dir/$_framework_name/Versions/Current",
128 ] 198 ]
129 args = [ 199 args = [
130 "package-framework", 200 "package-framework",
131 "$_framework_name", 201 "$_framework_name",
132 "$_framework_version", 202 "$_framework_version",
133 ] 203 ]
134 public_deps = [ 204 public_deps = [
135 ":$_framework_target", 205 ":$_framework_target",
136 ] 206 ]
137 } 207 }
138 } 208 }
209
210 group(_target_name + "+link") {
211 forward_variables_from(invoker,
212 [
213 "visibility",
214 "testonly",
215 ])
216 public_deps = [
217 ":$_target_name",
218 ]
219 public_configs = [ ":$_framework_public_config" ]
220 }
139 } 221 }
140 222
141 # Template to combile .xib or .storyboard files. 223 # Template to combile .xib or .storyboard files.
142 # 224 #
143 # 225 #
144 # Arguments 226 # Arguments
145 # 227 #
146 # sources: 228 # sources:
147 # list of string, sources to compile 229 # list of string, sources to compile
148 # 230 #
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 303 }
222 304
223 outputs = [ 305 outputs = [
224 "$_output_path/{{source_file_part}}", 306 "$_output_path/{{source_file_part}}",
225 ] 307 ]
226 } 308 }
227 } 309 }
228 310
229 # Template to package a shared library into a Mac framework bundle. 311 # Template to package a shared library into a Mac framework bundle.
230 # 312 #
313 # This template provides two targets to control whether the framework is
314 # merely built when targets depend on it, or whether it is linked as well:
315 # "$target_name" and "$target_name+link".
316 #
317 # See the //build/config/mac/rules.gni:framework_bundle for a discussion
318 # and examples.
319 #
231 # Arguments 320 # Arguments
232 # 321 #
233 # info_plist: 322 # info_plist:
234 # string, path to the Info.plist file that will be used for the bundle. 323 # string, path to the Info.plist file that will be used for the bundle.
235 # 324 #
236 # output_name: 325 # output_name:
237 # (optional) string, name of the generated framework without the 326 # (optional) string, name of the generated framework without the
238 # .framework suffix. If omitted, defaults to target_name. 327 # .framework suffix. If omitted, defaults to target_name.
239 # 328 #
240 # framework_version: 329 # framework_version:
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 ]) 512 ])
424 if (!defined(deps)) { 513 if (!defined(deps)) {
425 deps = [] 514 deps = []
426 } 515 }
427 deps += [ ":$_loadable_module_bundle_data" ] 516 deps += [ ":$_loadable_module_bundle_data" ]
428 517
429 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents" 518 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents"
430 bundle_executable_dir = "$bundle_root_dir/MacOS" 519 bundle_executable_dir = "$bundle_root_dir/MacOS"
431 } 520 }
432 } 521 }
OLDNEW
« no previous file with comments | « build/config/ios/rules.gni ('k') | ios/third_party/earl_grey/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698