generate_ui_string_overrider.gni 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. # Runs the resources map generation script other the given header files to
  5. # produce an output file and a source_set to build it.
  6. #
  7. # Parameters:
  8. # inputs:
  9. # List of file name to read. Each file should be an header file generated
  10. # by grit with line like "#define IDS_FOO 12345".
  11. #
  12. # namespace (optional):
  13. # Namespace in which the generated code should be scoped. If left empty,
  14. # the code will be in the global namespace.
  15. #
  16. # header_filename:
  17. # Name of the generated header file.
  18. #
  19. # source_filename:
  20. # Name of the generated source file.
  21. #
  22. # deps (optional):
  23. # List of targets to depend on.
  24. #
  25. template("generate_ui_string_overrider") {
  26. # Copy "target_name" to allow restrict the visibility of the generation
  27. # target to that target (as ":$target_name" will have a different meaning
  28. # in the "action" block).
  29. source_set_target_name = target_name
  30. gen_action_target_name = target_name + "_gen_sources"
  31. action(gen_action_target_name) {
  32. header_filename = "$target_gen_dir/" + invoker.header_filename
  33. source_filename = "$target_gen_dir/" + invoker.source_filename
  34. visibility = [ ":$source_set_target_name" ]
  35. script = "//components/variations/service/generate_ui_string_overrider.py"
  36. outputs = [
  37. header_filename,
  38. source_filename,
  39. ]
  40. inputs = invoker.inputs
  41. if (defined(invoker.deps)) {
  42. deps = invoker.deps
  43. }
  44. args = []
  45. if (defined(invoker.namespace) && invoker.namespace != "") {
  46. args += [ "-N" + invoker.namespace ]
  47. }
  48. args += [
  49. "-o" + rebase_path(root_gen_dir, root_build_dir),
  50. "-H" + rebase_path(header_filename, root_gen_dir),
  51. "-S" + rebase_path(source_filename, root_gen_dir),
  52. ] + rebase_path(inputs, root_build_dir)
  53. }
  54. source_set(target_name) {
  55. sources = get_target_outputs(":$gen_action_target_name")
  56. deps = [
  57. ":$gen_action_target_name",
  58. "//components/variations/service",
  59. ]
  60. forward_variables_from(invoker, [ "visibility" ])
  61. }
  62. }