function [flags, groups] = getCompileFlags(buildInfo, incGroups, excGroups, ...
params)
% GETCOMPILEFLAGS The getCompileFlags function returns compiler options stored
% in the model's build information. Using optional includeGroups and
% excludeGroups arguments, you can selectively include or exclude groups of
% options the function returns.
%
% Argument description
% buildinfo Build information handle returned by RTW.Buildinfo.
%
% includeGroups (optional) A character array or cell array of character arrays
% that specifies groups of compiler flags you want the function
% to return.
%
% excludeGroups (optional) A character array or cell array of character arrays
% that specifies groups of compiler flags you do not want the
% function to return.
%
% Return values
% the function returns the compiler options stored in the model's build
% information.
%
% example 1:
% myModelBuildInfo = RTW.BuildInfo;
% addCompileFlags(myModelBuildInfo, {'-Zi -Wall' '-O3'},...
% {'Debug' 'MemOpt'});
% compflags=getCompileFlags(myModelBuildInfo);
%
% resulting values:
% compflags == {'-Zi -Wall' '-O3'}
%
% example 2:
% myModelBuildInfo = RTW.BuildInfo;
% addCompileFlags(myModelBuildInfo, {'-Zi -Wall' '-O3'}, {'Debug' 'MemOpt'});
% compflags=getCompileFlags(myModelBuildInfo, '', 'Debug');
%
% resulting values:
% compflags == {'-O3'}
%
% Please refer to the documentation for more information.
%

% Copyright 2005-2023 The MathWorks, Inc.

arguments
buildInfo
incGroups = string.empty;
excGroups = string.empty;
params.OnlyForSharedLibraryMerge = false;
params.SourceFile string {mustBeScalarOrEmpty} = string.empty;
end

[flags, ~, ~, groups] = buildInfo.Options.getOptions('CompileFlags', ...
incGroups, excGroups, ...
OnlyForSharedLibraryMerge=params.OnlyForSharedLibraryMerge, ...
SourceFileHandle=getSourceFileHandles(buildInfo, params.SourceFile));