tweak_info_plist.gni 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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
  3. # found in the LICENSE file.
  4. import("//build/util/lastchange.gni")
  5. # Template to run the tweak_info_plist.py script on a plist.
  6. #
  7. # Arguments:
  8. #
  9. # info_plist:
  10. # (optional), string, the plist to tweak.
  11. #
  12. # info_plists:
  13. # (optional), list of string, the plist files to merge and tweak.
  14. #
  15. # args:
  16. # (optional), list of string, the arguments to pass to the
  17. # tweak_info_plist.py script.
  18. #
  19. # Callers should use get_target_outputs() to get the output name. One of
  20. # info_plist or info_plists must be specified.
  21. template("tweak_info_plist") {
  22. _output_name = "$target_gen_dir/${target_name}_tweaked.plist"
  23. if (defined(invoker.info_plists)) {
  24. assert(!defined(invoker.info_plist),
  25. "Cannot have both info_plist and info_plists for $target_name")
  26. _source_name = "$target_gen_dir/${target_name}_merged.plist"
  27. _deps = [ ":" + target_name + "_merge_plist" ]
  28. action(target_name + "_merge_plist") {
  29. forward_variables_from(invoker,
  30. [
  31. "testonly",
  32. "deps",
  33. ])
  34. script = "//build/apple/plist_util.py"
  35. sources = invoker.info_plists
  36. outputs = [ _source_name ]
  37. args = [
  38. "merge",
  39. "-f=xml1",
  40. "-o=" + rebase_path(_source_name, root_build_dir),
  41. ] + rebase_path(invoker.info_plists, root_build_dir)
  42. }
  43. } else {
  44. assert(defined(invoker.info_plist),
  45. "The info_plist must be specified in $target_name")
  46. _source_name = invoker.info_plist
  47. _deps = []
  48. if (defined(invoker.deps)) {
  49. _deps += invoker.deps
  50. }
  51. }
  52. action(target_name) {
  53. forward_variables_from(invoker,
  54. [
  55. "args",
  56. "testonly",
  57. ])
  58. script = "//build/apple/tweak_info_plist.py"
  59. inputs = [
  60. script,
  61. "//build/util/version.py",
  62. lastchange_file,
  63. "//chrome/VERSION",
  64. ]
  65. sources = [ _source_name ]
  66. outputs = [ _output_name ]
  67. if (!defined(args)) {
  68. args = []
  69. }
  70. args += [
  71. "--plist",
  72. rebase_path(_source_name, root_build_dir),
  73. "--output",
  74. rebase_path(_output_name, root_build_dir),
  75. "--platform=$current_os",
  76. ]
  77. deps = _deps
  78. }
  79. }