rules.gni 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import("//build/config/mac/mac_sdk.gni")
  2. # Template to compile .xib and .storyboard files.
  3. # (copied from src/build/config/ios/rules.gni)
  4. #
  5. # Arguments
  6. #
  7. # sources:
  8. # list of string, sources to compile
  9. #
  10. # ibtool_flags:
  11. # (optional) list of string, additional flags to pass to the ibtool
  12. template("compile_ib_files") {
  13. action_foreach(target_name) {
  14. forward_variables_from(invoker,
  15. [
  16. "testonly",
  17. "visibility",
  18. ])
  19. assert(defined(invoker.sources),
  20. "sources must be specified for $target_name")
  21. assert(defined(invoker.output_extension),
  22. "output_extension must be specified for $target_name")
  23. ibtool_flags = []
  24. if (defined(invoker.ibtool_flags)) {
  25. ibtool_flags = invoker.ibtool_flags
  26. }
  27. _output_extension = invoker.output_extension
  28. script = "//build/config/ios/compile_ib_files.py"
  29. sources = invoker.sources
  30. outputs = [
  31. "$target_gen_dir/$target_name/{{source_name_part}}.$_output_extension",
  32. ]
  33. args = [
  34. "--input",
  35. "{{source}}",
  36. "--output",
  37. rebase_path(
  38. "$target_gen_dir/$target_name/{{source_name_part}}.$_output_extension",
  39. root_build_dir),
  40. ]
  41. args += ibtool_flags
  42. }
  43. }
  44. # Template is copied here from Chromium but was removed in
  45. # https://chromium-review.googlesource.com/c/chromium/src/+/1637981
  46. # Template to compile and package Mac XIB files as bundle data.
  47. # Arguments
  48. # sources:
  49. # list of string, sources to comiple
  50. # output_path:
  51. # (optional) string, the path to use for the outputs list in the
  52. # bundle_data step. If unspecified, defaults to bundle_resources_dir.
  53. template("mac_xib_bundle_data") {
  54. _target_name = target_name
  55. _compile_target_name = _target_name + "_compile_ibtool"
  56. compile_ib_files(_compile_target_name) {
  57. forward_variables_from(invoker, [ "testonly" ])
  58. visibility = [ ":$_target_name" ]
  59. sources = invoker.sources
  60. output_extension = "nib"
  61. ibtool_flags = [
  62. "--minimum-deployment-target",
  63. mac_deployment_target,
  64. # TODO(rsesek): Enable this once all the bots are on Xcode 7+.
  65. # "--target-device",
  66. # "mac",
  67. ]
  68. }
  69. bundle_data(_target_name) {
  70. forward_variables_from(invoker,
  71. [
  72. "testonly",
  73. "visibility",
  74. ])
  75. public_deps = [ ":$_compile_target_name" ]
  76. sources = get_target_outputs(":$_compile_target_name")
  77. _output_path = "{{bundle_resources_dir}}"
  78. if (defined(invoker.output_path)) {
  79. _output_path = invoker.output_path
  80. }
  81. outputs = [ "$_output_path/{{source_file_part}}" ]
  82. }
  83. }