function [buildResult, mainObjFolder] = make_rtw(buildArgs, buildCommandArgs)
% MAKE_RTW Executes the Simulink Coder Build procedure for a block diagram.
%
% This function is called only for legacy workflows where MakeCommand
% is not set to the default "make_rtw". In a typical legacy workflow, 
% MakeCommand is set, for example, to make_rtw_custom and make_rtw_custom
% performs some extra work before or after calling make_rtw.
%
% This is an internal use only function and should not be called directly.

% Copyright 1994-2020 The MathWorks, Inc.

arguments
    buildArgs (1,1) coder.build.internal.BuildArgs
    buildCommandArgs char
end

% Build args might be prefixed with "mdl:modelName"
mdlPrefix = 'mdl:';

if startsWith(buildCommandArgs, mdlPrefix)
    [lModelName, buildCommandArgsRemainder] = strtok(buildCommandArgs);
    lModelName = lModelName(1+length(mdlPrefix):end);
else
    lModelName = bdroot;
    buildCommandArgsRemainder = buildCommandArgs;
end


[buildResult, mainObjFolder] = coder.internal.ModelBuilder.make_rtw...
    (buildArgs, lModelName, 'BuildCmdArgs', strtrim(buildCommandArgsRemainder));
