remoting_localize.gni 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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
  3. # found in the LICENSE file.
  4. # Calls the remoting_localize script with a jinja2 template.
  5. #
  6. # Arguments
  7. #
  8. # sources (required)
  9. # List of jinja2 files to load. This is the template.
  10. #
  11. # locale_list (required)
  12. # List of locales.
  13. #
  14. # locale_dir (optional)
  15. #
  16. # defines (optional)
  17. # List of defines to pass to script.
  18. # Example: defines = [ "FOO_HOST_PATH=bar" ]
  19. #
  20. # variables (optional)
  21. # List of variables to pass to script.
  22. #
  23. # output (optional)
  24. # Substitution pattern for the output. Defaults to a file in the target
  25. # gen dir with the extension stripped (normally the extension is ".jinja2"
  26. # which then leaves the non-tempaltized file name).
  27. # TODO(brettw) Need locale_output. This is a per-locale output file.
  28. #
  29. # encoding (optional)
  30. # String.
  31. #
  32. # deps (optional)
  33. # visibility (optional)
  34. template("remoting_localize") {
  35. action_foreach(target_name) {
  36. if (defined(invoker.visibility)) {
  37. visibility = invoker.visibility
  38. }
  39. script = "//remoting/tools/build/remoting_localize.py"
  40. sources = invoker.sources
  41. if (defined(invoker.output)) {
  42. outputs = [ invoker.output ]
  43. } else {
  44. outputs = [ "$target_gen_dir/{{source_name_part}}" ]
  45. }
  46. args = []
  47. if (defined(invoker.locale_dir)) {
  48. args += [
  49. "--locale_dir",
  50. rebase_path(invoker.locale_dir, root_build_dir),
  51. ]
  52. }
  53. # Add defines to command line.
  54. if (defined(invoker.defines)) {
  55. foreach(i, invoker.defines) {
  56. args += [
  57. "--define",
  58. i,
  59. ]
  60. }
  61. }
  62. # Add variables to command line.
  63. if (defined(invoker.variables)) {
  64. foreach(i, invoker.variables) {
  65. args += [
  66. "--variables",
  67. rebase_path(i, root_build_dir),
  68. ]
  69. }
  70. }
  71. # The template file is required.
  72. args += [
  73. "--template",
  74. "{{source}}",
  75. ]
  76. args += [
  77. "--output",
  78. rebase_path(outputs[0], root_build_dir),
  79. ]
  80. if (defined(invoker.encoding)) {
  81. args += [
  82. "--encoding",
  83. invoker.encoding,
  84. ]
  85. }
  86. args += invoker.locale_list
  87. if (defined(invoker.deps)) {
  88. deps = invoker.deps
  89. } else {
  90. deps = []
  91. }
  92. # This script reads the messages strings from the generated resource files.
  93. deps += [ "//remoting/resources:strings" ]
  94. }
  95. }