function initTMFTokens(lBuildInfo, varargin)
% INITTMFTOKENS initializes buildInfo TMF tokens

%   Copyright 2017-2019 The MathWorks, Inc.

% As optimization, use persistent variable for input parser
persistent p
if isempty(p)
    p = inputParser;
    addParameter(p, 'NumSt', '');
    addParameter(p, 'Tid01eq', '0'); % default for value Tid01eq must only be
                                     % used when NCStates==0, g1914961
    addParameter(p, 'NCStates', '0');
    addParameter(p, 'MemAlloc', '');
    addParameter(p, 'ClassicInterface', '0');
    addParameter(p, 'AllocFcn', '0');
    addParameter(p, 'GenerateSampleERTMain', '0');
    addParameter(p, 'CodeInterfacePackaging', '');
    addParameter(p, 'MultiTasking', '0');
    addParameter(p, 'ModelRefs', '');
    addParameter(p, 'TgtFcnLib', 'ISO_C');
    addParameter(p, 'InterleavedComplex', '');
    addParameter(p, 'TargetLangExt', '');
    addParameter(p, 'ModelName', '');
    addParameter(p, 'MakefileName', '');
    addParameter(p, 'MakefileBuilder', '0');
    addParameter(p, 'ModelRefSfcnSuffix', '');
    addParameter(p, 'UseSLExecSimBridge', '0');
    addParameter(p, 'RaccelParSet', struct('ParallelExecution', {'0'}, ...
                                           'NumThreads', {'1'}, ...
                                           'NumParNodes', {'0'}, ...
                                           'ParallelSimulatorType', {'0'}));
    addParameter(p, 'DynamicallyLoadedSFcns', '');
    addParameter(p, 'GlobalTiming', '0');
end
parse(p, varargin{:});


purifyMatlabBuild = '0';

toks = {
    '|>SOLVER<|',          '',    'makevar'
    '|>SOLVER_OBJ<|',      '',    'makevar'
    '|>SOLVER_TYPE<|',     '',    'buildOpts'
    '|>NUMST<|',           p.Results.NumSt,               'buildOpts'
    '|>TID01EQ<|',         p.Results.Tid01eq,             'buildOpts'
    '|>NCSTATES<|',        p.Results.NCStates,            'buildOpts'
    '|>MEM_ALLOC<|',       p.Results.MemAlloc,            'buildOpts'
    '|>CLASSIC_INTERFACE<|',  p.Results.ClassicInterface, 'GRTInterface_makevar'
    '|>GENERATE_ALLOC_FCN<|', p.Results.AllocFcn, ''
    '|>GEN_SAMPLE_MAIN<|',    p.Results.GenerateSampleERTMain, ''
    '|>CODE_INTERFACE_PACKAGING<|', p.Results.CodeInterfacePackaging, ''
    '|>COMPUTER<|',          computer, ''
    '|>MEXEXT<|',            mexext, ''
    '|>MULTITASKING<|',      p.Results.MultiTasking, ''
    '|>RELEASE_VERSION<|',   ['R' version('-release')], ''
    '|>PURIFY<|',            purifyMatlabBuild, ''
    '|>MODELREFS<|',         p.Results.ModelRefs, ''
    '|>TGT_FCN_LIB<|',       p.Results.TgtFcnLib, 'makevar'
    '|>TARGET_LANG_EXT<|',   p.Results.TargetLangExt, ''
    '|>MODEL_NAME<|',        p.Results.ModelName, ''
    '|>MAKEFILE_NAME<|',     p.Results.MakefileName, ''
    '|>INTERLEAVED_COMPLEX_FLAGS<|', p.Results.InterleavedComplex, ''
    '|>MAKEFILEBUILDER_TGT<|', p.Results.MakefileBuilder, ''
    '|>MODELREF_SFCN_SUFFIX<|', p.Results.ModelRefSfcnSuffix, ''
    '|>ENABLE_SLEXEC_SSBRIDGE<|', p.Results.UseSLExecSimBridge, ''
    ...
    ...% Rapid accelerator may need to dynamically load any s-functions
    '|>MODEL_HAS_DYNAMICALLY_LOADED_SFCNS<|', p.Results.DynamicallyLoadedSFcns, 'makevar'
    ...
    '|>GLOBAL_TIMING_ENGINE<|', p.Results.GlobalTiming, ''
};

% Add TMF tokens to buildInfo
tokNames = toks(:,1);
tokVals = toks(:,2);
tokGroups = toks(:,3);
lBuildInfo.addTMFTokens(tokNames,tokVals, tokGroups);

