aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authordenisk <denisk@yandex-team.ru>2022-02-10 16:48:13 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:13 +0300
commita3e40d22cc86312046f69a10ea401b78e9efb746 (patch)
tree9133cfa57ce2fa5b31742d1dac3bc609e00297a8 /build
parent0e38f1d675a0b3d02016acf698e8d04c0b224047 (diff)
downloadydb-a3e40d22cc86312046f69a10ea401b78e9efb746.tar.gz
Restoring authorship annotation for <denisk@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'build')
-rw-r--r--build/plugins/code_generator.py84
-rw-r--r--build/plugins/tests/test_code_generator.py32
-rw-r--r--build/plugins/tests/ya.make2
-rw-r--r--build/plugins/ya.make2
-rw-r--r--build/scripts/ya.make4
-rw-r--r--build/ymake.core.conf42
6 files changed, 83 insertions, 83 deletions
diff --git a/build/plugins/code_generator.py b/build/plugins/code_generator.py
index ca8bb18c15..0e876c21f7 100644
--- a/build/plugins/code_generator.py
+++ b/build/plugins/code_generator.py
@@ -1,45 +1,45 @@
-import re
-import os
-
-import _import_wrapper as iw
-
+import re
+import os
+
+import _import_wrapper as iw
+
pattern = re.compile(r"#include\s*[<\"](?P<INDUCED>[^>\"]+)[>\"]|(?:@|{@)\s*(?:import|include|from)\s*[\"'](?P<INCLUDE>[^\"']+)[\"']")
-
-
-class CodeGeneratorTemplateParser(object):
- def __init__(self, path, unit):
- self._path = path
+
+
+class CodeGeneratorTemplateParser(object):
+ def __init__(self, path, unit):
+ self._path = path
retargeted = os.path.join(unit.path(), os.path.relpath(path, unit.resolve(unit.path())))
- with open(path, 'rb') as f:
- includes, induced = CodeGeneratorTemplateParser.parse_includes(f.readlines())
- self._includes = unit.resolve_include([retargeted] + includes) if includes else []
- self._induced = unit.resolve_include([retargeted] + induced) if induced else []
-
- @staticmethod
- def parse_includes(lines):
- includes = []
- induced = []
-
- for line in lines:
- for match in pattern.finditer(line):
- type = match.lastgroup
- if type == 'INCLUDE':
- includes.append(match.group(type))
- elif type == 'INDUCED':
- induced.append(match.group(type))
- else:
- raise Exception("Unexpected match! Perhaps it is a result of an error in pattern.")
- return (includes, induced)
-
- def includes(self):
- return self._includes
-
- def induced_deps(self):
- return {
- 'h+cpp': self._induced
- }
-
-
-def init():
+ with open(path, 'rb') as f:
+ includes, induced = CodeGeneratorTemplateParser.parse_includes(f.readlines())
+ self._includes = unit.resolve_include([retargeted] + includes) if includes else []
+ self._induced = unit.resolve_include([retargeted] + induced) if induced else []
+
+ @staticmethod
+ def parse_includes(lines):
+ includes = []
+ induced = []
+
+ for line in lines:
+ for match in pattern.finditer(line):
+ type = match.lastgroup
+ if type == 'INCLUDE':
+ includes.append(match.group(type))
+ elif type == 'INDUCED':
+ induced.append(match.group(type))
+ else:
+ raise Exception("Unexpected match! Perhaps it is a result of an error in pattern.")
+ return (includes, induced)
+
+ def includes(self):
+ return self._includes
+
+ def induced_deps(self):
+ return {
+ 'h+cpp': self._induced
+ }
+
+
+def init():
iw.addparser('markettemplate', CodeGeneratorTemplateParser)
- iw.addparser('macro', CodeGeneratorTemplateParser)
+ iw.addparser('macro', CodeGeneratorTemplateParser)
diff --git a/build/plugins/tests/test_code_generator.py b/build/plugins/tests/test_code_generator.py
index a675d9068c..b9ef68bc0f 100644
--- a/build/plugins/tests/test_code_generator.py
+++ b/build/plugins/tests/test_code_generator.py
@@ -1,16 +1,16 @@
-from build.plugins import code_generator
-
-
-def test_include_parser():
- template_file = """
- @ from 'util/namespace.macro' import namespace, change_namespace, close_namespaces
- @ import 'market/tools/code_generator/templates/serialization/json.macro' as json
- @ import 'market/tools/code_generator/templates/serialization/request_parameters.macro' as rp
- #include <sss/abcdefg.h>
- #include<fff/asd>
- #include "hhh/quququ.h"
- """
-
- includes, induced = code_generator.CodeGeneratorTemplateParser.parse_includes(template_file.split('\n'))
- assert includes == ['util/namespace.macro', 'market/tools/code_generator/templates/serialization/json.macro', 'market/tools/code_generator/templates/serialization/request_parameters.macro']
- assert induced == ['sss/abcdefg.h', 'fff/asd', 'hhh/quququ.h']
+from build.plugins import code_generator
+
+
+def test_include_parser():
+ template_file = """
+ @ from 'util/namespace.macro' import namespace, change_namespace, close_namespaces
+ @ import 'market/tools/code_generator/templates/serialization/json.macro' as json
+ @ import 'market/tools/code_generator/templates/serialization/request_parameters.macro' as rp
+ #include <sss/abcdefg.h>
+ #include<fff/asd>
+ #include "hhh/quququ.h"
+ """
+
+ includes, induced = code_generator.CodeGeneratorTemplateParser.parse_includes(template_file.split('\n'))
+ assert includes == ['util/namespace.macro', 'market/tools/code_generator/templates/serialization/json.macro', 'market/tools/code_generator/templates/serialization/request_parameters.macro']
+ assert induced == ['sss/abcdefg.h', 'fff/asd', 'hhh/quququ.h']
diff --git a/build/plugins/tests/ya.make b/build/plugins/tests/ya.make
index 87228b98df..856b7ceb9a 100644
--- a/build/plugins/tests/ya.make
+++ b/build/plugins/tests/ya.make
@@ -7,7 +7,7 @@ PEERDIR(
)
TEST_SRCS(
- test_code_generator.py
+ test_code_generator.py
test_common.py
test_requirements.py
test_ssqls.py
diff --git a/build/plugins/ya.make b/build/plugins/ya.make
index 4ad5f5988e..06e94b9c92 100644
--- a/build/plugins/ya.make
+++ b/build/plugins/ya.make
@@ -3,7 +3,7 @@ OWNER(g:ymake)
PY2_LIBRARY()
PY_SRCS(
- code_generator.py
+ code_generator.py
ssqls.py
swig.py
diff --git a/build/scripts/ya.make b/build/scripts/ya.make
index 710165e40d..b360dcc659 100644
--- a/build/scripts/ya.make
+++ b/build/scripts/ya.make
@@ -84,8 +84,8 @@ TEST_SRCS(
touch.py
unpacking_jtest_runner.py
vcs_info.py
- with_coverage.py
- with_crash_on_timeout.py
+ with_coverage.py
+ with_crash_on_timeout.py
with_pathsep_resolve.py
wrap_groovyc.py
wrapper.py
diff --git a/build/ymake.core.conf b/build/ymake.core.conf
index 081833998b..44b963719a 100644
--- a/build/ymake.core.conf
+++ b/build/ymake.core.conf
@@ -7141,33 +7141,33 @@ macro CTEMPLATE_VARNAMES(File) {
LLVM_OPTS=
CLANG_ROOT=$CLANG_RESOURCE_GLOBAL
-### @usage: GENERATED_SRCS(srcs... PARSE_META_FROM cpp_srcs... [OUTPUT_INCLUDES output_includes...] [OPTIONS])
-###
+### @usage: GENERATED_SRCS(srcs... PARSE_META_FROM cpp_srcs... [OUTPUT_INCLUDES output_includes...] [OPTIONS])
+###
### Generate sources using Jinja 2 template engine.
###
-### srcs... - list of text files which will be generated during build time by templates. Each template must be
-### placed to the place in source tree where corresponding source file should be generated. Name of
+### srcs... - list of text files which will be generated during build time by templates. Each template must be
+### placed to the place in source tree where corresponding source file should be generated. Name of
### template must be "<name_of_src_file>.markettemplate". For example if you want to generate file "example.cpp"
### then template should be named "example.cpp.markettemplate".
-### PARSE_META_FROM cpp_srcs... - list of C++ source files (.cpp, .h) which will be parsed using clang library
-### and metainformation extracted from the files will be made available for templates. Example of
-### template code fragment using metainformation: {{ meta.objects["@N@std@S@string"].name }}
-### OUTPUT_INCLUDES output_includes... - in cases when build system parser fails to determine all headers
-### which generated files include, you can specify additional headers here. In a normal situation this should
-### not be needed and this feature could be removed in the future.
-### OPTIONS - additional options for code_generator utility
-###
-### Examples of templates can be found in directory market/tools/code_generator/templates.
-### Metainformation does not contain entries for every object declared in C++ files specified in PARSE_META_FROM
-### parameter. To include some object into consideration you need to mark it by attribute. Attributes can
-### automatically add more attributes to dependent objects. This behavior depends on attribute definition.
-###
-### More information will be available (eventually:) here: https://wiki.yandex-team.ru/Users/denisk/codegenerator/
-macro GENERATED_SRCS(PARSE_META_FROM{input}[], OUTPUT_INCLUDES[], OPTIONS[], TEMPLATES...) {
+### PARSE_META_FROM cpp_srcs... - list of C++ source files (.cpp, .h) which will be parsed using clang library
+### and metainformation extracted from the files will be made available for templates. Example of
+### template code fragment using metainformation: {{ meta.objects["@N@std@S@string"].name }}
+### OUTPUT_INCLUDES output_includes... - in cases when build system parser fails to determine all headers
+### which generated files include, you can specify additional headers here. In a normal situation this should
+### not be needed and this feature could be removed in the future.
+### OPTIONS - additional options for code_generator utility
+###
+### Examples of templates can be found in directory market/tools/code_generator/templates.
+### Metainformation does not contain entries for every object declared in C++ files specified in PARSE_META_FROM
+### parameter. To include some object into consideration you need to mark it by attribute. Attributes can
+### automatically add more attributes to dependent objects. This behavior depends on attribute definition.
+###
+### More information will be available (eventually:) here: https://wiki.yandex-team.ru/Users/denisk/codegenerator/
+macro GENERATED_SRCS(PARSE_META_FROM{input}[], OUTPUT_INCLUDES[], OPTIONS[], TEMPLATES...) {
.CMD=${tool:"market/tools/code_generator"} --cpp-file ${input:PARSE_META_FROM} --templates-dir / ${ARCADIA_ROOT} --templates ${input:TEMPLATES.markettemplate} --generated-files ${output:TEMPLATES} ${output_include;hide:OUTPUT_INCLUDES} ${output_include;hide:PARSE_META_FROM} --arcadia-root ${ARCADIA_ROOT} --arcadia-build-root ${ARCADIA_BUILD_ROOT} --clang-root $CLANG_ROOT ${OPTIONS} -- $C_FLAGS_PLATFORM $CXXFLAGS ${pre=-I:_C__INCLUDE} -std=c++17 -Wno-unknown-warning-option -Wno-unused-parameter -Wno-undefined-inline -Wno-undefined-internal -Wno-unused-function $LLVM_OPTS -fno-lto
PEERDIR(build/platform/clang)
-}
-
+}
+
### @usage: CLANG_EMIT_AST_CXX(Input Output Opts...)
###
### Emit Clang AST from .cpp file. CXXFLAGS and LLVM_OPTS are passed in, while CFLAGS and C_FLAGS_PLATFORM are not.