OLD | NEW |
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/config/mac/base_rules.gni") | 5 import("//build/config/mac/base_rules.gni") |
6 | 6 |
7 # Generates Info.plist files for Mac apps and frameworks. | 7 # Generates Info.plist files for Mac apps and frameworks. |
8 # | 8 # |
9 # Arguments | 9 # Arguments |
10 # | 10 # |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 109 } |
110 | 110 |
111 outputs = [ | 111 outputs = [ |
112 "$_output_path/{{source_file_part}}", | 112 "$_output_path/{{source_file_part}}", |
113 ] | 113 ] |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 # Template to package a shared library into a Mac framework bundle. | 117 # Template to package a shared library into a Mac framework bundle. |
118 # | 118 # |
119 # This template provides two targets to control whether the framework is | 119 # By default, the bundle target this template generates does not link the |
120 # merely built when targets depend on it, or whether it is linked as well: | 120 # resulting framework into anything that depends on it. If a dependency wants |
121 # "$target_name" and "$target_name+link". | 121 # a link-time (as well as build-time) dependency on the framework bundle, |
122 # | 122 # depend against "$target_name+link". If only the build-time dependency is |
123 # See the //build/config/mac/base_rules.gni:framework_bundle for a discussion | 123 # required (e.g., for copying into another bundle), then use "$target_name". |
124 # and examples. | |
125 # | 124 # |
126 # Arguments | 125 # Arguments |
127 # | 126 # |
128 # info_plist: | 127 # info_plist: |
129 # (optional) string, path to the Info.plist file that will be used for | 128 # (optional) string, path to the Info.plist file that will be used for |
130 # the bundle. | 129 # the bundle. |
131 # | 130 # |
132 # info_plist_target: | 131 # info_plist_target: |
133 # (optional) string, if the info_plist is generated from an action, | 132 # (optional) string, if the info_plist is generated from an action, |
134 # rather than a regular source file, specify the target name in lieu | 133 # rather than a regular source file, specify the target name in lieu |
135 # of info_plist. The two arguments are mutually exclusive. | 134 # of info_plist. The two arguments are mutually exclusive. |
136 # | 135 # |
137 # output_name: | 136 # output_name: |
138 # (optional) string, name of the generated framework without the | 137 # (optional) string, name of the generated framework without the |
139 # .framework suffix. If omitted, defaults to target_name. | 138 # .framework suffix. If omitted, defaults to target_name. |
140 # | 139 # |
141 # framework_version: | 140 # framework_version: |
142 # (optional) string, version of the framework. Typically this is a | 141 # (optional) string, version of the framework. Typically this is a |
143 # single letter, like "A". If omitted, the Versions/ subdirectory | 142 # single letter, like "A". If omitted, the Versions/ subdirectory |
144 # structure will not be created, and build output will go directly | 143 # structure will not be created, and build output will go directly |
145 # into the framework subdirectory. | 144 # into the framework subdirectory. |
146 # | 145 # |
147 # extra_substitutions: | 146 # extra_substitutions: |
148 # (optional) string array, 'key=value' pairs for extra fields which are | 147 # (optional) string array, 'key=value' pairs for extra fields which are |
149 # specified in a source Info.plist template. | 148 # specified in a source Info.plist template. |
150 # | 149 # |
| 150 # This template provides two targets for the resulting framework bundle. The |
| 151 # link-time behavior varies depending on which of the two targets below is |
| 152 # added as a dependency: |
| 153 # - $target_name only adds a build-time dependency. Targets that depend on |
| 154 # it will not link against the framework. |
| 155 # - $target_name+link adds a build-time and link-time dependency. Targets |
| 156 # that depend on it will link against the framework. |
| 157 # |
| 158 # The build-time-only dependency is used for when a target needs to use the |
| 159 # framework either only for resources, or because the target loads it at run- |
| 160 # time, via dlopen() or NSBundle. The link-time dependency will cause the |
| 161 # dependee to have the framework loaded by dyld at launch. |
| 162 # |
| 163 # Example of build-time only dependency: |
| 164 # |
| 165 # mac_framework_bundle("CoreTeleportation") { |
| 166 # sources = [ ... ] |
| 167 # } |
| 168 # |
| 169 # bundle_data("core_teleportation_bundle_data") { |
| 170 # deps = [ ":CoreTeleportation" ] |
| 171 # sources = [ "$root_out_dir/CoreTeleportation.framework" ] |
| 172 # outputs = [ "{{bundle_root_dir}}/Frameworks/{{source_file_part}}" ] |
| 173 # } |
| 174 # |
| 175 # app_bundle("GoatTeleporter") { |
| 176 # sources = [ ... ] |
| 177 # deps = [ |
| 178 # ":core_teleportation_bundle_data", |
| 179 # ] |
| 180 # } |
| 181 # |
| 182 # The GoatTeleporter.app will not directly link against |
| 183 # CoreTeleportation.framework, but it will be included in the bundle's |
| 184 # Frameworks directory. |
| 185 # |
| 186 # Example of link-time dependency: |
| 187 # |
| 188 # mac_framework_bundle("CoreTeleportation") { |
| 189 # sources = [ ... ] |
| 190 # ldflags = [ |
| 191 # "-install_name", |
| 192 # "@executable_path/../Frameworks/$target_name.framework" |
| 193 # ] |
| 194 # } |
| 195 # |
| 196 # bundle_data("core_teleportation_bundle_data") { |
| 197 # deps = [ ":CoreTeleportation+link" ] |
| 198 # sources = [ "$root_out_dir/CoreTeleportation.framework" ] |
| 199 # outputs = [ "{{bundle_root_dir}}/Frameworks/{{source_file_part}}" ] |
| 200 # } |
| 201 # |
| 202 # app_bundle("GoatTeleporter") { |
| 203 # sources = [ ... ] |
| 204 # deps = [ |
| 205 # ":core_teleportation_bundle_data", |
| 206 # ] |
| 207 # } |
| 208 # |
| 209 # Note that the framework is still copied to the app's bundle, but dyld will |
| 210 # load this library when the app is launched because it uses the "+link" |
| 211 # target as a dependency. This also requires that the framework set its |
| 212 # install_name so that dyld can locate it. |
| 213 # |
151 # See "gn help shared_library" for more information on arguments supported | 214 # See "gn help shared_library" for more information on arguments supported |
152 # by shared library target. | 215 # by shared library target. |
153 template("mac_framework_bundle") { | 216 template("mac_framework_bundle") { |
154 assert(defined(invoker.deps), | 217 assert(defined(invoker.deps), |
155 "Dependencies must be specified for $target_name") | 218 "Dependencies must be specified for $target_name") |
156 | 219 |
157 _info_plist_target = target_name + "_info_plist" | 220 _info_plist_target = target_name + "_info_plist" |
158 | 221 |
159 mac_info_plist(_info_plist_target) { | 222 mac_info_plist(_info_plist_target) { |
160 executable_name = target_name | 223 executable_name = target_name |
(...skipping 15 matching lines...) Expand all Loading... |
176 forward_variables_from(invoker, [ "testonly" ]) | 239 forward_variables_from(invoker, [ "testonly" ]) |
177 sources = get_target_outputs(":$_info_plist_target") | 240 sources = get_target_outputs(":$_info_plist_target") |
178 outputs = [ | 241 outputs = [ |
179 "{{bundle_resources_dir}}/Info.plist", | 242 "{{bundle_resources_dir}}/Info.plist", |
180 ] | 243 ] |
181 public_deps = [ | 244 public_deps = [ |
182 ":$_info_plist_target", | 245 ":$_info_plist_target", |
183 ] | 246 ] |
184 } | 247 } |
185 | 248 |
186 framework_bundle(target_name) { | 249 _target_name = target_name |
187 forward_variables_from(invoker, "*", [ "info_plist" ]) | 250 _output_name = target_name |
| 251 if (defined(invoker.output_name)) { |
| 252 _output_name = invoker.output_name |
| 253 } |
| 254 |
| 255 # If the framework is unversioned, the final _target_name will be the |
| 256 # create_bundle(_framework_target), otherwise an action with the name |
| 257 # _target_name will depends on the the create_bundle() in order to prepare |
| 258 # the versioned directory structure. |
| 259 _framework_target = _target_name |
| 260 _framework_name = _output_name + ".framework" |
| 261 _framework_root_dir = "$root_out_dir/$_framework_name" |
| 262 if (defined(invoker.framework_version) && invoker.framework_version != "") { |
| 263 _framework_version = invoker.framework_version |
| 264 _framework_root_dir += "/Versions/$_framework_version" |
| 265 _framework_target = _target_name + "_create_bundle" |
| 266 } |
| 267 |
| 268 _link_shared_library_target = target_name + "_shared_library" |
| 269 _shared_library_bundle_data = target_name + "_shared_library_bundle_data" |
| 270 |
| 271 shared_library(_link_shared_library_target) { |
| 272 forward_variables_from(invoker, |
| 273 "*", |
| 274 [ |
| 275 "assert_no_deps", |
| 276 "bundle_deps", |
| 277 "code_signing_enabled", |
| 278 "data_deps", |
| 279 "info_plist", |
| 280 "info_plist_target", |
| 281 "output_name", |
| 282 "visibility", |
| 283 ]) |
| 284 visibility = [ ":$_shared_library_bundle_data" ] |
| 285 output_name = _output_name |
| 286 output_prefix_override = true |
| 287 output_extension = "" |
| 288 output_dir = "$target_out_dir/$_link_shared_library_target" |
| 289 } |
| 290 |
| 291 bundle_data(_shared_library_bundle_data) { |
| 292 visibility = [ ":$_framework_target" ] |
| 293 forward_variables_from(invoker, [ "testonly" ]) |
| 294 sources = [ |
| 295 "$target_out_dir/$_link_shared_library_target/$_output_name", |
| 296 ] |
| 297 outputs = [ |
| 298 "{{bundle_executable_dir}}/$_output_name", |
| 299 ] |
| 300 public_deps = [ |
| 301 ":$_link_shared_library_target", |
| 302 ] |
| 303 } |
| 304 |
| 305 _framework_public_config = _target_name + "_public_config" |
| 306 config(_framework_public_config) { |
| 307 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs |
| 308 # and include_dirs to avoid duplicate values on the command-line. |
| 309 visibility = [ ":$_framework_target" ] |
| 310 ldflags = [ |
| 311 "-F", |
| 312 rebase_path("$root_out_dir/.", root_build_dir), |
| 313 ] |
| 314 lib_dirs = [ root_out_dir ] |
| 315 libs = [ _framework_name ] |
| 316 } |
| 317 |
| 318 create_bundle(_framework_target) { |
| 319 forward_variables_from(invoker, |
| 320 [ |
| 321 "data_deps", |
| 322 "deps", |
| 323 "public_deps", |
| 324 "testonly", |
| 325 ]) |
| 326 |
| 327 if (defined(_framework_version)) { |
| 328 visibility = [ ":$_target_name" ] |
| 329 } else { |
| 330 if (defined(invoker.visibility)) { |
| 331 visibility = invoker.visibility |
| 332 visibility += [ ":$_target_name+link" ] |
| 333 } |
| 334 } |
188 | 335 |
189 if (!defined(deps)) { | 336 if (!defined(deps)) { |
190 deps = [] | 337 deps = [] |
191 } | 338 } |
192 deps += [ ":$_info_plist_bundle_data" ] | 339 deps += [ ":$_info_plist_bundle_data" ] |
| 340 |
| 341 if (defined(invoker.bundle_deps)) { |
| 342 deps += invoker.bundle_deps |
| 343 } |
| 344 |
| 345 if (!defined(public_deps)) { |
| 346 public_deps = [] |
| 347 } |
| 348 public_deps += [ ":$_shared_library_bundle_data" ] |
| 349 |
| 350 bundle_root_dir = _framework_root_dir |
| 351 bundle_resources_dir = "$bundle_root_dir/Resources" |
| 352 bundle_executable_dir = "$bundle_root_dir" |
| 353 } |
| 354 |
| 355 if (defined(_framework_version)) { |
| 356 action(_target_name) { |
| 357 forward_variables_from(invoker, [ "testonly" ]) |
| 358 |
| 359 if (defined(invoker.visibility)) { |
| 360 visibility = invoker.visibility |
| 361 visibility += [ ":$_target_name+link" ] |
| 362 } |
| 363 |
| 364 script = "//build/config/mac/package_framework.py" |
| 365 outputs = [ |
| 366 "$root_out_dir/$_framework_name/Versions/Current", |
| 367 ] |
| 368 args = [ |
| 369 "$_framework_name", |
| 370 "$_framework_version", |
| 371 ] |
| 372 public_deps = [ |
| 373 ":$_framework_target", |
| 374 ] |
| 375 } |
| 376 } |
| 377 |
| 378 group(_target_name + "+link") { |
| 379 forward_variables_from(invoker, |
| 380 [ |
| 381 "public_configs", |
| 382 "testonly", |
| 383 "visibility", |
| 384 ]) |
| 385 public_deps = [ |
| 386 ":$_target_name", |
| 387 ] |
| 388 if (!defined(public_configs)) { |
| 389 public_configs = [] |
| 390 } |
| 391 public_configs += [ ":$_framework_public_config" ] |
193 } | 392 } |
194 } | 393 } |
195 | 394 |
196 set_defaults("mac_framework_bundle") { | 395 set_defaults("mac_framework_bundle") { |
197 configs = default_shared_library_configs | 396 configs = default_shared_library_configs |
198 } | 397 } |
199 | 398 |
200 # Template to create a Mac executable application bundle. | 399 # Template to create a Mac executable application bundle. |
201 # | 400 # |
202 # Arguments | 401 # Arguments |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 ]) | 603 ]) |
405 if (!defined(deps)) { | 604 if (!defined(deps)) { |
406 deps = [] | 605 deps = [] |
407 } | 606 } |
408 deps += [ ":$_loadable_module_bundle_data" ] | 607 deps += [ ":$_loadable_module_bundle_data" ] |
409 | 608 |
410 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents" | 609 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents" |
411 bundle_executable_dir = "$bundle_root_dir/MacOS" | 610 bundle_executable_dir = "$bundle_root_dir/MacOS" |
412 } | 611 } |
413 } | 612 } |
OLD | NEW |