aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnermolaev <snermolaev@yandex-team.com>2023-09-28 05:22:37 +0300
committersnermolaev <snermolaev@yandex-team.com>2023-09-28 05:46:51 +0300
commit3dc3eef69dc850828fcb3e2874cbd6673c7b5cf6 (patch)
treeed8436ab7cac29a49c1e69aef97801649fcadda8
parentdac948692cbbd01fe980826d12fcf540ccd61ba8 (diff)
downloadydb-3dc3eef69dc850828fcb3e2874cbd6673c7b5cf6.tar.gz
move code_generator.py to build/internal/plugins
-rw-r--r--build/plugins/code_generator.py45
-rw-r--r--build/plugins/tests/test_code_generator.py20
-rw-r--r--build/plugins/tests/ya.make1
-rw-r--r--build/plugins/ya.make1
4 files changed, 0 insertions, 67 deletions
diff --git a/build/plugins/code_generator.py b/build/plugins/code_generator.py
deleted file mode 100644
index 396c2706d8..0000000000
--- a/build/plugins/code_generator.py
+++ /dev/null
@@ -1,45 +0,0 @@
-import re
-import os
-
-import ymake
-
-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
- 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():
- ymake.addparser('markettemplate', CodeGeneratorTemplateParser)
- ymake.addparser('macro', CodeGeneratorTemplateParser)
diff --git a/build/plugins/tests/test_code_generator.py b/build/plugins/tests/test_code_generator.py
deleted file mode 100644
index 0d1d72bb30..0000000000
--- a/build/plugins/tests/test_code_generator.py
+++ /dev/null
@@ -1,20 +0,0 @@
-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 c8da702380..1dae544917 100644
--- a/build/plugins/tests/ya.make
+++ b/build/plugins/tests/ya.make
@@ -3,7 +3,6 @@ PY2TEST()
OWNER(g:ymake)
TEST_SRCS(
- 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 9b5f815c80..75b033baf8 100644
--- a/build/plugins/ya.make
+++ b/build/plugins/ya.make
@@ -5,7 +5,6 @@ PY2_LIBRARY()
PY_SRCS(
TOP_LEVEL
- code_generator.py
ssqls.py
_common.py