function addDefines(h, options, groups, params)
% ADDDEFINES - The addDefines function adds specified preprocessor macro
% definitions to the model's build information. Real-Time Workshop stores
% the definitions in a vector. The function adds definitions to the end of
% the vector based on the order in which you specify them.
%
% Argument    description
% buildinfo   Build information handle returned by RTW.Buildinfo.
% 
%    
% iddefs      A character array or cell array of character arrays that
%             specifies the preprocessor macro definitions to be added to
%             the object. The function adds each definition to the end of a
%             compiler option vector. If you specify multiple definitions
%             within a single character array, for example '-DRT -DDEBUG',
%             the function adds the string to the vector as a single
%             element. For example, if you add '-DPROTO -DDEBUG' and then
%             '-DPRODUCTION', the vector consists of two elements, as shown
%             below.
%                  {'-DPROTO -DDEBUG'    '-DPRODUCTION'}
%
% groups      (optional) A character array or cell array of character arrays
%             that groups specified definitions
%
% example 1:
%   myModelBuildInfo = RTW.BuildInfo;
%   addDefines(myModelBuildInfo, '-DPRODUCTION','Release');
%
% example 2:
%   myModelBuildInfo = RTW.BuildInfo;
%   addDefines(myModelBuildInfo,...
%              {'-DPROTO -DDEBUG' '-DPRODUCTION'},...
%              {'Debug' 'Release'});
%
%
% Please refer to the documentation for more information.
%

% Copyright 2005-2023 The MathWorks, Inc.

arguments
    h (1,1) RTW.BuildInfoBuildObj
    options
    groups = string.empty;
    params.SharedLibraryMerge = true;
    params.SourceFile string = string.empty; 
end

h.Options.addOptions('Defines', options, groups, ...
    SharedLibraryMerge=params.SharedLibraryMerge, ...
    SourceFileHandles=getSourceFileHandles(h, params.SourceFile));

