function simulinkrc
% Master startup MATLAB function for Simulink
%
% Automatically executed by the dispatcher when libmwsimulink.dll is
% loaded into memory.  Checks some aspects of the installation, loads
% user preferences, and runs customizations.
%
% Also executes any function called "startupsl" that is found on
% the MATLAB path.

%   Copyright 1984-2020 The MathWorks, Inc.
    
performance.productStats.logEventTime('SLStartup','simulinkrcBegin');
if usejava('desktop')
    desktopframe = com.mathworks.mlservices.MatlabDesktopServices.getDesktop.getMainFrame;
    if ~isempty(desktopframe)
        if (license('test', 'Simulink'))
            msg = message('Simulink:Commands:StartingSimulink');
            javaMethodEDT('setStatusText',desktopframe,msg.getString);
        else
            % If there is no simulink license the only reason we are
            % allowed to load simulink is to get SFINML Set now message
            msg = '';
            javaMethodEDT('setStatusText',desktopframe,msg);
        end
        restore_status = onCleanup(@() javaMethodEDT('setStatusText',desktopframe,[]));
    end
end

% Warn if the OS does not have the libraries required to use Simulink
if strcmp(computer('arch'), 'glnxa64')
    missingLibraries = matlab.internal.webwindow.findMissingLibraries();
    if ~isempty(missingLibraries)
        warning(message('Simulink:utility:SimulinkMissingLibraries', sprintf('\t%s\n', missingLibraries)));
    end
end

% Load Simulink Preferences 
try %#ok<TRYNC>
    slinstallprefs;
end

% Execute startupsl MATLAB script for Simulink, if it exists.
startup_exists = exist('startupsl','file');
if startup_exists == 2 || startup_exists == 6
  evalin('base','startupsl')
end

% Customization manager
performance.productStats.logEventTime('SLStartup','slCustomizerBegin');
slCustomizer.staticRefresh();
performance.productStats.logEventTime('SLStartup','slCustomizerEnd');
performance.productStats.logEventTime('SLStartup','simulinkrcEnd');

% Trigger MLInitialize_sl_block_graphics(g2337699)
DVG.Registry.isIconRegistered("icon");

end
