MATLAB: How to get the compiler’s directory from a subsystem without “CompilerDir” property, while performing the build process

buildingcompilationcustomcustomizationdeploygetprefsetsimulink codertargettlc

I have a make hook script that runs to link several parts of a model together. I need my external program to know what is the compiler directory's path. I normally use get_param(gcs,'CompilerDr'), but this model has many subsystems, and sometimes gcs will latch to a subsystem instead of the top level model. Subsystems don't have this property, therefore the make hook fails.
What alternatives are there to get "CompilerDir"?

Best Answer

If you are using the following command:
get_param(gcs, 'CompilerDir');
In a make hook for a model with several subsystems, your make hook will fail.
There is an alternative, which is to get the information about the compiler from the given arguments:
buildArgs = args.buildInfo.BuildArgs;
compilerObj = buildArgs.findobj('Group', 'BUILD_ARG', 'Key', 'COMPILER_DIR');
compilerDir = erase(compilerObj.Value, '"');
This will resolve the issues in the make hook.