- https://www.mathworks.com/help/releases/R2025a/simulink/slref/slbuild.html
- https://www.mathworks.com/help/releases/R2025a/rtw/ug/customizing-post-code-generation-build-processing.html
I cannot use the Pre Build configuration to run scripts.
7 views (last 30 days)
Show older comments
Hello everyone.
I have Matlab 2025a with the Embedded Coder toolbox installed and the MinGW toolchain set up. My problem is that in the Model Settings > Code Generation > Custom Code section I can't find the Pre or Post Building option to trigger scripts. Another method that didn't work is in the startup file, where in Post Build I can use: set_param(model, 'PostCodeGenCommand', myScript); but the set_param(model, 'PreCodeGenCommand', myScript); does not work. Do you have any other suggestions? My goal is to press the Build button and run the Pre Build script -> Build -> and so on.......
Thank you in advance.
0 Comments
Accepted Answer
Adarsh
on 4 Jun 2025
I understand that you are searching for an option to run two scripts, one before the start of build process and other after completion of build process.
In MATLAB you can set the “Post Code Generation Command” to run any script after code generation but no method exists for “Pre Code Generation”.
To access the “Post Code Generation Command” option click on “Model Settings” and then select “Code Generation” and select “Advanced Parameters” to find the “Post Code Generation Command”.
You can also do this programmatically by following the process in the documentation link below:
Alternatively, you can create a custom script in which, “Pre Build” command is executed and then “slbuild” is executed for model build process and then “Post Build” command is executed as shown in the example below:
disp('Running pre-build tasks...');
myPreBuildScript;
disp('Building model...');
slbuild('myModel');
disp('Running post-build tasks...');
myPostBuildScript;
For more customization, a custom build hook file can be used as shown in the documentation link below:
For more information, the following documentation links can be referred:
I hope this helps.
More Answers (0)
See Also
Categories
Find more on Generated Code Compilation 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!