function [buildDir] = getBuildDirForSolverChange(modelName)
% Copyright 2021 The MathWorks, Inc.

simMode = get_param( modelName, 'SimulationMode' );

if simMode=="accelerator"
    folders = Simulink.filegen.internal.FolderConfiguration(modelName);
    buildDir = folders.Accelerator.absolutePath('ModelCode');
else % for raccel. As there are only two cases here, accel or raccel
    % Based on the solution in:
    % matlab/toolbox/simulink/core/general/+Simulink/+packagedmodel/getRapidAccelBuildDir.m
    fileGenCfg = Simulink.fileGenControl('getConfig');
    buildDir = fullfile(fileGenCfg.CacheFolder, 'slprj', 'raccel', modelName);
end

end