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

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

Issue 2135323002: Add support for fat build to "ios_framework_bundle" target. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fat-build-enable
Patch Set: Rebase Created 4 years, 5 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') | components/cronet/ios/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 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 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 # This file contains rules that are shared between Mac and iOS. 5 # This file contains rules that are shared between Mac and iOS.
6 6
7 import("//build/toolchain/toolchain.gni") 7 import("//build/toolchain/toolchain.gni")
8 8
9 if (is_mac) { 9 if (is_mac) {
10 import("//build/config/mac/mac_sdk.gni") 10 import("//build/config/mac/mac_sdk.gni")
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 # 211 #
212 # See "gn help shared_library" for more information on arguments supported 212 # See "gn help shared_library" for more information on arguments supported
213 # by shared library target. 213 # by shared library target.
214 template("framework_bundle") { 214 template("framework_bundle") {
215 _target_name = target_name 215 _target_name = target_name
216 _output_name = target_name 216 _output_name = target_name
217 if (defined(invoker.output_name)) { 217 if (defined(invoker.output_name)) {
218 _output_name = invoker.output_name 218 _output_name = invoker.output_name
219 } 219 }
220 220
221 # If the framework is unversioned, the final _target_name will be the 221 _is_fat_build = is_ios && additional_toolchains != []
222 # create_bundle(_framework_target), otherwise an action with the name 222 if (_is_fat_build) {
223 # _target_name will depends on the the create_bundle() in order to prepare 223 _is_fat_build_main_target = current_toolchain == default_toolchain
224 # the versioned directory structure.
225 _framework_target = _target_name
226 _framework_name = _output_name + ".framework"
227 _framework_root_dir = "$root_out_dir/$_framework_name"
228 if (defined(invoker.framework_version) && invoker.framework_version != "") {
229 _framework_version = invoker.framework_version
230 _framework_root_dir += "/Versions/$_framework_version"
231 _framework_target = _target_name + "_create_bundle"
232 } 224 }
233 225
234 _shared_library_target = target_name + "_shared_library" 226 # The expansion of the template is different for fat and thin builds. For
235 _shared_library_bundle_data = _shared_library_target + "_bundle_data" 227 # thin build (and default toolchain of a fat build), the template expands
236 228 # to a "shared_library" target to create the bundle shared library and a
237 shared_library(_shared_library_target) { 229 # "create_bundle" target (the main target) to create the bundle structure.
238 visibility = [ ":$_shared_library_bundle_data" ] 230 #
239 forward_variables_from(invoker, 231 # For a fat build, the template just expands to the "shared_library" target
240 "*", 232 # for the non-default toolchain, while the final library is created using
241 [ 233 # "lipo" in the expansion of the template for the default toolchain.
242 "assert_no_deps", 234 #
243 "data_deps", 235 # The "$target_name+link" group for the non-default toolchain depends on the
244 "info_plist", 236 # target of the same name from the default toolchain as this is the target
245 "output_name", 237 # that defines the real framework bundle (it will support the current cpu
246 "visibility", 238 # as it is a fat framework).
247 ]) 239
248 output_name = _output_name 240 if (_is_fat_build && !_is_fat_build_main_target) {
249 output_prefix_override = true 241 shared_library(_target_name) {
250 output_extension = "" 242 forward_variables_from(invoker,
251 output_dir = "$target_out_dir/$_shared_library_target" 243 "*",
252 } 244 [
253 245 "assert_no_deps",
254 bundle_data(_shared_library_bundle_data) { 246 "data_deps",
255 visibility = [ ":$_framework_target" ] 247 "info_plist",
256 forward_variables_from(invoker, [ "testonly" ]) 248 "output_name",
257 sources = [ 249 ])
258 "$target_out_dir/$_shared_library_target/$_output_name", 250 if (defined(visibility)) {
259 ] 251 visibility += [ ":${_target_name}_shared_library($default_toolchain)" ]
260 outputs = [ 252 }
261 "{{bundle_executable_dir}}/$_output_name", 253 output_name = _output_name
262 ] 254 output_prefix_override = true
263 public_deps = [ 255 output_extension = ""
264 ":$_shared_library_target", 256 output_dir = "$target_out_dir/$_target_name"
265 ] 257 }
266 } 258
267 259 group(_target_name + "+link") {
268 _framework_public_config = _target_name + "_public_config" 260 forward_variables_from(invoker,
269 config(_framework_public_config) { 261 [
270 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs 262 "visibility",
271 # and include_dirs to avoid duplicate values on the command-line. 263 "testonly",
272 visibility = [ ":$_framework_target" ] 264 ])
273 ldflags = [ "-F" + rebase_path("$root_out_dir/.", root_build_dir) ] 265 public_deps = [
274 lib_dirs = [ root_out_dir ] 266 ":$_target_name($default_toolchain)",
275 libs = [ _framework_name ] 267 ]
276 } 268 }
277 269 } else {
278 create_bundle(_framework_target) { 270 # If the framework is unversioned, the final _target_name will be the
279 forward_variables_from(invoker, 271 # create_bundle(_framework_target), otherwise an action with the name
280 [ 272 # _target_name will depends on the the create_bundle() in order to prepare
281 "data_deps", 273 # the versioned directory structure.
282 "deps", 274 _framework_target = _target_name
283 "public_deps", 275 _framework_name = _output_name + ".framework"
284 "testonly", 276 _framework_root_dir = "$root_out_dir/$_framework_name"
285 ]) 277 if (defined(invoker.framework_version) && invoker.framework_version != "") {
278 _framework_version = invoker.framework_version
279 _framework_root_dir += "/Versions/$_framework_version"
280 _framework_target = _target_name + "_create_bundle"
281 }
282
283 _link_shared_library_target = target_name + "_shared_library"
284 _shared_library_bundle_data = target_name + "_shared_library_bundle_data"
285 _link_shared_library_visibility = [ ":$_shared_library_bundle_data" ]
286
287 if (_is_fat_build) {
288 _lipo_shared_library_target = _link_shared_library_target
289 _lipo_shared_library_visibility = _link_shared_library_visibility
290
291 _link_shared_library_visibility = []
292 _link_shared_library_visibility = [ ":$_lipo_shared_library_target" ]
293 _link_shared_library_target = target_name + "_arch_shared_library"
294 }
295
296 shared_library(_link_shared_library_target) {
297 forward_variables_from(invoker,
298 "*",
299 [
300 "assert_no_deps",
301 "data_deps",
302 "info_plist",
303 "output_name",
304 "visibility",
305 ])
306 visibility = _link_shared_library_visibility
307 output_name = _output_name
308 output_prefix_override = true
309 output_extension = ""
310 output_dir = "$target_out_dir/$_link_shared_library_target"
311 }
312
313 if (_is_fat_build) {
314 action(_lipo_shared_library_target) {
315 forward_variables_from(invoker, [ "testonly" ])
316 visibility = _lipo_shared_library_visibility
317 script = "//build/config/mac/xcrun.py"
318 outputs = [
319 "$target_out_dir/$_lipo_shared_library_target/$_output_name",
320 ]
321 inputs = [
322 "$target_out_dir/$_link_shared_library_target/$_output_name",
323 ]
324 deps = [
325 ":$_link_shared_library_target",
326 ]
327 foreach(_additional_toolchain, additional_toolchains) {
328 _additional_toolchain_target = "$_target_name($_additional_toolchain)"
329 deps += [ ":$_additional_toolchain_target" ]
330 inputs += [ get_label_info(_additional_toolchain_target,
331 "target_out_dir") + "/$_output_name" ]
332 }
333 args = [
334 "lipo",
335 "-create",
336 "-output",
337 rebase_path(outputs[0], root_build_dir),
338 ] + rebase_path(inputs, root_build_dir)
339 }
340 }
341
342 bundle_data(_shared_library_bundle_data) {
343 visibility = [ ":$_framework_target" ]
344 forward_variables_from(invoker, [ "testonly" ])
345 outputs = [
346 "{{bundle_executable_dir}}/$_output_name",
347 ]
348 if (_is_fat_build) {
349 sources = [
350 "$target_out_dir/$_lipo_shared_library_target/$_output_name",
351 ]
352 public_deps = [
353 ":$_lipo_shared_library_target",
354 ]
355 } else {
356 sources = [
357 "$target_out_dir/$_link_shared_library_target/$_output_name",
358 ]
359 public_deps = [
360 ":$_link_shared_library_target",
361 ]
362 }
363 }
364
365 _framework_public_config = _target_name + "_public_config"
366 config(_framework_public_config) {
367 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs
368 # and include_dirs to avoid duplicate values on the command-line.
369 visibility = [ ":$_framework_target" ]
370 ldflags = [ "-F" + rebase_path("$root_out_dir/.", root_build_dir) ]
371 lib_dirs = [ root_out_dir ]
372 libs = [ _framework_name ]
373 }
374
375 create_bundle(_framework_target) {
376 forward_variables_from(invoker,
377 [
378 "data_deps",
379 "deps",
380 "public_deps",
381 "testonly",
382 ])
383
384 if (defined(_framework_version)) {
385 visibility = [ ":$_target_name" ]
386 } else {
387 if (defined(invoker.visibility)) {
388 visibility = invoker.visibility
389 visibility += [ ":$_target_name+link" ]
390 }
391 }
392
393 if (!defined(public_deps)) {
394 public_deps = []
395 }
396 public_deps += [ ":$_shared_library_bundle_data" ]
397
398 bundle_root_dir = _framework_root_dir
399 bundle_resources_dir = "$bundle_root_dir/Resources"
400 bundle_executable_dir = "$bundle_root_dir"
401 }
286 402
287 if (defined(_framework_version)) { 403 if (defined(_framework_version)) {
288 visibility = [ ":$_target_name" ] 404 action(_target_name) {
289 } else { 405 forward_variables_from(invoker, [ "testonly" ])
290 if (defined(invoker.visibility)) { 406
291 visibility = invoker.visibility 407 if (defined(invoker.visibility)) {
292 visibility += [ ":$_target_name+link" ] 408 visibility = invoker.visibility
293 } 409 visibility += [ ":$_target_name+link" ]
294 } 410 }
295 411
296 if (!defined(public_deps)) { 412 script = "//build/config/mac/package_framework.py"
297 public_deps = [] 413 outputs = [
298 } 414 "$root_out_dir/$_framework_name/Versions/Current",
299 public_deps += [ ":$_shared_library_bundle_data" ] 415 ]
300 416 args = [
301 bundle_root_dir = _framework_root_dir 417 "$_framework_name",
302 bundle_resources_dir = "$bundle_root_dir/Resources" 418 "$_framework_version",
303 bundle_executable_dir = "$bundle_root_dir" 419 ]
304 } 420 public_deps = [
305 421 ":$_framework_target",
306 if (defined(_framework_version)) { 422 ]
307 action(_target_name) { 423 }
308 forward_variables_from(invoker, [ "testonly" ]) 424 }
309 425
310 if (defined(invoker.visibility)) { 426 group(_target_name + "+link") {
311 visibility = invoker.visibility 427 forward_variables_from(invoker,
312 visibility += [ ":$_target_name+link" ] 428 [
313 } 429 "visibility",
314 430 "testonly",
315 script = "//build/config/mac/package_framework.py" 431 ])
316 outputs = [ 432 public_deps = [
317 "$root_out_dir/$_framework_name/Versions/Current", 433 ":$_target_name",
318 ] 434 ]
319 args = [ 435 public_configs = [ ":$_framework_public_config" ]
320 "$_framework_name", 436 }
321 "$_framework_version",
322 ]
323 public_deps = [
324 ":$_framework_target",
325 ]
326 }
327 }
328
329 group(_target_name + "+link") {
330 forward_variables_from(invoker,
331 [
332 "visibility",
333 "testonly",
334 ])
335 public_deps = [
336 ":$_target_name",
337 ]
338 public_configs = [ ":$_framework_public_config" ]
339 } 437 }
340 } 438 }
341 439
342 # Template to combile .xib or .storyboard files. 440 # Template to combile .xib or .storyboard files.
343 # 441 #
344 # Arguments 442 # Arguments
345 # 443 #
346 # sources: 444 # sources:
347 # list of string, sources to compile 445 # list of string, sources to compile
348 # 446 #
(...skipping 21 matching lines...) Expand all
370 ] 468 ]
371 args = 469 args =
372 [ 470 [
373 "--input", 471 "--input",
374 "{{source}}", 472 "{{source}}",
375 "--output", 473 "--output",
376 rebase_path("$target_gen_dir/$target_name/{{source_name_part}}.nib"), 474 rebase_path("$target_gen_dir/$target_name/{{source_name_part}}.nib"),
377 ] + ibtool_flags 475 ] + ibtool_flags
378 } 476 }
379 } 477 }
OLDNEW
« no previous file with comments | « build/config/ios/rules.gni ('k') | components/cronet/ios/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698