Skip to content

Commit

Permalink
feat c35: configs-variables
Browse files Browse the repository at this point in the history
3f0c7868293ea4f2818bd62ab58e215e3aec8251
  • Loading branch information
segoon committed Aug 2, 2024
1 parent b5df56f commit a1da039
Showing 1 changed file with 45 additions and 21 deletions.
66 changes: 45 additions & 21 deletions chaotic/chaotic/compilers/dynamic_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,27 @@ def _generate_types(
)
return schemas, types

def variables_includes_hpp(self, name: str) -> List[str]:
types = self._variables_types[name]
includes: List[str] = []
for type_ in types.values():
includes += type_.declaration_includes()

return sorted(set(includes))

def variables_includes_cpp(self, name: str) -> List[str]:
types = self._variables_types[name]
includes: List[str] = []
for type_ in types.values():
includes += type_.definition_includes()
return sorted(set(includes))

def variables_external_includes_hpp(self, name: str) -> List[str]:
types = self._variables_types[name]
return self.renderer_for_variable(
name, False,
).extract_external_includes(types, '')

def _read_default(self, filepath: str) -> Any:
with open(filepath, 'r') as ifile:
content = yaml.load(ifile, Loader=yaml.CLoader)
Expand All @@ -229,32 +250,35 @@ def create_aliases(
) -> List[Tuple[str, str]]:
return []

def renderer_for_variable(
self, name: str, parse_extra_formats: bool,
) -> renderer.OneToOneFileRenderer:
return renderer.OneToOneFileRenderer(
relative_to='/',
vfilepath_to_relfilepath={
name: f'taxi_config/variables/{name}.types.hpp',
**{
name: (
'taxi_config/definitions/'
f'{name.split(".")[0].replace("/", "_")}.hpp'
)
for name in self._definitions
},
},
clang_format_bin=get_clang_format_bin(),
parse_extra_formats=parse_extra_formats,
generate_serializer=parse_extra_formats,
)

# TODO: move jinja files to arcadia_compiler
def generate_variable(
self, name: str, output_dir: str, parse_extra_formats: bool,
) -> None:
types = self._variables_types[name]
outputs = (
renderer.OneToOneFileRenderer(
relative_to='/',
vfilepath_to_relfilepath={
name: f'taxi_config/variables/{name}.types.hpp',
**{
name: (
'taxi_config/definitions/'
f'{name.split(".")[0].replace("/", "_")}.hpp'
)
for name in self._definitions
},
},
clang_format_bin=get_clang_format_bin(),
parse_extra_formats=parse_extra_formats,
generate_serializer=parse_extra_formats,
).render(
types,
local_pair_header=False,
# pair_header=f'taxi_config/variables/{name}.types.hpp',
)
outputs = self.renderer_for_variable(name, parse_extra_formats).render(
types,
local_pair_header=False,
# pair_header=f'taxi_config/variables/{name}.types.hpp',
)

name_lower = self.format_ns_name(name)
Expand Down

0 comments on commit a1da039

Please sign in to comment.