diff --git a/symforce/codegen/codegen.py b/symforce/codegen/codegen.py index 3ed8e2dde..e922a5d8a 100644 --- a/symforce/codegen/codegen.py +++ b/symforce/codegen/codegen.py @@ -538,8 +538,9 @@ def generate_function( self.namespace = namespace template_data = dict(self.common_data(), spec=self) - template_dir = self.config.template_dir() + self.config.update_template_data(data=template_data) + template_dir = self.config.template_dir() backend_name = self.config.backend_name() if skip_directory_nesting: out_function_dir = output_dir diff --git a/symforce/codegen/codegen_config.py b/symforce/codegen/codegen_config.py index 64b416281..f7494e520 100644 --- a/symforce/codegen/codegen_config.py +++ b/symforce/codegen/codegen_config.py @@ -136,3 +136,13 @@ def format_eigen_lcm_accessor(key: str, i: int) -> str: Format accessor for eigen_lcm types. """ pass + + def update_template_data(self, data: T.Dict[str, T.Any]) -> None: + """ + Derived classes may override this to customize the "template data" dict. This dict + is passed to jinja at code-generation time. + + Args: + data: Dict passed by Codegen. The function should modify this in-place. + """ + pass