From 4e53b9818a5496dfd7d5f8864a9006a376e3f744 Mon Sep 17 00:00:00 2001 From: Henrik Wahlqvist Date: Fri, 4 Oct 2024 10:16:10 +0200 Subject: [PATCH] Add option for supplying custom init function name Note that this only applies to the runnable in the generated yaml file. Change-Id: I4f6ac188bcfdeddddb390b9627b7cbddcd6456ad --- powertrain_build/build_proj_config.py | 4 ++++ powertrain_build/zone_controller/composition_yaml.py | 4 +++- tests/zone_controller/test_composition_yaml.py | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/powertrain_build/build_proj_config.py b/powertrain_build/build_proj_config.py index c0a3f54..6b8b24f 100644 --- a/powertrain_build/build_proj_config.py +++ b/powertrain_build/build_proj_config.py @@ -263,6 +263,10 @@ class BuildProjConfig: """Return the relative composition arxml path.""" return self._prj_cfg['ProjectInfo']['compositionArxml'] + def get_custom_yaml_init_function_name(self): + """Return the custom yaml init function name.""" + return self._prj_cfg['ProjectInfo'].get('customYamlInitFunctionName') + def get_gen_ext_impl_type(self): """Return the generate external implementation type.""" return self._prj_cfg['ProjectInfo'].get('generateExternalImplementationType', True) diff --git a/powertrain_build/zone_controller/composition_yaml.py b/powertrain_build/zone_controller/composition_yaml.py index a5a80ef..6817e25 100644 --- a/powertrain_build/zone_controller/composition_yaml.py +++ b/powertrain_build/zone_controller/composition_yaml.py @@ -357,7 +357,9 @@ class CompositionYaml(ProblemLogger): swc_name = self.build_cfg.get_swc_name() autosar_prefix = "AR_" swc_prefix = self.build_cfg.get_scheduler_prefix() - init_function = autosar_prefix + swc_prefix + "VcExtINI" + custom_init_function = self.build_cfg.get_custom_yaml_init_function_name() + standard_init_function = autosar_prefix + swc_prefix + "VcExtINI" + init_function = custom_init_function if custom_init_function is not None else standard_init_function calibration_variables = list(self.cal_class_info["autosar"]["class_info"].keys()) swc_content = {init_function: {"type": "INIT", "accesses": calibration_variables}} diff --git a/tests/zone_controller/test_composition_yaml.py b/tests/zone_controller/test_composition_yaml.py index 2cd45f3..2355658 100644 --- a/tests/zone_controller/test_composition_yaml.py +++ b/tests/zone_controller/test_composition_yaml.py @@ -51,6 +51,7 @@ class TestCompositionYaml(unittest.TestCase): self.build_cfg.get_swc_name = MagicMock(return_value="testName_SC") self.build_cfg.get_swc_template = MagicMock(return_value="ARTCSC") self.build_cfg.get_swc_base = MagicMock(return_value="QM") + self.build_cfg.get_custom_yaml_init_function_name = MagicMock(return_value=None) self.build_cfg.get_gen_ext_impl_type = MagicMock(return_value=True) self.build_cfg.get_code_generation_config = MagicMock(return_value=False)