Clear Filters
Clear Filters

Access to Source files List called by Model by Embedded Coder?

13 views (last 30 days)
Hi,
We have a whole library of C functions that are called in my main Simulink model using S-function blocks.
I'd like to find a way to know which files are being used when I generate the C code with Embedded Coder so I can copy the source files to my build directory with a script automatically. I know this is possible, I can see a "modelsources.txt" file in my ../code/Model_target/ directory and I can also see the info in buildInfo.mat (the buildOpts.Modules field). Those files are generated by Embedded Coder, but I can't see how.
Currently this files contains 2-3 of the C files that are being used, but I don't know which file I need to modify to include them all.
I thought it would be in the .tlc file with %<SLibAddToStaticSources("xxx.c")> but this isn't it.
Thanks!

Answers (1)

Aishwarya Shukla
Aishwarya Shukla on 2 May 2023
To automatically copy the necessary source files to your build directory, you can use the "Include files" option in the "Code Generation" pane of your Simulink model.
First, select "Code Generation" from the "Model Settings" menu. In the "Code Generation" pane, scroll down to the "Custom Code" section and expand it. Then, select "Include files" from the list of options.
In the "Include files" field, you can specify a list of file names or wildcard patterns that should be included in the build process. For example, if all your C functions are in a directory called "my_functions", you can add "my_functions/*.c" to the "Include files" field.
When you generate code using Embedded Coder, it will automatically include any files specified in the "Include files" field in the generated code. You can also specify additional directories to search for included files using the "Additional include directories" field in the "Code Generation" pane.
Note that if you have multiple S-Function blocks in your Simulink model that use different sets of C functions, you may need to create separate "Include files" entries for each set of functions.

Categories

Find more on Simulink Coder in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!