I cannot use the Pre Build configuration to run scripts.

10 visualizaciones (últimos 30 días)
Luca
Luca el 29 de Mayo de 2025
Comentada: Luca el 6 de Jun. de 2025
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.

Respuesta aceptada

Adarsh
Adarsh el 4 de Jun. de 2025
Hi @Luca,
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.
  1 comentario
Luca
Luca el 6 de Jun. de 2025
Understood, I will follow your advice using the script you suggested; at the moment, I don't see any other alternatives. Thank you. Best regards.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Generated Code Compilation en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by