target_commands.jinja 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. {%- if current_target.target_commands|length -%}
  2. {%- for target_command in current_target.target_commands %}
  3. {{ target_command.macro }}(
  4. {%- if target_command.args|length -%}
  5. {%- for arg in target_command.args %}
  6. {{ arg }}
  7. {%- endfor -%}
  8. {%- endif -%}
  9. {%- if target_command.args_escaped|length %}
  10. "
  11. {%- for arg_escaped in target_command.args_escaped -%}
  12. {{ arg_escaped|replace('\\', '\\\\')|replace('"', '\\"')|replace(';', '\\;') }}
  13. {%- if not loop.last -%};{%- endif -%}
  14. {%- endfor -%}
  15. "
  16. {%- endif %}
  17. )
  18. {% endfor -%}
  19. {%- endif -%}
  20. {%- if current_target.custom_runs|length -%}
  21. {%- for custom_run in current_target.custom_runs %}
  22. {%- set first_arg = custom_run.command|first %}
  23. {%- if (first_arg == "run_antlr") or (first_arg == "run_antlr4") %}
  24. {{ first_arg }}(
  25. {%- if custom_run.outputs|length %}
  26. OUTPUT
  27. {%- for output in custom_run.outputs %}
  28. {{ output }}
  29. {%- endfor -%}
  30. {%- endif %}
  31. {%- if (custom_run.cwd is defined) and (custom_run.cwd != "") %}
  32. WORKING_DIRECTORY
  33. {{ custom_run.cwd }}
  34. {%- endif -%}
  35. {%- if custom_run.command|length > 1 %}
  36. ANTLER_ARGS
  37. {%- for arg in custom_run.command -%}
  38. {%- if not loop.first %}
  39. {{ arg }}
  40. {%- endif -%}
  41. {%- endfor -%}
  42. {%- endif %}
  43. )
  44. {% else %}
  45. add_custom_command(
  46. {%- if custom_run.outputs|length %}
  47. OUTPUT
  48. {%- for output in custom_run.outputs %}
  49. {{ output }}
  50. {%- endfor -%}
  51. {%- endif -%}
  52. {%- if custom_run.depends|length %}
  53. DEPENDS
  54. {%- for depend in custom_run.depends %}
  55. {{ depend }}
  56. {%- endfor -%}
  57. {%- endif -%}
  58. {%- if (custom_run.cwd is defined ) and (custom_run.cwd != "") %}
  59. WORKING_DIRECTORY
  60. {{ custom_run.cwd }}
  61. {%- endif -%}
  62. {%- if custom_run.command|length %}
  63. COMMAND
  64. {%- if custom_run.env|length %}
  65. ${CMAKE_COMMAND}
  66. -E
  67. env
  68. {%- for env in custom_run.env %}
  69. {{ env|replace('\\', '\\\\')|replace('"', '\\"')|replace(';', '\\;') }}
  70. {%- if not loop.last -%};{%- endif -%}
  71. {%- endfor -%}
  72. {%- endif -%}
  73. {%- for arg in custom_run.command -%}
  74. {%- if loop.first and arg == "python3" -%}
  75. {%- set arg = "Python3::Interpreter" -%}
  76. {%- endif %}
  77. {{ arg }}
  78. {%- endfor -%}
  79. {%- endif %}
  80. )
  81. {% endif -%}
  82. {%- endfor -%}
  83. {%- endif -%}