Commit e1f50ea9 authored by Jay Dubb's avatar Jay Dubb
Browse files

-- Fix build not working because need to copy ALL config files to installation folder

-- Improve launch performance by changing config file access to global variable
parent 277d8341
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
function userfuncdir = FindUserFuncDir(obj)
global cfg

cfg = InitConfig(cfg);

userfuncdir = {};
dirnameApp = getAppDir();

@@ -14,10 +18,9 @@ for ii = 1:length(dirs)
        continue
    elseif strcmp(dirs(ii).name, 'Archive')
        obj.config = struct('InclArchivedFunctions','');
        cfg = ConfigFileClass();
        obj.config.InclArchivedFunctions = cfg.GetValue('Include Archived User Functions');        
        if strcmp(obj.config.InclArchivedFunctions, 'Yes')
            userfuncdir{end+1} = fullpath([userfuncdir{1}, 'Archive/']);
            userfuncdir{end+1} = fullpath([userfuncdir{1}, 'Archive/']); %#ok<*AGROW>
        end
    else
        userfuncdir{end+1} = filesepStandard(fullpath([userfuncdir{1}, dirs(ii).name]));
+6 −3
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ function unitTest = Homer3(groupDirs, inputFileFormat, unitTest)
%

global logger
global cfg

setNamespace('Homer3');

@@ -44,9 +45,6 @@ if strcmp(cfg.GetValue('Logging'), 'off')
end
PrintSystemInfo(logger, 'Homer3');
checkForHomerUpdates();
for ii = 1:length(cfg.filenames)
    logger.Write(sprintf('Opened config file %s\n', cfg.filenames{ii}))
end
gdir = cfg.GetValue('Last Group Folder');
if isempty(gdir)
    if isdeployed()
@@ -59,7 +57,12 @@ try
catch ME
    % Clean up in case of error make sure all open file handles are closed 
    % so we don't leave the application in a bad state
    cfg.Close();
    printStack(ME);
    logger.Close();
    rethrow(ME);
end

logger.Close();

+7 −33
Original line number Diff line number Diff line
function Buildexe(appName, exclList, inclList, flags)
function Buildexe(appname, exclList, inclList, flags)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BuildExe allows building of the current directories project in 
@@ -11,8 +11,8 @@ function Buildexe(appName, exclList, inclList, flags)
rootdir = filesepStandard(pwd);

% Args 
if ~exist('appName','var')
    [~, appName] = fileparts(rootdir);
if ~exist('appname','var')
    [~, appname] = fileparts(rootdir);
end
if ~exist('exclList','var')
    exclList = {};
@@ -24,7 +24,7 @@ if ~exist('flags','var')
    flags = {};
end

rootdir = filesepStandard(fileparts(which(appName)));
rootdir = filesepStandard(fileparts(which(appname)));


% Matlab compiler generates a readme file that overwrites the app readme
@@ -35,33 +35,7 @@ if ispathvalid('./README.txt', 'file')
    movefile('./README.txt', 'TEMP.txt');
end

% Find main .m file
appDotMFilesStr = '';
sanity = 100;
while ~ispathvalid(appDotMFilesStr, 'file')
    
    appDotMFileMain = sprintf('%s.m', appName);
    
    % Check to make sure main .m file exists
    if ~ispathvalid([rootdir, appDotMFileMain], 'file')
        q = menu(sprintf('Could not find the main application file %s.m. Please locate the main application file.', appName), 'OK');
        [filenm, pathnm] = uigetfile({'*.m'}, 'Select main .m file');
        if filenm==0
            return;
        end
        [~, appName] = fileparts(filenm);
        appDotMFileMain = [pathnm, filenm];
        appDotMFilesStr = appDotMFileMain;
    else
        appDotMFilesStr = filesepStandard(sprintf('%s%s', rootdir, appDotMFileMain'));
    end
    
    sanity = sanity-1;
    if sanity<=0
        return;
    end
   
end
appDotMFileMain = [appname, '.m'];
appDotMFilesStr = sprintf('-v %s', appDotMFileMain');

% Get all .m files which will go into making the app executable
@@ -91,7 +65,7 @@ appDotMFiles = removeEntryFromList('Buildme.m', appDotMFiles);
% Construct files list portion of build command
fid = fopen('./Buildme.log','w');
fprintf(fid, '==================================:\n');
fprintf(fid, 'Building %s from these files:\n', appName);
fprintf(fid, 'Building %s from these files:\n', appname);
fprintf(fid, '==================================:\n');
for jj = 2:length(appDotMFiles)
    appDotMFilesStr = sprintf('%s -a ''%s''', appDotMFilesStr, appDotMFiles{jj});
@@ -101,7 +75,7 @@ fprintf(fid, '\n\n');
fclose(fid);

% Complete the final build command and execute it
buildcmdstr = sprintf('mcc -o %s -W main:%s -T link:exe -d ''%s'' %s %s', appName, appName, rootdir, compileSwitches, appDotMFilesStr);
buildcmdstr = sprintf('mcc -o %s -W main:%s -T link:exe -d ''%s'' %s %s', appname, appname, rootdir, compileSwitches, appDotMFilesStr);
disp(buildcmdstr);
eval(buildcmdstr);

+0 −1
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@ exclLst = {
    'submodules';
    'Data';
    'setpaths.m';
    'getpaths.m';
    };

Buildexe(appname, exclLst)
+20 −0
Original line number Diff line number Diff line
@@ -92,6 +92,19 @@ for ii=1:length(platform.createshort_script)
    end
end

dirnameSrc = filesepStandard(fileparts(which([exename, '.m'])));
cfg = ConfigFileClass();
for ii = 1:length(cfg.filenames)
    p = filesepStandard(fileparts(cfg.filenames{ii}));
    k = strfind(p, dirnameSrc);
    pathRelative = p(k+length(dirnameSrc):end);
    fprintf('Copying  %s  to  %s\n', cfg.filenames{ii}, [dirnameInstall, installfilename, '/', pathRelative]);
    if ~ispathvalid([dirnameInstall, installfilename, '/', pathRelative])
        mkdir([dirnameInstall, installfilename, '/', pathRelative])
    end
    copyfile(cfg.filenames{ii}, [dirnameInstall, installfilename, '/', pathRelative]);
end

if exist([dirnameApp, 'AppSettings.cfg'],'file')
    copyfile([dirnameApp, 'AppSettings.cfg'], [dirnameInstall, installfilename]);
end
@@ -120,6 +133,11 @@ if ispathvalid([dirnameInstall, 'uninstall.bat'])
    copyfile([dirnameInstall, 'uninstall.bat'], [dirnameInstall, installfilename, '/uninstall.bat']);
end

if exist([dirnameApp, 'SDGcolors.csv'],'file')
    copyfile([dirnameApp, 'SDGcolors.csv'], [dirnameInstall, installfilename]);
end


% Zip it all up into a single installation file
zip([dirnameInstall, installfilename, '.zip'], [dirnameInstall, installfilename]);

@@ -129,3 +147,5 @@ fclose all;
cleanup(dirnameInstall, dirnameApp);



Loading