aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Stoyan <vvvv@ydb.tech>2023-12-29 23:44:59 +0300
committerGitHub <noreply@github.com>2023-12-29 23:44:59 +0300
commitaf6fb5d78323cf77cfcad7c79134a6c163d3897a (patch)
tree14cb64b7bf5b55a6c3acb193af54c7936a3d4b1b
parent279bff472e65f41778673a8cb7cc623aadd379c7 (diff)
downloadydb-af6fb5d78323cf77cfcad7c79134a6c163d3897a.tar.gz
YQL-17485 initial version of splitter for generated pb files from grammar (#791)
* init * simplify * missing file * integration into ya.make * disable code size option * drop symlinks:
-rw-r--r--ydb/library/yql/parser/proto_ast/gen/jsonpath/ya.make1
-rw-r--r--ydb/library/yql/parser/proto_ast/gen/multiproto.py110
-rw-r--r--ydb/library/yql/parser/proto_ast/gen/v0/ya.make64
-rw-r--r--ydb/library/yql/parser/proto_ast/gen/v0_proto/ya.make.gen29
-rwxr-xr-xydb/library/yql/parser/proto_ast/gen/v0_proto_split/update.sh7
-rw-r--r--ydb/library/yql/parser/proto_ast/gen/v0_proto_split/ya.make79
-rw-r--r--ydb/library/yql/parser/proto_ast/gen/v1/ya.make7
-rw-r--r--ydb/library/yql/parser/proto_ast/gen/v1_ansi/ya.make7
-rw-r--r--ydb/library/yql/parser/proto_ast/gen/v1_proto/ya.make.gen (renamed from ydb/library/yql/parser/proto_ast/gen/v1_proto/ya.make)0
-rwxr-xr-xydb/library/yql/parser/proto_ast/gen/v1_proto_split/update.sh7
-rw-r--r--ydb/library/yql/parser/proto_ast/gen/v1_proto_split/ya.make88
-rw-r--r--ydb/library/yql/parser/proto_ast/gen/ya.make3
-rwxr-xr-xydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/Cpp/Cpp.stg.in2
-rw-r--r--ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/protobuf/protobuf.stg.in1
-rw-r--r--ydb/library/yql/sql/v0/sql.cpp2
-rw-r--r--ydb/library/yql/sql/v0/ya.make1
-rw-r--r--ydb/library/yql/sql/v1/context.h2
-rw-r--r--ydb/library/yql/sql/v1/format/sql_format.cpp2
-rw-r--r--ydb/library/yql/sql/v1/lexer/ya.make2
-rw-r--r--ydb/library/yql/sql/v1/proto_parser/proto_parser.cpp2
-rw-r--r--ydb/library/yql/sql/v1/proto_parser/ya.make2
-rw-r--r--ydb/library/yql/sql/v1/sql_query.h2
-rw-r--r--ydb/library/yql/sql/v1/sql_select.h2
-rw-r--r--ydb/library/yql/sql/v1/sql_translation.h2
-rw-r--r--ydb/library/yql/sql/v1/sql_values.h2
-rw-r--r--ydb/library/yql/sql/v1/ya.make2
26 files changed, 370 insertions, 58 deletions
diff --git a/ydb/library/yql/parser/proto_ast/gen/jsonpath/ya.make b/ydb/library/yql/parser/proto_ast/gen/jsonpath/ya.make
index a78011fbafa..b050069fbc9 100644
--- a/ydb/library/yql/parser/proto_ast/gen/jsonpath/ya.make
+++ b/ydb/library/yql/parser/proto_ast/gen/jsonpath/ya.make
@@ -7,6 +7,7 @@ IF (CPP_PROTO)
SET(ANTLR_PACKAGE_NAME NJsonPathGenerated)
SET(PROTOBUF_HEADER_PATH ${MODDIR})
+ SET(PROTOBUF_SUFFIX_PATH .pb.h)
SET(LEXER_PARSER_NAMESPACE NALP)
diff --git a/ydb/library/yql/parser/proto_ast/gen/multiproto.py b/ydb/library/yql/parser/proto_ast/gen/multiproto.py
new file mode 100644
index 00000000000..75251fad9d0
--- /dev/null
+++ b/ydb/library/yql/parser/proto_ast/gen/multiproto.py
@@ -0,0 +1,110 @@
+import os
+import sys
+
+NSPLIT=10
+
+def main(argv):
+ input_dir="."
+ output_dir="."
+ name=sys.argv[1]
+ if len(argv)>2:
+ input_dir=argv[2]
+ if len(argv)>3:
+ output_dir=argv[3]
+ print("name:",name)
+ print("input_dir:",input_dir)
+ print("output_dir:",output_dir)
+
+ in_h=os.path.join(input_dir,name + ".pb.h")
+ in_cpp=os.path.join(input_dir,name + ".pb.cc")
+ out_h=os.path.join(output_dir,name + ".pb.main.h")
+ out_cpp_template=os.path.join(output_dir,name + ".pb.I")
+
+ with open(out_h,"w") as out_file:
+ with open(in_h,"r") as in_file:
+ for line in in_file:
+ line = line.replace("inline void RegisterArenaDtor","void RegisterArenaDtor")
+ out_file.write(line)
+
+ for i in range(0,2 + NSPLIT):
+ with open(out_cpp_template.replace("I","code" + str(i) + ".cc" if i<NSPLIT else "data.cc" if i==NSPLIT else "classes.h"),"w") as out_file:
+ with open(in_cpp,"r") as in_file:
+ line = line.replace("inline ","")
+ statement_index=0
+ current_types=set()
+ is_data_stmt=False
+ extern_data=False
+ extern_code=False
+ in_class_def=False
+ for line in in_file:
+ if line.startswith("#include") and name + ".pb.h" in line:
+ out_file.write('#include "' + name + '.pb.main.h"\n')
+ if i!=NSPLIT+1:
+ out_file.write('#include "' + name + '.pb.classes.h"\n')
+ continue
+ if line.strip()=="PROTOBUF_PRAGMA_INIT_SEG":
+ out_file.write(line)
+ break
+ out_file.write(line)
+ for line in in_file:
+ line=line.replace("inline ","")
+ if line.startswith("#"):
+ out_file.write(line)
+ continue
+ if line.startswith("namespace") or line.startswith("PROTOBUF_NAMESPACE_OPEN"):
+ open_namespace = True
+ out_file.write(line)
+ continue
+ if (line.startswith("} // namespace") or line.startswith("PROTOBUF_NAMESPACE_CLOSE")) and open_namespace:
+ open_namespace = False
+ out_file.write(line)
+ continue
+ if in_class_def:
+ if (i==NSPLIT+1):
+ out_file.write(line)
+ if line.startswith("};"):
+ in_class_def=False
+ continue
+ if line.startswith("PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT"):
+ type_name=line.split(" ")[2]
+ if type_name in current_types:
+ out_file.write(line)
+ continue
+ if line.startswith("static ") or (line.startswith("const ") and ("[]" in line or "=" in line)) or line.startswith("PROTOBUF_ATTRIBUTE_WEAK"):
+ is_data_stmt = True
+ extern_data = "file_level_metadata" in line or ("descriptor_table" in line and "once" in line)
+ extern_code = line.startswith("PROTOBUF_ATTRIBUTE_WEAK")
+ if line.startswith("class"):
+ in_class_def=True
+ if i==NSPLIT+1:
+ out_file.write(line)
+ continue
+ if not is_data_stmt and (statement_index % NSPLIT)==i:
+ if line.startswith("struct"):
+ current_types.add(line.split(" ")[1])
+ out_file.write(line)
+ if is_data_stmt and i==NSPLIT:
+ if extern_data:
+ line = line.replace("static ","")
+ out_file.write(line)
+ if is_data_stmt and i<NSPLIT:
+ if extern_data or extern_code:
+ if extern_data:
+ line = "extern " + line.replace("static ","").replace(" = {",";")
+ if extern_code:
+ if not "PROTOBUF_ATTRIBUTE_WEAK" in line:
+ continue
+ line = "extern " + line.replace(" {",";")
+ out_file.write(line)
+ extern_data = False
+ extern_code = False
+ if line.startswith("}"):
+ if is_data_stmt:
+ is_data_stmt=False
+ extern_data = False
+ extern_code = False
+ else:
+ statement_index += 1
+
+if __name__ == "__main__":
+ main(sys.argv)
diff --git a/ydb/library/yql/parser/proto_ast/gen/v0/ya.make b/ydb/library/yql/parser/proto_ast/gen/v0/ya.make
index 3c16fddba71..2037ad3f864 100644
--- a/ydb/library/yql/parser/proto_ast/gen/v0/ya.make
+++ b/ydb/library/yql/parser/proto_ast/gen/v0/ya.make
@@ -1,48 +1,36 @@
-PROTO_LIBRARY()
+LIBRARY()
-EXCLUDE_TAGS(GO_PROTO JAVA_PROTO)
+PEERDIR (
+ ydb/library/yql/parser/proto_ast/gen/v0_proto_split
+)
-IF (CPP_PROTO)
+SET(antlr_output ${ARCADIA_BUILD_ROOT}/${MODDIR})
+SET(antlr_templates ${antlr_output}/org/antlr/codegen/templates)
+SET(sql_grammar ${ARCADIA_ROOT}/ydb/library/yql/sql/v0/SQL.g)
- SET(antlr_output ${ARCADIA_BUILD_ROOT}/${MODDIR})
- SET(antlr_templates ${antlr_output}/org/antlr/codegen/templates)
- SET(sql_grammar ${ARCADIA_ROOT}/ydb/library/yql/sql/v0/SQL.g)
+SET(ANTLR_PACKAGE_NAME NSQLGenerated)
+SET(PROTOBUF_HEADER_PATH ydb/library/yql/parser/proto_ast/gen/v0_proto_split)
+SET(PROTOBUF_SUFFIX_PATH .pb.main.h)
+SET(LEXER_PARSER_NAMESPACE NALP)
- SET(ANTLR_PACKAGE_NAME NSQLGenerated)
- SET(PROTOBUF_HEADER_PATH ${MODDIR})
- SET(LEXER_PARSER_NAMESPACE NALP)
+CONFIGURE_FILE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/Cpp/Cpp.stg.in ${antlr_templates}/Cpp/Cpp.stg)
- CONFIGURE_FILE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/Cpp/Cpp.stg.in ${antlr_templates}/Cpp/Cpp.stg)
- CONFIGURE_FILE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/protobuf/protobuf.stg.in ${antlr_templates}/protobuf/protobuf.stg)
+NO_COMPILER_WARNINGS()
- RUN_ANTLR(
- ${sql_grammar}
- -lib .
- -fo ${antlr_output}
- -language protobuf
- IN ${sql_grammar} ${antlr_templates}/protobuf/protobuf.stg
- OUT_NOAUTO SQLParser.proto
- CWD ${antlr_output}
- )
+INCLUDE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/ya.make.incl)
- NO_COMPILER_WARNINGS()
-
- INCLUDE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/ya.make.incl)
-
- RUN_ANTLR(
- ${sql_grammar}
- -lib .
- -fo ${antlr_output}
- IN ${sql_grammar} ${antlr_templates}/Cpp/Cpp.stg
- OUT SQLParser.cpp SQLLexer.cpp SQLParser.h SQLLexer.h
- OUTPUT_INCLUDES
- SQLParser.pb.h
- ${STG_INCLUDES}
- CWD ${antlr_output}
- )
-ENDIF()
-
-SRCS(SQLParser.proto)
+RUN_ANTLR(
+ ${sql_grammar}
+ -lib .
+ -fo ${antlr_output}
+ IN ${sql_grammar} ${antlr_templates}/Cpp/Cpp.stg
+ OUT SQLParser.cpp SQLLexer.cpp SQLParser.h SQLLexer.h
+ OUTPUT_INCLUDES
+ ${PROTOBUF_HEADER_PATH}/SQLParser.pb.main.h
+ ${STG_INCLUDES}
+ CWD ${antlr_output}
+)
END()
+
diff --git a/ydb/library/yql/parser/proto_ast/gen/v0_proto/ya.make.gen b/ydb/library/yql/parser/proto_ast/gen/v0_proto/ya.make.gen
new file mode 100644
index 00000000000..cf8d70d84de
--- /dev/null
+++ b/ydb/library/yql/parser/proto_ast/gen/v0_proto/ya.make.gen
@@ -0,0 +1,29 @@
+PROTO_LIBRARY()
+
+IF (GEN_PROTO)
+
+ SET(antlr_output ${ARCADIA_BUILD_ROOT}/${MODDIR})
+ SET(antlr_templates ${antlr_output}/org/antlr/codegen/templates)
+ SET(sql_grammar ${ARCADIA_ROOT}/ydb/library/yql/sql/v0/SQL.g)
+
+ SET(ANTLR_PACKAGE_NAME NSQLGenerated)
+
+ CONFIGURE_FILE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/protobuf/protobuf.stg.in ${antlr_templates}/protobuf/protobuf.stg)
+
+ RUN_ANTLR(
+ ${sql_grammar}
+ -lib .
+ -fo ${antlr_output}
+ -language protobuf
+ IN ${sql_grammar} ${antlr_templates}/protobuf/protobuf.stg
+ OUT_NOAUTO SQLParser.proto
+ CWD ${antlr_output}
+ )
+
+ENDIF()
+
+SRCS(SQLParser.proto)
+
+EXCLUDE_TAGS(GO_PROTO JAVA_PROTO)
+
+END()
diff --git a/ydb/library/yql/parser/proto_ast/gen/v0_proto_split/update.sh b/ydb/library/yql/parser/proto_ast/gen/v0_proto_split/update.sh
new file mode 100755
index 00000000000..b362d37db02
--- /dev/null
+++ b/ydb/library/yql/parser/proto_ast/gen/v0_proto_split/update.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+set -eux
+cp ../v0_proto/ya.make.gen ../v0_proto/ya.make
+yag make ../v0_proto --add-result=".h" --add-result=".cc"
+rm ../v0_proto/ya.make
+python3 ../multiproto.py SQLParser ../v0_proto .
+
diff --git a/ydb/library/yql/parser/proto_ast/gen/v0_proto_split/ya.make b/ydb/library/yql/parser/proto_ast/gen/v0_proto_split/ya.make
new file mode 100644
index 00000000000..8781f9c1c60
--- /dev/null
+++ b/ydb/library/yql/parser/proto_ast/gen/v0_proto_split/ya.make
@@ -0,0 +1,79 @@
+LIBRARY()
+
+OWNER(g:yql g:yql_ydb_core)
+
+SET(antlr_output ${ARCADIA_BUILD_ROOT}/${MODDIR})
+SET(antlr_templates ${antlr_output}/org/antlr/codegen/templates)
+SET(sql_grammar ${ARCADIA_ROOT}/ydb/library/yql/sql/v0/SQL.g)
+
+SET(ANTLR_PACKAGE_NAME NSQLGenerated)
+
+CONFIGURE_FILE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/protobuf/protobuf.stg.in ${antlr_templates}/protobuf/protobuf.stg)
+
+RUN_ANTLR(
+ ${sql_grammar}
+ -lib .
+ -fo ${antlr_output}
+ -language protobuf
+ IN ${sql_grammar} ${antlr_templates}/protobuf/protobuf.stg
+ OUT_NOAUTO SQLParser.proto
+ CWD ${antlr_output}
+)
+
+IF (USE_VANILLA_PROTOC)
+ SET(PROTOC_PATH contrib/tools/protoc_std)
+ELSE()
+ SET(PROTOC_PATH contrib/tools/protoc)
+ENDIF()
+
+
+RUN_PROGRAM(
+ $PROTOC_PATH -I=$CURDIR -I=$ARCADIA_ROOT -I=$ARCADIA_BUILD_ROOT -I=$ARCADIA_ROOT/contrib/libs/protobuf/src
+ --cpp_out=$ARCADIA_BUILD_ROOT --cpp_styleguide_out=$ARCADIA_BUILD_ROOT
+ --plugin=protoc-gen-cpp_styleguide=contrib/tools/protoc/plugins/cpp_styleguide
+ SQLParser.proto
+ IN SQLParser.proto
+ TOOL contrib/tools/protoc/plugins/cpp_styleguide
+ OUT_NOAUTO SQLParser.pb.h SQLParser.pb.cc
+ CWD $ARCADIA_BUILD_ROOT
+)
+
+RUN_PYTHON3(
+ ${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/gen/multiproto.py SQLParser
+ IN SQLParser.pb.h
+ IN SQLParser.pb.cc
+ OUT_NOAUTO
+ SQLParser.pb.code0.cc
+ SQLParser.pb.code1.cc
+ SQLParser.pb.code2.cc
+ SQLParser.pb.code3.cc
+ SQLParser.pb.code4.cc
+ SQLParser.pb.code5.cc
+ SQLParser.pb.code6.cc
+ SQLParser.pb.code7.cc
+ SQLParser.pb.code8.cc
+ SQLParser.pb.code9.cc
+ SQLParser.pb.data.cc
+ SQLParser.pb.classes.h
+ SQLParser.pb.main.h
+ CWD $ARCADIA_BUILD_ROOT/ydb/library/yql/parser/proto_ast/gen/v0_proto_split
+)
+
+PEERDIR(contrib/libs/protobuf)
+
+SRCS(
+ SQLParser.pb.code0.cc
+ SQLParser.pb.code1.cc
+ SQLParser.pb.code2.cc
+ SQLParser.pb.code3.cc
+ SQLParser.pb.code4.cc
+ SQLParser.pb.code5.cc
+ SQLParser.pb.code6.cc
+ SQLParser.pb.code7.cc
+ SQLParser.pb.code8.cc
+ SQLParser.pb.code9.cc
+ SQLParser.pb.data.cc
+)
+
+END()
+
diff --git a/ydb/library/yql/parser/proto_ast/gen/v1/ya.make b/ydb/library/yql/parser/proto_ast/gen/v1/ya.make
index d756efefea9..f5487a56a18 100644
--- a/ydb/library/yql/parser/proto_ast/gen/v1/ya.make
+++ b/ydb/library/yql/parser/proto_ast/gen/v1/ya.make
@@ -1,7 +1,7 @@
LIBRARY()
PEERDIR (
- ydb/library/yql/parser/proto_ast/gen/v1_proto
+ ydb/library/yql/parser/proto_ast/gen/v1_proto_split
)
SET(antlr_output ${ARCADIA_BUILD_ROOT}/${MODDIR})
@@ -9,7 +9,8 @@ SET(antlr_templates ${antlr_output}/org/antlr/codegen/templates)
SET(sql_grammar ${antlr_output}/SQLv1.g)
SET(ANTLR_PACKAGE_NAME NSQLv1Generated)
-SET(PROTOBUF_HEADER_PATH ydb/library/yql/parser/proto_ast/gen/v1_proto)
+SET(PROTOBUF_HEADER_PATH ydb/library/yql/parser/proto_ast/gen/v1_proto_split)
+SET(PROTOBUF_SUFFIX_PATH .pb.main.h)
SET(LEXER_PARSER_NAMESPACE NALPDefault)
@@ -36,7 +37,7 @@ RUN_ANTLR(
IN ${sql_grammar} ${antlr_templates}/Cpp/Cpp.stg
OUT SQLv1Parser.cpp SQLv1Lexer.cpp SQLv1Parser.h SQLv1Lexer.h
OUTPUT_INCLUDES
- ${PROTOBUF_HEADER_PATH}/SQLv1Parser.pb.h
+ ${PROTOBUF_HEADER_PATH}/SQLv1Parser.pb.main.h
${STG_INCLUDES}
CWD ${antlr_output}
)
diff --git a/ydb/library/yql/parser/proto_ast/gen/v1_ansi/ya.make b/ydb/library/yql/parser/proto_ast/gen/v1_ansi/ya.make
index 27572951f0b..ebd0e8b70dc 100644
--- a/ydb/library/yql/parser/proto_ast/gen/v1_ansi/ya.make
+++ b/ydb/library/yql/parser/proto_ast/gen/v1_ansi/ya.make
@@ -1,7 +1,7 @@
LIBRARY()
PEERDIR (
- ydb/library/yql/parser/proto_ast/gen/v1_proto
+ ydb/library/yql/parser/proto_ast/gen/v1_proto_split
)
SET(antlr_output ${ARCADIA_BUILD_ROOT}/${MODDIR})
@@ -9,7 +9,8 @@ SET(antlr_templates ${antlr_output}/org/antlr/codegen/templates)
SET(sql_grammar ${antlr_output}/SQLv1.g)
SET(ANTLR_PACKAGE_NAME NSQLv1Generated)
-SET(PROTOBUF_HEADER_PATH ydb/library/yql/parser/proto_ast/gen/v1_proto)
+SET(PROTOBUF_HEADER_PATH ydb/library/yql/parser/proto_ast/gen/v1_proto_split)
+SET(PROTOBUF_SUFFIX_PATH .pb.main.h)
SET(LEXER_PARSER_NAMESPACE NALPAnsi)
@@ -36,7 +37,7 @@ RUN_ANTLR(
IN ${sql_grammar} ${antlr_templates}/Cpp/Cpp.stg
OUT SQLv1Parser.cpp SQLv1Lexer.cpp SQLv1Parser.h SQLv1Lexer.h
OUTPUT_INCLUDES
- ${PROTOBUF_HEADER_PATH}/SQLv1Parser.pb.h
+ ${PROTOBUF_HEADER_PATH}/SQLv1Parser.pb.main.h
${STG_INCLUDES}
CWD ${antlr_output}
)
diff --git a/ydb/library/yql/parser/proto_ast/gen/v1_proto/ya.make b/ydb/library/yql/parser/proto_ast/gen/v1_proto/ya.make.gen
index 68188823c32..68188823c32 100644
--- a/ydb/library/yql/parser/proto_ast/gen/v1_proto/ya.make
+++ b/ydb/library/yql/parser/proto_ast/gen/v1_proto/ya.make.gen
diff --git a/ydb/library/yql/parser/proto_ast/gen/v1_proto_split/update.sh b/ydb/library/yql/parser/proto_ast/gen/v1_proto_split/update.sh
new file mode 100755
index 00000000000..9e562ac57f2
--- /dev/null
+++ b/ydb/library/yql/parser/proto_ast/gen/v1_proto_split/update.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+set -eux
+cp ../v1_proto/ya.make.gen ../v1_proto/ya.make
+yag make ../v1_proto --add-result=".h" --add-result=".cc"
+rm ../v1_proto/ya.make
+python3 ../multiproto.py SQLv1Parser ../v1_proto .
+
diff --git a/ydb/library/yql/parser/proto_ast/gen/v1_proto_split/ya.make b/ydb/library/yql/parser/proto_ast/gen/v1_proto_split/ya.make
new file mode 100644
index 00000000000..099fbe345be
--- /dev/null
+++ b/ydb/library/yql/parser/proto_ast/gen/v1_proto_split/ya.make
@@ -0,0 +1,88 @@
+LIBRARY()
+
+OWNER(g:yql g:yql_ydb_core)
+
+SET(antlr_output ${ARCADIA_BUILD_ROOT}/${MODDIR})
+SET(antlr_templates ${antlr_output}/org/antlr/codegen/templates)
+SET(sql_grammar ${antlr_output}/SQLv1.g)
+
+SET(ANTLR_PACKAGE_NAME NSQLv1Generated)
+
+SET(GRAMMAR_STRING_CORE_SINGLE "\"~(QUOTE_SINGLE | BACKSLASH) | (BACKSLASH .)\"")
+SET(GRAMMAR_STRING_CORE_DOUBLE "\"~(QUOTE_DOUBLE | BACKSLASH) | (BACKSLASH .)\"")
+SET(GRAMMAR_MULTILINE_COMMENT_CORE "\".\"")
+
+CONFIGURE_FILE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/protobuf/protobuf.stg.in ${antlr_templates}/protobuf/protobuf.stg)
+
+IF(EXPORT_CMAKE)
+ MANUAL_GENERATION(${sql_grammar})
+ELSE()
+ CONFIGURE_FILE(${ARCADIA_ROOT}/ydb/library/yql/sql/v1/SQLv1.g.in ${sql_grammar})
+ENDIF()
+
+RUN_ANTLR(
+ ${sql_grammar}
+ -lib .
+ -fo ${antlr_output}
+ -language protobuf
+ IN ${sql_grammar} ${antlr_templates}/protobuf/protobuf.stg
+ OUT_NOAUTO SQLv1Parser.proto
+ CWD ${antlr_output}
+)
+
+IF (USE_VANILLA_PROTOC)
+ SET(PROTOC_PATH contrib/tools/protoc_std)
+ELSE()
+ SET(PROTOC_PATH contrib/tools/protoc)
+ENDIF()
+
+
+RUN_PROGRAM(
+ $PROTOC_PATH -I=$CURDIR -I=$ARCADIA_ROOT -I=$ARCADIA_BUILD_ROOT -I=$ARCADIA_ROOT/contrib/libs/protobuf/src
+ --cpp_out=$ARCADIA_BUILD_ROOT --cpp_styleguide_out=$ARCADIA_BUILD_ROOT
+ --plugin=protoc-gen-cpp_styleguide=contrib/tools/protoc/plugins/cpp_styleguide
+ SQLv1Parser.proto
+ IN SQLv1Parser.proto
+ TOOL contrib/tools/protoc/plugins/cpp_styleguide
+ OUT_NOAUTO SQLv1Parser.pb.h SQLv1Parser.pb.cc
+ CWD $ARCADIA_BUILD_ROOT
+)
+
+RUN_PYTHON3(
+ ${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/gen/multiproto.py SQLv1Parser
+ IN SQLv1Parser.pb.h
+ IN SQLv1Parser.pb.cc
+ OUT_NOAUTO
+ SQLv1Parser.pb.code0.cc
+ SQLv1Parser.pb.code1.cc
+ SQLv1Parser.pb.code2.cc
+ SQLv1Parser.pb.code3.cc
+ SQLv1Parser.pb.code4.cc
+ SQLv1Parser.pb.code5.cc
+ SQLv1Parser.pb.code6.cc
+ SQLv1Parser.pb.code7.cc
+ SQLv1Parser.pb.code8.cc
+ SQLv1Parser.pb.code9.cc
+ SQLv1Parser.pb.data.cc
+ SQLv1Parser.pb.classes.h
+ SQLv1Parser.pb.main.h
+ CWD $ARCADIA_BUILD_ROOT/ydb/library/yql/parser/proto_ast/gen/v1_proto_split
+)
+
+PEERDIR(contrib/libs/protobuf)
+
+SRCS(
+ SQLv1Parser.pb.code0.cc
+ SQLv1Parser.pb.code1.cc
+ SQLv1Parser.pb.code2.cc
+ SQLv1Parser.pb.code3.cc
+ SQLv1Parser.pb.code4.cc
+ SQLv1Parser.pb.code5.cc
+ SQLv1Parser.pb.code6.cc
+ SQLv1Parser.pb.code7.cc
+ SQLv1Parser.pb.code8.cc
+ SQLv1Parser.pb.code9.cc
+ SQLv1Parser.pb.data.cc
+)
+
+END()
diff --git a/ydb/library/yql/parser/proto_ast/gen/ya.make b/ydb/library/yql/parser/proto_ast/gen/ya.make
index 72c7ac4da73..b480619bbcb 100644
--- a/ydb/library/yql/parser/proto_ast/gen/ya.make
+++ b/ydb/library/yql/parser/proto_ast/gen/ya.make
@@ -1,6 +1,7 @@
RECURSE(
v0
v1
- v1_proto
+ v0_proto_split
+ v1_proto_split
jsonpath
)
diff --git a/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/Cpp/Cpp.stg.in b/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/Cpp/Cpp.stg.in
index f254a92c3ae..b5e688e07ed 100755
--- a/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/Cpp/Cpp.stg.in
+++ b/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/Cpp/Cpp.stg.in
@@ -133,7 +133,7 @@ outputFile( LEXER,
* Include the ANTLR3 generated header file.
*/
<if(PARSER)>
-#include \<@PROTOBUF_HEADER_PATH@/<name>.pb.h>
+#include \<@PROTOBUF_HEADER_PATH@/<name>@PROTOBUF_SUFFIX_PATH@>
<endif>
#include "<recognizer.grammar.name>Lexer.h"
diff --git a/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/protobuf/protobuf.stg.in b/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/protobuf/protobuf.stg.in
index 06fb6a697da..c232db86dc9 100644
--- a/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/protobuf/protobuf.stg.in
+++ b/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/protobuf/protobuf.stg.in
@@ -43,7 +43,6 @@ outputFile(LEXER,PARSER,TREE_PARSER, actionScope, actions,
syntax = "proto3";
option cc_enable_arenas = true;
-option optimize_for = CODE_SIZE;
package @ANTLR_PACKAGE_NAME@;
diff --git a/ydb/library/yql/sql/v0/sql.cpp b/ydb/library/yql/sql/v0/sql.cpp
index a8234d06ce0..ca8444a8a63 100644
--- a/ydb/library/yql/sql/v0/sql.cpp
+++ b/ydb/library/yql/sql/v0/sql.cpp
@@ -7,7 +7,7 @@
#include <ydb/library/yql/parser/proto_ast/collect_issues/collect_issues.h>
#include <ydb/library/yql/parser/proto_ast/gen/v0/SQLLexer.h>
#include <ydb/library/yql/parser/proto_ast/gen/v0/SQLParser.h>
-#include <ydb/library/yql/parser/proto_ast/gen/v0/SQLParser.pb.h>
+#include <ydb/library/yql/parser/proto_ast/gen/v0_proto_split/SQLParser.pb.main.h>
#include <ydb/library/yql/minikql/mkql_program_builder.h>
#include <ydb/library/yql/providers/common/provider/yql_provider_names.h>
#include <ydb/library/yql/core/yql_expr_type_annotation.h>
diff --git a/ydb/library/yql/sql/v0/ya.make b/ydb/library/yql/sql/v0/ya.make
index 334083a6c90..8211d93348d 100644
--- a/ydb/library/yql/sql/v0/ya.make
+++ b/ydb/library/yql/sql/v0/ya.make
@@ -12,6 +12,7 @@ PEERDIR(
ydb/library/yql/parser/proto_ast
ydb/library/yql/parser/proto_ast/collect_issues
ydb/library/yql/parser/proto_ast/gen/v0
+ ydb/library/yql/parser/proto_ast/gen/v0_proto_split
)
SRCS(
diff --git a/ydb/library/yql/sql/v1/context.h b/ydb/library/yql/sql/v1/context.h
index 2fea5638518..0ab493a62a1 100644
--- a/ydb/library/yql/sql/v1/context.h
+++ b/ydb/library/yql/sql/v1/context.h
@@ -9,7 +9,7 @@
#include <ydb/library/yql/sql/settings/translation_settings.h>
#include <ydb/library/yql/sql/cluster_mapping.h>
-#include <ydb/library/yql/parser/proto_ast/gen/v1_proto/SQLv1Parser.pb.h>
+#include <ydb/library/yql/parser/proto_ast/gen/v1_proto_split/SQLv1Parser.pb.main.h>
#include <util/generic/hash.h>
#include <util/generic/map.h>
diff --git a/ydb/library/yql/sql/v1/format/sql_format.cpp b/ydb/library/yql/sql/v1/format/sql_format.cpp
index 9294fd1f67f..b000932819a 100644
--- a/ydb/library/yql/sql/v1/format/sql_format.cpp
+++ b/ydb/library/yql/sql/v1/format/sql_format.cpp
@@ -6,7 +6,7 @@
#include <ydb/library/yql/sql/v1/lexer/lexer.h>
#include <ydb/library/yql/sql/v1/proto_parser/proto_parser.h>
-#include <ydb/library/yql/parser/proto_ast/gen/v1_proto/SQLv1Parser.pb.h>
+#include <ydb/library/yql/parser/proto_ast/gen/v1_proto_split/SQLv1Parser.pb.main.h>
#include <library/cpp/protobuf/util/simple_reflection.h>
#include <library/cpp/resource/resource.h>
diff --git a/ydb/library/yql/sql/v1/lexer/ya.make b/ydb/library/yql/sql/v1/lexer/ya.make
index 75abcae1f05..01a200311c3 100644
--- a/ydb/library/yql/sql/v1/lexer/ya.make
+++ b/ydb/library/yql/sql/v1/lexer/ya.make
@@ -5,7 +5,7 @@ PEERDIR(
ydb/library/yql/parser/proto_ast
ydb/library/yql/parser/proto_ast/gen/v1
ydb/library/yql/parser/proto_ast/gen/v1_ansi
- ydb/library/yql/parser/proto_ast/gen/v1_proto
+ ydb/library/yql/parser/proto_ast/gen/v1_proto_split
)
SRCS(
diff --git a/ydb/library/yql/sql/v1/proto_parser/proto_parser.cpp b/ydb/library/yql/sql/v1/proto_parser/proto_parser.cpp
index a26da0c62e0..04334f50b96 100644
--- a/ydb/library/yql/sql/v1/proto_parser/proto_parser.cpp
+++ b/ydb/library/yql/sql/v1/proto_parser/proto_parser.cpp
@@ -8,7 +8,7 @@
#include <ydb/library/yql/parser/proto_ast/gen/v1_ansi/SQLv1Lexer.h>
#include <ydb/library/yql/parser/proto_ast/gen/v1_ansi/SQLv1Parser.h>
-#include <ydb/library/yql/parser/proto_ast/gen/v1_proto/SQLv1Parser.pb.h>
+#include <ydb/library/yql/parser/proto_ast/gen/v1_proto_split/SQLv1Parser.pb.main.h>
#if defined(_tsan_enabled_)
#include <util/system/mutex.h>
diff --git a/ydb/library/yql/sql/v1/proto_parser/ya.make b/ydb/library/yql/sql/v1/proto_parser/ya.make
index d0667167e0f..5c16e92fa0c 100644
--- a/ydb/library/yql/sql/v1/proto_parser/ya.make
+++ b/ydb/library/yql/sql/v1/proto_parser/ya.make
@@ -7,7 +7,7 @@ PEERDIR(
ydb/library/yql/parser/proto_ast/collect_issues
ydb/library/yql/parser/proto_ast/gen/v1
ydb/library/yql/parser/proto_ast/gen/v1_ansi
- ydb/library/yql/parser/proto_ast/gen/v1_proto
+ ydb/library/yql/parser/proto_ast/gen/v1_proto_split
)
SRCS(
diff --git a/ydb/library/yql/sql/v1/sql_query.h b/ydb/library/yql/sql/v1/sql_query.h
index 7f383a3ec05..982f9c8c317 100644
--- a/ydb/library/yql/sql/v1/sql_query.h
+++ b/ydb/library/yql/sql/v1/sql_query.h
@@ -2,7 +2,7 @@
#include "sql_translation.h"
-#include <ydb/library/yql/parser/proto_ast/gen/v1_proto/SQLv1Parser.pb.h>
+#include <ydb/library/yql/parser/proto_ast/gen/v1_proto_split/SQLv1Parser.pb.main.h>
#include <util/string/split.h>
namespace NSQLTranslationV1 {
diff --git a/ydb/library/yql/sql/v1/sql_select.h b/ydb/library/yql/sql/v1/sql_select.h
index 945722501da..8d7d25d9b80 100644
--- a/ydb/library/yql/sql/v1/sql_select.h
+++ b/ydb/library/yql/sql/v1/sql_select.h
@@ -1,7 +1,7 @@
#pragma once
#include "sql_translation.h"
-#include <ydb/library/yql/parser/proto_ast/gen/v1_proto/SQLv1Parser.pb.h>
+#include <ydb/library/yql/parser/proto_ast/gen/v1_proto_split/SQLv1Parser.pb.main.h>
namespace NSQLTranslationV1 {
diff --git a/ydb/library/yql/sql/v1/sql_translation.h b/ydb/library/yql/sql/v1/sql_translation.h
index bcf0b8feba5..6d23faa04bf 100644
--- a/ydb/library/yql/sql/v1/sql_translation.h
+++ b/ydb/library/yql/sql/v1/sql_translation.h
@@ -1,6 +1,6 @@
#pragma once
#include "context.h"
-#include <ydb/library/yql/parser/proto_ast/gen/v1_proto/SQLv1Parser.pb.h>
+#include <ydb/library/yql/parser/proto_ast/gen/v1_proto_split/SQLv1Parser.pb.main.h>
#include <library/cpp/charset/ci_string.h>
namespace NSQLTranslationV1 {
diff --git a/ydb/library/yql/sql/v1/sql_values.h b/ydb/library/yql/sql/v1/sql_values.h
index aaae53490f6..32834657e96 100644
--- a/ydb/library/yql/sql/v1/sql_values.h
+++ b/ydb/library/yql/sql/v1/sql_values.h
@@ -1,7 +1,7 @@
#pragma once
#include "sql_translation.h"
-#include <ydb/library/yql/parser/proto_ast/gen/v1_proto/SQLv1Parser.pb.h>
+#include <ydb/library/yql/parser/proto_ast/gen/v1_proto_split/SQLv1Parser.pb.main.h>
namespace NSQLTranslationV1 {
diff --git a/ydb/library/yql/sql/v1/ya.make b/ydb/library/yql/sql/v1/ya.make
index c6d812c707c..3d86e879d40 100644
--- a/ydb/library/yql/sql/v1/ya.make
+++ b/ydb/library/yql/sql/v1/ya.make
@@ -17,7 +17,7 @@ PEERDIR(
ydb/library/yql/parser/proto_ast/collect_issues
ydb/library/yql/parser/proto_ast/gen/v1
ydb/library/yql/parser/proto_ast/gen/v1_ansi
- ydb/library/yql/parser/proto_ast/gen/v1_proto
+ ydb/library/yql/parser/proto_ast/gen/v1_proto_split
ydb/library/yql/parser/pg_catalog
ydb/library/yql/sql/v1/lexer
ydb/library/yql/sql/v1/proto_parser