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

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

Issue 2487763002: [Mac/GN] Re-do framework packaging to fix framework versioning. (Closed)
Patch Set: Created 4 years, 1 month 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
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/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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 # output_name: 136 # output_name:
137 # (optional) string, name of the generated framework without the 137 # (optional) string, name of the generated framework without the
138 # .framework suffix. If omitted, defaults to target_name. 138 # .framework suffix. If omitted, defaults to target_name.
139 # 139 #
140 # framework_version: 140 # framework_version:
141 # (optional) string, version of the framework. Typically this is a 141 # (optional) string, version of the framework. Typically this is a
142 # single letter, like "A". If omitted, the Versions/ subdirectory 142 # single letter, like "A". If omitted, the Versions/ subdirectory
143 # structure will not be created, and build output will go directly 143 # structure will not be created, and build output will go directly
144 # into the framework subdirectory. 144 # into the framework subdirectory.
145 # 145 #
146 # framework_contents:
147 # (optional) list of string, top-level items in the framework. For
148 # frameworks with a framework_version, this is the list of symlinks to
149 # create in the .framework directory that link into Versions/Current/.
150 #
146 # extra_substitutions: 151 # extra_substitutions:
147 # (optional) string array, 'key=value' pairs for extra fields which are 152 # (optional) string array, 'key=value' pairs for extra fields which are
148 # specified in a source Info.plist template. 153 # specified in a source Info.plist template.
149 # 154 #
150 # This template provides two targets for the resulting framework bundle. The 155 # 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 156 # link-time behavior varies depending on which of the two targets below is
152 # added as a dependency: 157 # added as a dependency:
153 # - $target_name only adds a build-time dependency. Targets that depend on 158 # - $target_name only adds a build-time dependency. Targets that depend on
154 # it will not link against the framework. 159 # it will not link against the framework.
155 # - $target_name+link adds a build-time and link-time dependency. Targets 160 # - $target_name+link adds a build-time and link-time dependency. Targets
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 # Note that the framework is still copied to the app's bundle, but dyld will 214 # 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" 215 # 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 216 # target as a dependency. This also requires that the framework set its
212 # install_name so that dyld can locate it. 217 # install_name so that dyld can locate it.
213 # 218 #
214 # See "gn help shared_library" for more information on arguments supported 219 # See "gn help shared_library" for more information on arguments supported
215 # by shared library target. 220 # by shared library target.
216 template("mac_framework_bundle") { 221 template("mac_framework_bundle") {
217 assert(defined(invoker.deps), 222 assert(defined(invoker.deps),
218 "Dependencies must be specified for $target_name") 223 "Dependencies must be specified for $target_name")
224 assert(!defined(invoker.framework_contents) ||
225 defined(invoker.framework_version),
226 "framework_contents requres a versioned framework")
219 227
220 _info_plist_target = target_name + "_info_plist" 228 _info_plist_target = target_name + "_info_plist"
221 229
222 mac_info_plist(_info_plist_target) { 230 mac_info_plist(_info_plist_target) {
223 executable_name = target_name 231 executable_name = target_name
224 if (defined(invoker.output_name)) { 232 if (defined(invoker.output_name)) {
225 executable_name = invoker.output_name 233 executable_name = invoker.output_name
226 } 234 }
227 forward_variables_from(invoker, 235 forward_variables_from(invoker,
228 [ 236 [
(...skipping 16 matching lines...) Expand all
245 ":$_info_plist_target", 253 ":$_info_plist_target",
246 ] 254 ]
247 } 255 }
248 256
249 _target_name = target_name 257 _target_name = target_name
250 _output_name = target_name 258 _output_name = target_name
251 if (defined(invoker.output_name)) { 259 if (defined(invoker.output_name)) {
252 _output_name = invoker.output_name 260 _output_name = invoker.output_name
253 } 261 }
254 262
255 # If the framework is unversioned, the final _target_name will be the 263 # Create a file to track the build dependency on the framework_version and
256 # create_bundle(_framework_target), otherwise an action with the name 264 # framework_contents variables.
257 # _target_name will depends on the the create_bundle() in order to prepare 265 _framework_toc = []
258 # the versioned directory structure. 266 if (defined(invoker.framework_version)) {
267 _framework_toc += [
268 "Version=" + invoker.framework_version,
269 _output_name,
270 ]
271 _framework_contents = [ _output_name ]
272 }
273 if (defined(invoker.framework_contents)) {
274 _framework_toc += invoker.framework_contents
275 _framework_contents += invoker.framework_contents
276 }
277 _framework_toc_file = "$target_out_dir/${target_name}.toc"
278 write_file(_framework_toc_file, _framework_toc)
279
280 # Create local variables for referencing different parts of the bundle.
259 _framework_target = _target_name 281 _framework_target = _target_name
260 _framework_name = _output_name + ".framework" 282 _framework_name = _output_name + ".framework"
261 _framework_base_dir = "$root_out_dir/$_framework_name" 283 _framework_base_dir = "$root_out_dir/$_framework_name"
262 if (defined(invoker.framework_version) && invoker.framework_version != "") { 284 if (defined(invoker.framework_version) && invoker.framework_version != "") {
263 _framework_version = invoker.framework_version 285 _framework_version = invoker.framework_version
264 _framework_root_dir = _framework_base_dir + "/Versions/$_framework_version" 286 _framework_root_dir = _framework_base_dir + "/Versions/$_framework_version"
265 _framework_target = _target_name + "_create_bundle"
266 } else { 287 } else {
267 _framework_root_dir = _framework_base_dir 288 _framework_root_dir = _framework_base_dir
268 } 289 }
269 290
291 # Clean the entire framework if the framework_version changes.
292 _version_arg = "''"
293 if (defined(invoker.framework_version)) {
294 _version_arg = _framework_version
295 }
296 _version_file = "$target_out_dir/${target_name}_version"
297 exec_script("//build/config/mac/prepare_framework_version.py",
298 [
299 rebase_path(_version_file),
300 rebase_path(_framework_base_dir),
301 _version_arg,
302 ])
303
304 # Create the symlinks.
305 _framework_package_target = target_name + "_package"
306 action(_framework_package_target) {
307 script = "//build/config/mac/package_framework.py"
308
309 inputs = [
310 _framework_toc_file,
Dirk Pranke 2016/11/08 21:41:10 I don't see where package_framework.py is actually
Robert Sesek 2016/11/08 21:55:33 Just the latter; we're only using it as an input d
311 ]
312
313 _stamp_file = "$target_out_dir/run_${_framework_package_target}.stamp"
314 outputs = [
315 _stamp_file,
316 ]
317
318 visibility = [ ":$_framework_target" ]
319
320 args = [
321 "--framework",
322 rebase_path(_framework_base_dir, root_build_dir),
323 "--stamp",
324 rebase_path(_stamp_file, root_build_dir),
325 ]
326
327 if (defined(invoker.framework_version)) {
328 outputs += [ "$_framework_base_dir/Versions/Current" ]
329 args += [
330 "--version",
331 invoker.framework_version,
332 "--contents",
333 ] + _framework_contents
334
335 # It is not possible to list _framework_contents as outputs, since
336 # ninja does not properly stat symbolic links. The exception is the
337 # "Current" symlink, since package_framework.py will ensure that
338 # directory exists so the resolved-symlink mtime will be up-to-date.
339 # https://github.com/ninja-build/ninja/issues/1186
340 }
341 }
342
270 _link_shared_library_target = target_name + "_shared_library" 343 _link_shared_library_target = target_name + "_shared_library"
271 _shared_library_bundle_data = target_name + "_shared_library_bundle_data" 344 _shared_library_bundle_data = target_name + "_shared_library_bundle_data"
272 345
273 shared_library(_link_shared_library_target) { 346 shared_library(_link_shared_library_target) {
274 forward_variables_from(invoker, 347 forward_variables_from(invoker,
275 "*", 348 "*",
276 [ 349 [
277 "assert_no_deps", 350 "assert_no_deps",
278 "bundle_deps", 351 "bundle_deps",
279 "code_signing_enabled", 352 "code_signing_enabled",
(...skipping 17 matching lines...) Expand all
297 "$target_out_dir/$_link_shared_library_target/$_output_name", 370 "$target_out_dir/$_link_shared_library_target/$_output_name",
298 ] 371 ]
299 outputs = [ 372 outputs = [
300 "{{bundle_executable_dir}}/$_output_name", 373 "{{bundle_executable_dir}}/$_output_name",
301 ] 374 ]
302 public_deps = [ 375 public_deps = [
303 ":$_link_shared_library_target", 376 ":$_link_shared_library_target",
304 ] 377 ]
305 } 378 }
306 379
307 # Clean the entire framework if the framework_version changes.
308 _version_arg = ""
309 if (defined(_framework_version)) {
310 _version_arg = _framework_version
311 }
312 _version_file = "$target_out_dir/${target_name}_version"
313 exec_script("//build/config/mac/prepare_framework_version.py",
314 [
315 rebase_path(_version_file),
316 rebase_path(_framework_base_dir),
317 "'$_version_arg'",
318 ])
319
320 _framework_public_config = _target_name + "_public_config" 380 _framework_public_config = _target_name + "_public_config"
321 config(_framework_public_config) { 381 config(_framework_public_config) {
322 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs 382 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs
323 # and include_dirs to avoid duplicate values on the command-line. 383 # and include_dirs to avoid duplicate values on the command-line.
324 visibility = [ ":$_framework_target" ] 384 visibility = [ ":$_framework_target" ]
325 ldflags = [ 385 ldflags = [
326 "-F", 386 "-F",
327 rebase_path("$root_out_dir/.", root_build_dir), 387 rebase_path("$root_out_dir/.", root_build_dir),
328 ] 388 ]
329 lib_dirs = [ root_out_dir ] 389 lib_dirs = [ root_out_dir ]
330 libs = [ _framework_name ] 390 libs = [ _framework_name ]
331 } 391 }
332 392
333 create_bundle(_framework_target) { 393 create_bundle(_framework_target) {
334 forward_variables_from(invoker, 394 forward_variables_from(invoker,
335 [ 395 [
336 "data_deps", 396 "data_deps",
337 "deps", 397 "deps",
338 "public_deps", 398 "public_deps",
339 "testonly", 399 "testonly",
340 ]) 400 ])
341 401
342 if (defined(_framework_version)) { 402 if (defined(invoker.visibility)) {
343 visibility = [ ":$_target_name" ] 403 visibility = invoker.visibility
344 } else { 404 visibility += [ ":$_target_name+link" ]
345 if (defined(invoker.visibility)) {
346 visibility = invoker.visibility
347 visibility += [ ":$_target_name+link" ]
348 }
349 } 405 }
350 406
351 if (!defined(deps)) { 407 if (!defined(deps)) {
352 deps = [] 408 deps = []
353 } 409 }
354 deps += [ ":$_info_plist_bundle_data" ] 410 deps += [ ":$_info_plist_bundle_data" ]
355 411
356 if (defined(invoker.bundle_deps)) { 412 if (defined(invoker.bundle_deps)) {
357 deps += invoker.bundle_deps 413 deps += invoker.bundle_deps
358 } 414 }
359 415
360 if (!defined(public_deps)) { 416 if (!defined(public_deps)) {
361 public_deps = [] 417 public_deps = []
362 } 418 }
363 public_deps += [ ":$_shared_library_bundle_data" ] 419 public_deps += [
420 ":$_framework_package_target",
421 ":$_shared_library_bundle_data",
422 ]
364 423
365 bundle_root_dir = _framework_root_dir 424 bundle_root_dir = _framework_root_dir
366 bundle_resources_dir = "$bundle_root_dir/Resources" 425 bundle_resources_dir = "$bundle_root_dir/Resources"
367 bundle_executable_dir = "$bundle_root_dir" 426 bundle_executable_dir = "$bundle_root_dir"
368 } 427 }
369 428
370 if (defined(_framework_version)) {
371 action(_target_name) {
372 forward_variables_from(invoker, [ "testonly" ])
373
374 if (defined(invoker.visibility)) {
375 visibility = invoker.visibility
376 visibility += [ ":$_target_name+link" ]
377 }
378
379 script = "//build/config/mac/package_framework.py"
380 outputs = [
381 "$root_out_dir/$_framework_name/Versions/Current",
382 ]
383 args = [
384 "$_framework_name",
385 "$_framework_version",
386 ]
387 public_deps = [
388 ":$_framework_target",
389 ]
390 }
391 }
392
393 group(_target_name + "+link") { 429 group(_target_name + "+link") {
394 forward_variables_from(invoker, 430 forward_variables_from(invoker,
395 [ 431 [
396 "public_configs", 432 "public_configs",
397 "testonly", 433 "testonly",
398 "visibility", 434 "visibility",
399 ]) 435 ])
400 public_deps = [ 436 public_deps = [
401 ":$_target_name", 437 ":$_target_name",
402 ] 438 ]
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 ]) 683 ])
648 if (!defined(deps)) { 684 if (!defined(deps)) {
649 deps = [] 685 deps = []
650 } 686 }
651 deps += [ ":$_loadable_module_bundle_data" ] 687 deps += [ ":$_loadable_module_bundle_data" ]
652 688
653 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents" 689 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents"
654 bundle_executable_dir = "$bundle_root_dir/MacOS" 690 bundle_executable_dir = "$bundle_root_dir/MacOS"
655 } 691 }
656 } 692 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698