From 11b5b34c602e012b1ac7f496ba894c8f113b1f5d Mon Sep 17 00:00:00 2001 From: dimdim11 Date: Thu, 13 Feb 2025 01:01:22 +0300 Subject: [PATCH] Fix exporting run_antlr(4) to CMake Fix exporting run_antlr(4) to CMake commit_hash:13fe87a90bc6cb50c8e9ecd46ee85d17655316f1 --- build/export_generators/cmake/generator.toml | 4 ++-- .../export_generators/cmake/target_commands.jinja | 15 ++++++++------- build/ymake.core.conf | 8 ++++---- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/build/export_generators/cmake/generator.toml b/build/export_generators/cmake/generator.toml index 9343bd58..b25cf88c 100644 --- a/build/export_generators/cmake/generator.toml +++ b/build/export_generators/cmake/generator.toml @@ -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"]}] diff --git a/build/export_generators/cmake/target_commands.jinja b/build/export_generators/cmake/target_commands.jinja index ebc1ef6c..6d28dce8 100644 --- a/build/export_generators/cmake/target_commands.jinja +++ b/build/export_generators/cmake/target_commands.jinja @@ -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 %} @@ -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 diff --git a/build/ymake.core.conf b/build/ymake.core.conf index e29b47c4..b051651e 100644 --- a/build/ymake.core.conf +++ b/build/ymake.core.conf @@ -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 ] OUT_[NOAUTO] [EXECUTABLE] [OUTPUT_INCLUDES ] [INDUCED_DEPS $VARs...]) @@ -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