OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "tools/gn/functions.h" | 5 #include "tools/gn/functions.h" |
6 | 6 |
7 #include "tools/gn/config_values_generator.h" | 7 #include "tools/gn/config_values_generator.h" |
8 #include "tools/gn/err.h" | 8 #include "tools/gn/err.h" |
9 #include "tools/gn/parse_tree.h" | 9 #include "tools/gn/parse_tree.h" |
10 #include "tools/gn/scope.h" | 10 #include "tools/gn/scope.h" |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 " This target can be used on all platforms though it is designed only to\n" | 327 " This target can be used on all platforms though it is designed only to\n" |
328 " generate iOS/OS X bundle. In cross-platform projects, it is advised to\n" | 328 " generate iOS/OS X bundle. In cross-platform projects, it is advised to\n" |
329 " put it behind iOS/Mac conditionals.\n" | 329 " put it behind iOS/Mac conditionals.\n" |
330 "\n" | 330 "\n" |
331 " If a create_bundle is specified as a data_deps for another target, the\n" | 331 " If a create_bundle is specified as a data_deps for another target, the\n" |
332 " bundle is considered a leaf, and its public and private dependencies\n" | 332 " bundle is considered a leaf, and its public and private dependencies\n" |
333 " will not contribute to any data or data_deps. Required runtime\n" | 333 " will not contribute to any data or data_deps. Required runtime\n" |
334 " dependencies should be placed in the bundle. A create_bundle can\n" | 334 " dependencies should be placed in the bundle. A create_bundle can\n" |
335 " declare its own explicit data and data_deps, however.\n" | 335 " declare its own explicit data and data_deps, however.\n" |
336 "\n" | 336 "\n" |
| 337 "Code signing\n" |
| 338 "\n" |
| 339 " Some bundle needs to be code signed as part of the build (on iOS all\n" |
| 340 " application needs to be code signed to run on a device). The code\n" |
| 341 " signature can be configured via the code_signing_script variable.\n" |
| 342 "\n" |
| 343 " If set, code_signing_script is the path of a script that invoked after\n" |
| 344 " all files have been moved into the bundle. The script must not change\n" |
| 345 " any file in the bundle, but may add new files.\n" |
| 346 "\n" |
| 347 " If code_signing_script is defined, then code_signing_outputs must also\n" |
| 348 " be defined and non-empty to inform when the script needs to be re-run.\n" |
| 349 " The code_signing_args will be passed as is to the script (so path have\n" |
| 350 " to be rebased) and additional inputs may be listed with the variable\n" |
| 351 " code_signing_sources.\n" |
| 352 "\n" |
337 "Variables\n" | 353 "Variables\n" |
338 "\n" | 354 "\n" |
339 " bundle_root_dir*, bundle_resources_dir*, bundle_executable_dir*,\n" | 355 " bundle_root_dir*, bundle_resources_dir*, bundle_executable_dir*,\n" |
340 " bundle_plugins_dir*, deps, data_deps, public_deps, visibility,\n" | 356 " bundle_plugins_dir*, deps, data_deps, public_deps, visibility,\n" |
341 " product_type\n" | 357 " product_type, code_signing_args, code_signing_script,\n" |
| 358 " code_signing_sources, code_signing_outputs\n" |
342 " * = required\n" | 359 " * = required\n" |
343 "\n" | 360 "\n" |
344 "Example\n" | 361 "Example\n" |
345 "\n" | 362 "\n" |
346 " # Defines a template to create an application. On most platform, this\n" | 363 " # Defines a template to create an application. On most platform, this\n" |
347 " # is just an alias for an \"executable\" target, but on iOS/OS X, it\n" | 364 " # is just an alias for an \"executable\" target, but on iOS/OS X, it\n" |
348 " # builds an application bundle.\n" | 365 " # builds an application bundle.\n" |
349 " template(\"app\") {\n" | 366 " template(\"app\") {\n" |
350 " if (!is_ios && !is_mac) {\n" | 367 " if (!is_ios && !is_mac) {\n" |
351 " executable(target_name) {\n" | 368 " executable(target_name) {\n" |
(...skipping 12 matching lines...) Expand all Loading... |
364 " }\n" | 381 " }\n" |
365 "\n" | 382 "\n" |
366 " bundle_data(\"${app_name}_bundle_info_plist\") {\n" | 383 " bundle_data(\"${app_name}_bundle_info_plist\") {\n" |
367 " deps = [ \":${app_name}_generate_info_plist\" ]\n" | 384 " deps = [ \":${app_name}_generate_info_plist\" ]\n" |
368 " sources = [ \"$gen_path/Info.plist\" ]\n" | 385 " sources = [ \"$gen_path/Info.plist\" ]\n" |
369 " outputs = [ \"{{bundle_root_dir}}/Info.plist\" ]\n" | 386 " outputs = [ \"{{bundle_root_dir}}/Info.plist\" ]\n" |
370 " }\n" | 387 " }\n" |
371 "\n" | 388 "\n" |
372 " executable(\"${app_name}_generate_executable\") {\n" | 389 " executable(\"${app_name}_generate_executable\") {\n" |
373 " forward_variables_from(invoker, \"*\", [\n" | 390 " forward_variables_from(invoker, \"*\", [\n" |
374 " \"output_name\",\n" | 391 " \"output_name\",\n" |
375 " \"visibility\",\n" | 392 " \"visibility\",\n" |
376 " ])\n" | 393 " ])\n" |
377 " output_name =\n" | 394 " output_name =\n" |
378 " rebase_path(\"$gen_path/$app_name\", root_build_dir)\n" | 395 " rebase_path(\"$gen_path/$app_name\", root_build_dir)\n" |
379 " }\n" | 396 " }\n" |
380 "\n" | 397 "\n" |
381 " bundle_data(\"${app_name}_bundle_executable\") {\n" | 398 " code_signing =\n" |
382 " deps = [ \":${app_name}_generate_executable\" ]\n" | 399 " defined(invoker.code_signing) && invoker.code_signing\n" |
383 " sources = [ \"$gen_path/$app_name\" ]\n" | 400 "\n" |
384 " outputs = [ \"{{bundle_executable_dir}}/$app_name\" ]\n" | 401 " if (is_ios && !code_signing) {\n" |
| 402 " bundle_data(\"${app_name}_bundle_executable\") {\n" |
| 403 " deps = [ \":${app_name}_generate_executable\" ]\n" |
| 404 " sources = [ \"$gen_path/$app_name\" ]\n" |
| 405 " outputs = [ \"{{bundle_executable_dir}}/$app_name\" ]\n" |
| 406 " }\n" |
385 " }\n" | 407 " }\n" |
386 "\n" | 408 "\n" |
387 " create_bundle(\"${app_name}.app\") {\n" | 409 " create_bundle(\"${app_name}.app\") {\n" |
388 " product_type = \"com.apple.product-type.application\"\n" | 410 " product_type = \"com.apple.product-type.application\"\n" |
389 " deps = [\n" | |
390 " \":${app_name}_bundle_executable\",\n" | |
391 " \":${app_name}_bundle_info_plist\",\n" | |
392 " ]\n" | |
393 " if (is_ios) {\n" | 411 " if (is_ios) {\n" |
394 " bundle_root_dir = \"${root_build_dir}/$target_name\"\n" | 412 " bundle_root_dir = \"${root_build_dir}/$target_name\"\n" |
395 " bundle_resources_dir = bundle_root_dir\n" | 413 " bundle_resources_dir = bundle_root_dir\n" |
396 " bundle_executable_dir = bundle_root_dir\n" | 414 " bundle_executable_dir = bundle_root_dir\n" |
397 " bundle_plugins_dir = bundle_root_dir + \"/Plugins\"\n" | 415 " bundle_plugins_dir = bundle_root_dir + \"/Plugins\"\n" |
398 " } else {\n" | 416 " } else {\n" |
399 " bundle_root_dir = \"${root_build_dir}/target_name/Contents\"\n" | 417 " bundle_root_dir = \"${root_build_dir}/target_name/Contents\"\n" |
400 " bundle_resources_dir = bundle_root_dir + \"/Resources\"\n" | 418 " bundle_resources_dir = bundle_root_dir + \"/Resources\"\n" |
401 " bundle_executable_dir = bundle_root_dir + \"/MacOS\"\n" | 419 " bundle_executable_dir = bundle_root_dir + \"/MacOS\"\n" |
402 " bundle_plugins_dir = bundle_root_dir + \"/Plugins\"\n" | 420 " bundle_plugins_dir = bundle_root_dir + \"/Plugins\"\n" |
403 " }\n" | 421 " }\n" |
404 " }\n" | 422 " deps = [ \":${app_name}_bundle_info_plist\" ]\n" |
405 "\n" | 423 " if (is_ios && code_signing) {\n" |
406 " group(target_name) {\n" | 424 " deps += [ \":${app_name}_generate_executable\" ]\n" |
407 " forward_variables_from(invoker, [\"visibility\"])\n" | 425 " code_signing_script = \"//build/config/ios/codesign.py\"\n" |
408 " deps = [ \":${app_name}.app\" ]\n" | 426 " code_signing_sources = [\n" |
| 427 " invoker.entitlements_path,\n" |
| 428 " \"$target_gen_dir/$app_name\",\n" |
| 429 " ]\n" |
| 430 " code_signing_outputs = [\n" |
| 431 " \"$bundle_root_dir/$app_name\",\n" |
| 432 " \"$bundle_root_dir/_CodeSignature/CodeResources\",\n" |
| 433 " \"$bundle_root_dir/embedded.mobileprovision\",\n" |
| 434 " \"$target_gen_dir/$app_name.xcent\",\n" |
| 435 " ]\n" |
| 436 " code_signing_args = [\n" |
| 437 " \"-i=\" + ios_code_signing_identity,\n" |
| 438 " \"-b=\" + rebase_path(\n" |
| 439 " \"$target_gen_dir/$app_name\", root_build_dir),\n" |
| 440 " \"-e=\" + rebase_path(\n" |
| 441 " invoker.entitlements_path, root_build_dir),\n" |
| 442 " \"-e=\" + rebase_path(\n" |
| 443 " \"$target_gen_dir/$app_name.xcent\", root_build_dir),\n" |
| 444 " rebase_path(bundle_root_dir, root_build_dir),\n" |
| 445 " ]\n" |
| 446 " } else {\n" |
| 447 " deps += [ \":${app_name}_bundle_executable\" ]\n" |
| 448 " }\n" |
409 " }\n" | 449 " }\n" |
410 " }\n" | 450 " }\n" |
411 " }\n"; | 451 " }\n"; |
412 | 452 |
413 Value RunCreateBundle(Scope* scope, | 453 Value RunCreateBundle(Scope* scope, |
414 const FunctionCallNode* function, | 454 const FunctionCallNode* function, |
415 const std::vector<Value>& args, | 455 const std::vector<Value>& args, |
416 BlockNode* block, | 456 BlockNode* block, |
417 Err* err) { | 457 Err* err) { |
418 return ExecuteGenericTarget(functions::kCreateBundle, scope, function, args, | 458 return ExecuteGenericTarget(functions::kCreateBundle, scope, function, args, |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 const Template* templ = scope->GetTemplate(target_type); | 774 const Template* templ = scope->GetTemplate(target_type); |
735 if (templ) | 775 if (templ) |
736 return templ->Invoke(scope, function, sub_args, block, err); | 776 return templ->Invoke(scope, function, sub_args, block, err); |
737 | 777 |
738 // Otherwise, assume the target is a built-in target type. | 778 // Otherwise, assume the target is a built-in target type. |
739 return ExecuteGenericTarget(target_type.c_str(), scope, function, sub_args, | 779 return ExecuteGenericTarget(target_type.c_str(), scope, function, sub_args, |
740 block, err); | 780 block, err); |
741 } | 781 } |
742 | 782 |
743 } // namespace functions | 783 } // namespace functions |
OLD | NEW |