summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordimdim11 <[email protected]>2024-09-12 23:37:34 +0300
committerdimdim11 <[email protected]>2024-09-12 23:50:02 +0300
commita4578ad8edc3f32dcc5c8bc40a1aae905157f1bf (patch)
tree88ff9611a044a803425e63d72390c01539bc5dc0
parent199514a288190e307760cad99a22f33bea95534c (diff)
Fix run_antlr semantics, add run_antlr4 semantic
Add run_antlr4 semantic Add semantic for run antlr4 commit_hash:55ff8945c64f798c87399822344b24b5bd6c7b16
-rw-r--r--build/export_generators/cmake/cmake/antlr.cmake13
-rw-r--r--build/export_generators/cmake/cmake/antlr4.cmake30
-rw-r--r--build/export_generators/cmake/generator.toml8
-rw-r--r--build/export_generators/hardcoded-cmake/cmake/antlr.cmake13
-rw-r--r--build/export_generators/hardcoded-cmake/cmake/antlr4.cmake30
-rw-r--r--build/export_generators/hardcoded-cmake/generator.toml5
-rw-r--r--build/ymake.core.conf10
7 files changed, 89 insertions, 20 deletions
diff --git a/build/export_generators/cmake/cmake/antlr.cmake b/build/export_generators/cmake/cmake/antlr.cmake
index d203fd9c885..3bbce44a676 100644
--- a/build/export_generators/cmake/cmake/antlr.cmake
+++ b/build/export_generators/cmake/cmake/antlr.cmake
@@ -1,7 +1,6 @@
function(ensure_antlr)
if(NOT ANTLR3_EXECUTABLE)
- find_program(ANTLR3_EXECUTABLE
- NAMES antlr3)
+ find_program(ANTLR3_EXECUTABLE NAMES antlr3)
if (NOT ANTLR3_EXECUTABLE)
message(FATAL_ERROR "Unable to find antlr3 program. Please install antlr3 and make sure executable file present in the $PATH env.")
endif()
@@ -14,7 +13,7 @@ function(run_antlr)
set(oneValueArgs WORKING_DIRECTORY)
set(multiValueArgs OUTPUT DEPENDS ANTLER_ARGS)
cmake_parse_arguments(
- RUN_ANTLR
+ RUN_ANTLR3
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
@@ -22,10 +21,10 @@ function(run_antlr)
)
add_custom_command(
- OUTPUT ${RUN_ANTLR_OUTPUT}
- COMMAND ${ANTLR3_EXECUTABLE} ${RUN_ANTLR_ANTLER_ARGS}
- WORKING_DIRECTORY ${RUN_ANTLR_WORKING_DIRECTORY}
- DEPENDS ${RUN_ANTLR_DEPENDS}
+ OUTPUT ${RUN_ANTLR3_OUTPUT}
+ COMMAND ${ANTLR3_EXECUTABLE} ${RUN_ANTLR3_ANTLER_ARGS}
+ WORKING_DIRECTORY ${RUN_ANTLR3_WORKING_DIRECTORY}
+ DEPENDS ${RUN_ANTLR3_DEPENDS}
)
endfunction()
diff --git a/build/export_generators/cmake/cmake/antlr4.cmake b/build/export_generators/cmake/cmake/antlr4.cmake
new file mode 100644
index 00000000000..df3465c1b3c
--- /dev/null
+++ b/build/export_generators/cmake/cmake/antlr4.cmake
@@ -0,0 +1,30 @@
+function(ensure_antlr4)
+ if(NOT ANTLR4_EXECUTABLE)
+ find_program(ANTLR4_EXECUTABLE NAMES antlr4)
+ if (NOT ANTLR4_EXECUTABLE)
+ message(FATAL_ERROR "Unable to find antlr4 program. Please install antlr4 and make sure executable file present in the $PATH env.")
+ endif()
+ endif()
+endfunction()
+
+function(run_antlr4)
+ ensure_antlr4()
+ set(options "")
+ set(oneValueArgs WORKING_DIRECTORY)
+ set(multiValueArgs OUTPUT DEPENDS ANTLER_ARGS)
+ cmake_parse_arguments(
+ RUN_ANTLR4
+ "${options}"
+ "${oneValueArgs}"
+ "${multiValueArgs}"
+ ${ARGN}
+ )
+
+ add_custom_command(
+ OUTPUT ${RUN_ANTLR4_OUTPUT}
+ COMMAND ${ANTLR4_EXECUTABLE} ${RUN_ANTLR4_ANTLER_ARGS}
+ WORKING_DIRECTORY ${RUN_ANTLR4_WORKING_DIRECTORY}
+ DEPENDS ${RUN_ANTLR4_DEPENDS}
+ )
+
+endfunction()
diff --git a/build/export_generators/cmake/generator.toml b/build/export_generators/cmake/generator.toml
index d253630ab65..4fcb521f2fc 100644
--- a/build/export_generators/cmake/generator.toml
+++ b/build/export_generators/cmake/generator.toml
@@ -188,6 +188,7 @@ set_yunittest_property="skip"
copy_file="skip"
configure_file="skip"
run_antlr="skip"
+run_antlr4="skip"
set_property="skip"
add_jar="skip"
set_property_escaped="skip"
@@ -270,11 +271,16 @@ copy=["cmake/FindJNITarget.cmake"]
add_values=[{attr="includes", values=["cmake/FindJNITarget.cmake"]}]
[[rules]]
-attrs=["run_antlr"]
+attrs=["target_commands-macro=run_antlr"]
copy=["cmake/antlr.cmake"]
add_values=[{attr="includes", values=["cmake/antlr.cmake"]}]
[[rules]]
+attrs=["target_commands-macro=run_antlr4"]
+copy=["cmake/antlr4.cmake"]
+add_values=[{attr="includes", values=["cmake/antlr4.cmake"]}]
+
+[[rules]]
attrs=[
"target_bison_parser",
"target_flex_lexers"
diff --git a/build/export_generators/hardcoded-cmake/cmake/antlr.cmake b/build/export_generators/hardcoded-cmake/cmake/antlr.cmake
index d203fd9c885..3bbce44a676 100644
--- a/build/export_generators/hardcoded-cmake/cmake/antlr.cmake
+++ b/build/export_generators/hardcoded-cmake/cmake/antlr.cmake
@@ -1,7 +1,6 @@
function(ensure_antlr)
if(NOT ANTLR3_EXECUTABLE)
- find_program(ANTLR3_EXECUTABLE
- NAMES antlr3)
+ find_program(ANTLR3_EXECUTABLE NAMES antlr3)
if (NOT ANTLR3_EXECUTABLE)
message(FATAL_ERROR "Unable to find antlr3 program. Please install antlr3 and make sure executable file present in the $PATH env.")
endif()
@@ -14,7 +13,7 @@ function(run_antlr)
set(oneValueArgs WORKING_DIRECTORY)
set(multiValueArgs OUTPUT DEPENDS ANTLER_ARGS)
cmake_parse_arguments(
- RUN_ANTLR
+ RUN_ANTLR3
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
@@ -22,10 +21,10 @@ function(run_antlr)
)
add_custom_command(
- OUTPUT ${RUN_ANTLR_OUTPUT}
- COMMAND ${ANTLR3_EXECUTABLE} ${RUN_ANTLR_ANTLER_ARGS}
- WORKING_DIRECTORY ${RUN_ANTLR_WORKING_DIRECTORY}
- DEPENDS ${RUN_ANTLR_DEPENDS}
+ OUTPUT ${RUN_ANTLR3_OUTPUT}
+ COMMAND ${ANTLR3_EXECUTABLE} ${RUN_ANTLR3_ANTLER_ARGS}
+ WORKING_DIRECTORY ${RUN_ANTLR3_WORKING_DIRECTORY}
+ DEPENDS ${RUN_ANTLR3_DEPENDS}
)
endfunction()
diff --git a/build/export_generators/hardcoded-cmake/cmake/antlr4.cmake b/build/export_generators/hardcoded-cmake/cmake/antlr4.cmake
new file mode 100644
index 00000000000..df3465c1b3c
--- /dev/null
+++ b/build/export_generators/hardcoded-cmake/cmake/antlr4.cmake
@@ -0,0 +1,30 @@
+function(ensure_antlr4)
+ if(NOT ANTLR4_EXECUTABLE)
+ find_program(ANTLR4_EXECUTABLE NAMES antlr4)
+ if (NOT ANTLR4_EXECUTABLE)
+ message(FATAL_ERROR "Unable to find antlr4 program. Please install antlr4 and make sure executable file present in the $PATH env.")
+ endif()
+ endif()
+endfunction()
+
+function(run_antlr4)
+ ensure_antlr4()
+ set(options "")
+ set(oneValueArgs WORKING_DIRECTORY)
+ set(multiValueArgs OUTPUT DEPENDS ANTLER_ARGS)
+ cmake_parse_arguments(
+ RUN_ANTLR4
+ "${options}"
+ "${oneValueArgs}"
+ "${multiValueArgs}"
+ ${ARGN}
+ )
+
+ add_custom_command(
+ OUTPUT ${RUN_ANTLR4_OUTPUT}
+ COMMAND ${ANTLR4_EXECUTABLE} ${RUN_ANTLR4_ANTLER_ARGS}
+ WORKING_DIRECTORY ${RUN_ANTLR4_WORKING_DIRECTORY}
+ DEPENDS ${RUN_ANTLR4_DEPENDS}
+ )
+
+endfunction()
diff --git a/build/export_generators/hardcoded-cmake/generator.toml b/build/export_generators/hardcoded-cmake/generator.toml
index 3e36586f390..e8c2a28b5cd 100644
--- a/build/export_generators/hardcoded-cmake/generator.toml
+++ b/build/export_generators/hardcoded-cmake/generator.toml
@@ -72,6 +72,11 @@ copy=["cmake/antlr.cmake"]
add_values=[{attr="includes", values=["cmake/antlr.cmake"]}]
[[rules]]
+attrs=["run_antlr4"]
+copy=["cmake/antlr4.cmake"]
+add_values=[{attr="includes", values=["cmake/antlr4.cmake"]}]
+
+[[rules]]
attrs=[
"target_bison_parser",
"target_flex_lexers"
diff --git a/build/ymake.core.conf b/build/ymake.core.conf
index 43400fb1332..50579af8f95 100644
--- a/build/ymake.core.conf
+++ b/build/ymake.core.conf
@@ -4605,9 +4605,10 @@ macro RUN_PYTHON3(ScriptPath, IN{input}[], IN_NOPARSE{input}[], OUT{output}[], O
}
# tag:java-specific
-macro _RUN_JAVA(IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], TOOL[], STDOUT="", STDOUT_NOAUTO="", CWD="", 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", SEM_ARGS_PREFIX="", 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 $Args ${hide;tool:TOOL} ${hide;input:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${hide;output:OUT} ${hide;noauto;output:OUT_NOAUTO} ${stdout;output:STDOUT} ${stdout;output;noauto:STDOUT_NOAUTO} ${hide;kv:"p JV"} ${hide;kv:"pc light-blue"} ${hide;kv:"show_out"}
+ .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} ${input;context=TEXT;hide:IN_NOPARSE} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${hide;output:OUT} ${hide;noauto;output:OUT_NOAUTO} ${stdout;output:STDOUT} ${stdout;output;noauto:STDOUT_NOAUTO} ${hide;kv:"p JV"} ${hide;kv:"pc light-blue"} ${hide;kv:"show_out"}
+ .SEM=$SEM OUTPUT ${output:OUT} ${noauto;output:OUT_NOAUTO} DEPENDS ${input:IN} ${pre=WORKING_DIRECTORY :CWD} $SEM_ARGS_PREFIX $Args && target_commands-ITEM && target_commands-macro $SEM && target_commands-args OUTPUT ${output:OUT} ${noauto;output:OUT_NOAUTO} DEPENDS ${input:IN} ${pre=WORKING_DIRECTORY :CWD} $SEM_ARGS_PREFIX $Args
}
### @usage: FROM_SANDBOX([FILE] resource_id [AUTOUPDATED script] [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE] [OUTPUT_INCLUDES <include files>] [INDUCED_DEPS $VARs...])
@@ -4961,15 +4962,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_JAVA(-jar ${input:"contrib/java/antlr/antlr3/antlr.jar"} $Args IN $IN IN_NOPARSE $IN_NOPARSE OUT $OUT OUT_NOAUTO $OUT_NOAUTO OUTPUT_INCLUDES $OUTPUT_INCLUDES INDUCED_DEPS $INDUCED_DEPS ${pre=CWD :CWD})
- .SEM=run_antlr OUTPUT ${output:OUT} ${noauto;output:OUT_NOAUTO} DEPENDS ${input:IN} ${pre=WORKING_DIRECTORY :CWD} ANTLER_ARGS $Args && target_commands-ITEM && target_commands-macro run_antlr && target_commands-args OUTPUT ${output:OUT} ${noauto;output:OUT_NOAUTO} DEPENDS ${input:IN} ${pre=WORKING_DIRECTORY :CWD} ANTLER_ARGS $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)
}
### @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_JAVA(-jar ${input:"contrib/java/antlr/antlr4/antlr.jar"} $Args IN $IN IN_NOPARSE $IN_NOPARSE OUT $OUT OUT_NOAUTO $OUT_NOAUTO OUTPUT_INCLUDES $OUTPUT_INCLUDES INDUCED_DEPS $INDUCED_DEPS ${pre=CWD :CWD})
+ _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)
}
_ANTLR4_LISTENER_GRAMMAR=-listener