Skip to content

Commit ecf58a9

Browse files
authored
Include _part*.c files to the list of source files for the FMU Makefile (#8836)
- Make sure any generated `_part*.c` files for big models are listed in the list of source files in the generated Makefile for FMU code. - The modelDescription.xml file does not list these files yet. Unfortunately: - We do not know how many of them there are until we have called `CodegenFMU.translateModel.` - Which means the list of source files passed to `CodegenFMU.translateModel` does not include these extra `_part.c` files. It only lists the default ones. - Which means they are not listed in the modelDescription.xml file. The way to fix that is to separate the generation of `modelDescrition.xml` from `CodegenFMU.translateModel`. However, `modelDescrition.xml` wants to use the same GUID as the model code. Which means the `transateModel` call should make its created GUID available outside of it. We can not simply return the GUID from it (?) so there needs to be some more restructuring needed. However, `modelDescrition.xml` at the moment does does not list all the extra files anyway. So for now we leave it like this and make sure the makefile gets them properly at least. - Fixes #8805 and improves #8641.
1 parent b1fc5c8 commit ecf58a9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

OMCompiler/Compiler/SimCode/SimCodeMain.mo

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,6 @@ algorithm
875875
System.writeFile(fmutmp+"/sources/isfmi" + (if FMUVersion=="1.0" then "1" else "2"), "");
876876

877877
model_gen_files := list(simCode.fileNamePrefix + f for f in RuntimeSources.defaultFileSuffixes);
878-
model_all_gen_files := listAppend(model_gen_files, SimCodeUtil.getFunctionIndex());
879878

880879
// I need to see some tests failing or something not working to make sense of what to add here
881880
shared_source_files := List.flatten({RuntimeSources.simrt_c_sources,
@@ -890,11 +889,22 @@ algorithm
890889
if not Flags.getConfigBool(Flags.FMI_SOURCES) or Flags.getConfigEnum(Flags.FMI_FILTER) == Flags.FMI_BLACKBOX then
891890
model_desc_src_files := {}; // set the sourceFiles to empty, to remove the sources in modeldescription.xml
892891
else
893-
model_desc_src_files := listAppend(model_all_gen_files, shared_source_files);
892+
model_desc_src_files := listAppend(model_gen_files, shared_source_files);
894893
end if;
895894

896895
Tpl.tplNoret(function CodegenFMU.translateModel(in_a_FMUVersion=FMUVersion, in_a_FMUType=FMUType, in_a_sourceFiles=model_desc_src_files), simCode);
897896

897+
// Add the _part*.c files to the list of source files. We do not know how many of them there are until
898+
// we have called CodegenFMU.translateModel. Which means the list of source files passed to
899+
// CodegenFMU.translateModel above does not include them. Which means they are not listed in the
900+
// modelDescription.xml file. The way to fix that is to separate the generation of modelDescrition.xml
901+
// from CodegenFMU.translateModel. However, modelDescrition.xml wants to use the same GUID as the model code.
902+
// Which means the transateModel call should make its created GUID available outside of it. We can not simply
903+
// return the GUID from it (?) so there needs to be some more restructure needed. However, modelDescrition.xml
904+
// at the moment does does not list all the extra files anyway. So for now we leave it like this and make sure
905+
// the makefile gets them properly at least.
906+
model_all_gen_files := listAppend(model_gen_files, SimCodeUtil.getFunctionIndex());
907+
898908
// Copy CMakeLists.txt.in and replace @FMU_NAME_IN@ with fmu name
899909
System.copyFile(source = install_share_buildproject_dir + "CMakeLists.txt.in",
900910
destination = fmu_tmp_sources_dir + "CMakeLists.txt");

0 commit comments

Comments
 (0)