Skip to content

Commit

Permalink
Fix exporting run_antlr(4) to CMake
Browse files Browse the repository at this point in the history
Fix exporting run_antlr(4) to CMake
commit_hash:13fe87a90bc6cb50c8e9ecd46ee85d17655316f1
  • Loading branch information
dimdim1177 committed Feb 12, 2025
1 parent 5f52c45 commit 11b5b34
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions build/export_generators/cmake/generator.toml
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,12 @@ copy=["cmake/FindJNITarget.cmake"]
add_values=[{attr="includes", values=["cmake/FindJNITarget.cmake"]}]

[[rules]]
attrs=["target_commands-macro=run_antlr"]
attrs=["custom_runs-command=run_antlr"]
copy=["cmake/antlr.cmake"]
add_values=[{attr="includes", values=["cmake/antlr.cmake"]}]

[[rules]]
attrs=["target_commands-macro=run_antlr4"]
attrs=["custom_runs-command=run_antlr4"]
copy=["cmake/antlr4.cmake"]
add_values=[{attr="includes", values=["cmake/antlr4.cmake"]}]

Expand Down
15 changes: 8 additions & 7 deletions build/export_generators/cmake/target_commands.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
{%- if current_target.custom_runs|length -%}
{%- for custom_run in current_target.custom_runs %}
{%- set first_arg = custom_run.command|first %}
{%- set tail_args = custom_run.command|slice(1, custom_run.command|length - 1) %}
{%- if (first_arg == "run_antlr") or (first_arg == "run_antlr4") %}
{{ first_arg }}(
{%- if custom_run.outputs|length %}
Expand All @@ -34,14 +33,16 @@
WORKING_DIRECTORY
{{ custom_run.cwd }}
{%- endif -%}
{%- if tail_args|length %}
ANTLR_ARGS
{%- for tail_arg in tail_args %}
{{ tail_arg }}
{%- if custom_run.command|length > 1 %}
ANTLER_ARGS
{%- for arg in custom_run.command -%}
{%- if not loop.first %}
{{ arg }}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endif %}
)
{%- else %}
{% else %}
add_custom_command(
{%- if custom_run.outputs|length %}
OUTPUT
Expand Down
8 changes: 4 additions & 4 deletions build/ymake.core.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4568,10 +4568,10 @@ macro RUN_PYTHON3(ScriptPath, IN{input}[], IN_NOPARSE{input}[], OUT{output}[], O
}

# tag:java-specific
macro _RUN_ANTLR_BASE(IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], TOOL[], STDOUT="", STDOUT_NOAUTO="", CWD="", JAR[], SEM="run_java", SEM_ARGS_PREFIX="", ENV[], HIDE_OUTPUT?"stderr2stdout":"stdout2stderr", Args...) {
macro _RUN_ANTLR_BASE(IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], TOOL[], STDOUT="", STDOUT_NOAUTO="", CWD="", JAR[], SEM="run_java", ENV[], HIDE_OUTPUT?"stderr2stdout":"stdout2stderr", Args...) {
PEERDIR(build/platform/java/jdk $JDK_RESOURCE_PEERDIR)
.CMD=${cwd:CWD} ${env:ENV} $YMAKE_PYTHON ${input;pre=build/scripts/:HIDE_OUTPUT.py} $JDK_RESOURCE/bin/java $JAR $Args ${hide;tool:TOOL} ${hide;input:IN} ${hide;context=TEXT;input:IN_NOPARSE} ${hide;output_include:OUTPUT_INCLUDES} $INDUCED_DEPS ${hide;output:OUT} ${hide;noauto;output:OUT_NOAUTO} ${stdout;output:STDOUT} ${stdout;noauto;output:STDOUT_NOAUTO} ${hide;kv:"p JV"} ${hide;kv:"pc light-blue"} ${hide;kv:"show_out"}
.SEM=custom_runs-ITEM && custom_runs-depends ${input:IN} && custom_runs-command $SEM $Args && custom_runs-outputs ${output:OUT} ${noauto;output:OUT_NOAUTO} ${pre=&& custom_runs-cwd :CWD}
.SEM=custom_runs-ITEM && custom_runs-depends ${input:IN} && custom_runs-command $SEM && custom_runs-command $Args && custom_runs-outputs ${output:OUT} ${noauto;output:OUT_NOAUTO} ${pre=&& custom_runs-cwd :CWD}
}

### @usage: FROM_SANDBOX([FILE] resource_id [AUTOUPDATED script] [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE] [OUTPUT_INCLUDES <include files>] [INDUCED_DEPS $VARs...])
Expand Down Expand Up @@ -4930,14 +4930,14 @@ macro ASM_PREINCLUDE(PREINCLUDES...) {
###
### Macro to invoke ANTLR3 generator (general case)
macro RUN_ANTLR(IN[], IN_NOPARSE[], OUT[], OUT_NOAUTO[], OUTPUT_INCLUDES[], INDUCED_DEPS[], CWD="", Args...) {
_RUN_ANTLR_BASE($Args IN $IN IN_NOPARSE $IN_NOPARSE OUT $OUT OUT_NOAUTO $OUT_NOAUTO OUTPUT_INCLUDES $OUTPUT_INCLUDES INDUCED_DEPS $INDUCED_DEPS ${pre=CWD :CWD} JAR -jar ${input:"contrib/java/antlr/antlr3/antlr.jar"} SEM run_antlr SEM_ARGS_PREFIX ANTLER_ARGS)
_RUN_ANTLR_BASE($Args IN $IN IN_NOPARSE $IN_NOPARSE OUT $OUT OUT_NOAUTO $OUT_NOAUTO OUTPUT_INCLUDES $OUTPUT_INCLUDES INDUCED_DEPS $INDUCED_DEPS ${pre=CWD :CWD} JAR -jar ${input:"contrib/java/antlr/antlr3/antlr.jar"} SEM run_antlr)
}

### @usage: RUN_ANTLR4(Args...)
###
### Macro to invoke ANTLR4 generator (general case)
macro RUN_ANTLR4(IN[], IN_NOPARSE[], OUT[], OUT_NOAUTO[], OUTPUT_INCLUDES[], INDUCED_DEPS[], CWD="", Args...) {
_RUN_ANTLR_BASE($Args IN $IN IN_NOPARSE $IN_NOPARSE OUT $OUT OUT_NOAUTO $OUT_NOAUTO OUTPUT_INCLUDES $OUTPUT_INCLUDES INDUCED_DEPS $INDUCED_DEPS ${pre=CWD :CWD} JAR -jar ${input:"contrib/java/antlr/antlr4/antlr.jar"} SEM run_antlr4 SEM_ARGS_PREFIX ANTLER_ARGS)
_RUN_ANTLR_BASE($Args IN $IN IN_NOPARSE $IN_NOPARSE OUT $OUT OUT_NOAUTO $OUT_NOAUTO OUTPUT_INCLUDES $OUTPUT_INCLUDES INDUCED_DEPS $INDUCED_DEPS ${pre=CWD :CWD} JAR -jar ${input:"contrib/java/antlr/antlr4/antlr.jar"} SEM run_antlr4)
}

_ANTLR4_LISTENER_GRAMMAR=-listener
Expand Down

0 comments on commit 11b5b34

Please sign in to comment.