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

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: Documentation 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 #
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".
9 # 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 sitll copied to the app's bundle, but dyld will
sdefresne 2016/04/25 16:47:52 nit: sitll -> still
Robert Sesek 2016/04/25 17:47:45 Done.
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.
22 # See "gn help shared_library" for more information on arguments supported 91 # See "gn help shared_library" for more information on arguments supported
sdefresne 2016/04/25 16:47:52 nit: can you add an empty comment line to separate
Robert Sesek 2016/04/25 17:47:45 Done.
23 # by shared library target. 92 # by shared library target.
24 template("framework_bundle") { 93 template("framework_bundle") {
25 _target_name = target_name 94 _target_name = target_name
26 _output_name = target_name 95 _output_name = target_name
27 if (defined(invoker.output_name)) { 96 if (defined(invoker.output_name)) {
28 _output_name = invoker.output_name 97 _output_name = invoker.output_name
29 } 98 }
30 99
31 # If the framework is unversionned, the final _target_name will be the 100 # If the framework is unversionned, the final _target_name will be the
32 # create_bundle(_framework_target), otherwise an action with the name 101 # create_bundle(_framework_target), otherwise an action with the name
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 public_deps = [ 142 public_deps = [
74 ":$_shared_library_target", 143 ":$_shared_library_target",
75 ] 144 ]
76 } 145 }
77 146
78 _framework_public_config = _target_name + "_public_config" 147 _framework_public_config = _target_name + "_public_config"
79 config(_framework_public_config) { 148 config(_framework_public_config) {
80 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs 149 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs
81 # and include_dirs to avoid duplicate values on the command-line. 150 # and include_dirs to avoid duplicate values on the command-line.
82 visibility = [ ":$_framework_target" ] 151 visibility = [ ":$_framework_target" ]
83 common_flags = [ "-F" + rebase_path("$root_out_dir/.", root_out_dir) ] 152 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 ] 153 lib_dirs = [ root_out_dir ]
88 libs = [ _framework_name ] 154 libs = [ _framework_name ]
89 } 155 }
90 156
91 create_bundle(_framework_target) { 157 create_bundle(_framework_target) {
92 forward_variables_from(invoker, 158 forward_variables_from(invoker,
93 [ 159 [
94 "data_deps", 160 "data_deps",
95 "deps", 161 "deps",
96 "public_deps", 162 "public_deps",
97 "testonly", 163 "testonly",
98 ]) 164 ])
99 165
100 if (defined(_framework_version)) { 166 if (defined(_framework_version)) {
101 visibility = [ ":$_target_name" ] 167 visibility = [ ":$_target_name" ]
102 } else { 168 } else {
103 forward_variables_from(invoker, [ "visibility" ]) 169 if (defined(invoker.visibility)) {
170 visibility = invoker.visibility
171 visibility += [ ":$_target_name+link" ]
172 }
104 } 173 }
105 174
106 if (!defined(public_deps)) { 175 if (!defined(public_deps)) {
107 public_deps = [] 176 public_deps = []
108 } 177 }
109 public_deps += [ ":$_shared_library_bundle_data" ] 178 public_deps += [ ":$_shared_library_bundle_data" ]
110 179
111 public_configs = [ ":$_framework_public_config" ]
112
113 bundle_root_dir = _framework_root_dir 180 bundle_root_dir = _framework_root_dir
114 bundle_resources_dir = "$bundle_root_dir/Resources" 181 bundle_resources_dir = "$bundle_root_dir/Resources"
115 bundle_executable_dir = "$bundle_root_dir" 182 bundle_executable_dir = "$bundle_root_dir"
116 } 183 }
117 184
118 if (defined(_framework_version)) { 185 if (defined(_framework_version)) {
119 action(_target_name) { 186 action(_target_name) {
120 forward_variables_from(invoker, 187 forward_variables_from(invoker, [ "testonly" ])
121 [ 188
122 "visibility", 189 if (defined(invoker.visibility)) {
123 "testonly", 190 visibility = invoker.visibility
124 ]) 191 visibility += [ ":$_target_name+link" ]
192 }
193
125 script = "$root_out_dir/gyp-mac-tool" 194 script = "$root_out_dir/gyp-mac-tool"
126 outputs = [ 195 outputs = [
127 "$root_out_dir/$_framework_name/Versions/Current", 196 "$root_out_dir/$_framework_name/Versions/Current",
128 ] 197 ]
129 args = [ 198 args = [
130 "package-framework", 199 "package-framework",
131 "$_framework_name", 200 "$_framework_name",
132 "$_framework_version", 201 "$_framework_version",
133 ] 202 ]
134 public_deps = [ 203 public_deps = [
135 ":$_framework_target", 204 ":$_framework_target",
136 ] 205 ]
137 } 206 }
138 } 207 }
208
209 group(_target_name + "+link") {
210 forward_variables_from(invoker,
211 [
212 "visibility",
213 "testonly",
214 ])
215 public_deps = [
216 ":$_target_name",
217 ]
218 public_configs = [ ":$_framework_public_config" ]
219 }
139 } 220 }
140 221
141 # Template to combile .xib or .storyboard files. 222 # Template to combile .xib or .storyboard files.
142 # 223 #
143 # 224 #
144 # Arguments 225 # Arguments
145 # 226 #
146 # sources: 227 # sources:
147 # list of string, sources to compile 228 # list of string, sources to compile
148 # 229 #
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 302 }
222 303
223 outputs = [ 304 outputs = [
224 "$_output_path/{{source_file_part}}", 305 "$_output_path/{{source_file_part}}",
225 ] 306 ]
226 } 307 }
227 } 308 }
228 309
229 # Template to package a shared library into a Mac framework bundle. 310 # Template to package a shared library into a Mac framework bundle.
230 # 311 #
312 # This template provides two targets to control whether the framework is
313 # merely built when targets depend on it, or whether it is linked as well:
314 # "$target_name" and "$target_name+link".
315 #
316 # See the //build/config/mac/rules.gni:framework_bundle for a discussion
317 # and examples.
318 #
231 # Arguments 319 # Arguments
232 # 320 #
233 # info_plist: 321 # info_plist:
234 # string, path to the Info.plist file that will be used for the bundle. 322 # string, path to the Info.plist file that will be used for the bundle.
235 # 323 #
236 # output_name: 324 # output_name:
237 # (optional) string, name of the generated framework without the 325 # (optional) string, name of the generated framework without the
238 # .framework suffix. If omitted, defaults to target_name. 326 # .framework suffix. If omitted, defaults to target_name.
239 # 327 #
240 # framework_version: 328 # framework_version:
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 ]) 503 ])
416 if (!defined(deps)) { 504 if (!defined(deps)) {
417 deps = [] 505 deps = []
418 } 506 }
419 deps += [ ":$_loadable_module_bundle_data" ] 507 deps += [ ":$_loadable_module_bundle_data" ]
420 508
421 bundle_root_dir = "$root_out_dir/$_target_name.plugin/Contents" 509 bundle_root_dir = "$root_out_dir/$_target_name.plugin/Contents"
422 bundle_executable_dir = "$bundle_root_dir/MacOS" 510 bundle_executable_dir = "$bundle_root_dir/MacOS"
423 } 511 }
424 } 512 }
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