Commit 632d5c53 authored by Jay Dubb's avatar Jay Dubb
Browse files

-- Improve reporting of errors in build process

parent b36a7d08
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -16,9 +16,9 @@ dirnameInstall = pwd;
cd(dirnameApp);

Buildme('Homer3', {}, {'.git'});
for ii=1:length(platform.homer3_exe)
    if exist(['./',  platform.homer3_exe{ii}],'file')
        movefile(['./',  platform.homer3_exe{ii}], dirnameInstall);
for ii=1:length(platform.exename)
    if exist(['./',  platform.exename{ii}],'file')
        movefile(['./',  platform.exename{ii}], dirnameInstall);
    end
end

+5 −5
Original line number Diff line number Diff line
@@ -23,11 +23,11 @@ end
if exist([dirnameInstall, 'homer3_install'],'dir')
    rmdir_safe([dirnameInstall, 'homer3_install']);
end
for ii=1:length(platform.homer3_exe(1))
    if exist([dirnameInstall, platform.homer3_exe{ii}],'file')==2
        delete([dirnameInstall, platform.homer3_exe{ii}]);
    elseif exist([dirnameInstall, platform.homer3_exe{ii}],'dir')==7
        rmdir_safe([dirnameInstall, platform.homer3_exe{ii}]);
for ii=1:length(platform.exename(1))
    if exist([dirnameInstall, platform.exename{ii}],'file')==2
        delete([dirnameInstall, platform.exename{ii}]);
    elseif exist([dirnameInstall, platform.exename{ii}],'dir')==7
        rmdir_safe([dirnameInstall, platform.exename{ii}]);
    end
end

+3 −3
Original line number Diff line number Diff line
@@ -62,9 +62,9 @@ end
dirnameDb2DotMat = findWaveletDb2([dirnameInstall, 'homer3_install/']);

% Copy files to installation package folder
for ii=1:length(platform.homer3_exe)
    if exist([dirnameInstall, platform.homer3_exe{ii}],'file')
        copyfile([dirnameInstall, platform.homer3_exe{ii}], [dirnameInstall, 'homer3_install/', platform.homer3_exe{ii}]);
for ii=1:length(platform.exename)
    if exist([dirnameInstall, platform.exename{ii}],'file')
        copyfile([dirnameInstall, platform.exename{ii}], [dirnameInstall, 'homer3_install/', platform.exename{ii}]);
    end
end
if exist([dirnameInstall, platform.setup_script],'file')==2
+39 −25
Original line number Diff line number Diff line
@@ -19,12 +19,17 @@ end


% ---------------------------------------------------------------------------
function msgFailure(errnum)
function setError(errcode)
global stats
stats.err = bitor(stats.err, 2^errcode);

handles = stats.handles;

stats.err = errnum;

% ---------------------------------------------------------------------------
function msgFailure()
global stats

handles = stats.handles;

msgFail{1}    = sprintf('Homer3 failed to install properly. Error code %d', stats.err);
msgFail{2}    = 'Contact jdubb@bu.edu for help with installation.';
@@ -37,9 +42,11 @@ set(hGui, 'name','Installation Error:');
set(hMsgFinished,'string', msgFail{1});
set(hMsgMoreInfo,'string', msgFail{2});

if ~isempty(dir([stats.dirnameApp, '.finished']))
    fd = fopen([stats.dirnameApp, '.finished'], 'w');
    fprintf(fd, '%d', stats.err);
    fclose(fd);    
end



@@ -58,10 +65,6 @@ elseif ismac()
    msgSuccess{2} = 'To run: Click on the Homer3.command icon on your Desktop to launch one of these applications';
end

hGui         = handles.this;
hMsgFinished = handles.msgFinished;
hMsgMoreInfo = handles.msgMoreInfo;

set(handles.this, 'name','SUCCESS:');
set(handles.msgFinished,'string', msgSuccess{1}, 'fontsize',14);
set(handles.msgMoreInfo,'string', msgSuccess{2}, 'fontsize',14);
@@ -71,6 +74,8 @@ fprintf(fd, '%d', stats.err);
fclose(fd);




% ---------------------------------------------------------------------------
function finishInstallGUI_OpeningFcn(hObject, eventdata, handles, varargin)
global stats
@@ -84,44 +89,51 @@ stats.handles.msgFinished = handles.textFinished;
stats.handles.msgMoreInfo = handles.textMoreInfo;
stats.dirnameApp = getAppDir('isdeployed');
stats.pushbuttonOKPress = false;
stats.Homer3_exe_flag = false;

fprintf('FinishInstallGUI_OpeningFcn: dirnameApp = %s\n', stats.dirnameApp);

% Error checks
platform = setplatformparams();

errcode = 1;

if stats.dirnameApp==0
    msgFailure(1);
    setError(errcode); 
end
errcode = errcode+1;

if isempty(stats.dirnameApp)
    msgFailure(2);
    setError(errcode); 
end
errcode = errcode+1;

files = dir([stats.dirnameApp, '/*']);
files = dir([stats.dirnameApp, '*']);
if isempty(files)
    msgFailure(3);
    setError(errcode); 
end
errcode = errcode+1;

for ii=1:length(files)
    [~, fname] = fileparts(files(ii).name);
    if strcmp(fname, 'Homer3')
        stats.Homer3_exe_flag = true;
        break;
for ii = 1:length(platform.exename)
    if ~exist([stats.dirnameApp, platform.exename{ii}], 'file')
        setError(errcode);
    end
    errcode = errcode+1;
end

if stats.Homer3_exe_flag==false
    msgFailure(4);
if ~exist(platform.exenameDesktopPath, 'file')
    setError(errcode); 
end


% Decide which message to display success or failure
if stats.err==0
    msgSuccess();
else
    msgFailure();
end





% ---------------------------------------------------------------------------
function varargout = finishInstallGUI_OutputFcn(hObject, eventdata, handles) 
global stats
@@ -129,6 +141,8 @@ global stats
varargout{1} = stats.err;




% ---------------------------------------------------------------------------
function pushbuttonOK_Callback(hObject, eventdata, handles)
global stats
+31 −0
Original line number Diff line number Diff line
function desktopPath = generateDesktopPath(dirnameSrc)
if ~exist('dirnameSrc','var')
    dirnameSrc = filesepStandard(pwd);
end

if ispc()
    if ~exist([dirnameSrc, 'desktopPath.txt'],'file')
        system(sprintf('call "%sgenerateDesktopPath.bat"', dirnameSrc));
    end
    
    if exist([dirnameSrc, 'desktopPath.txt'],'file')
        fid = fopen([dirnameSrc, 'desktopPath.txt'],'rt');
        line = fgetl(fid);
        line(line=='"')='';
        desktopPath = strtrim(line);
        fclose(fid);
    else
        desktopPath = sprintf('%%userprofile%%');
    end    
else
    desktopPath = fullpath('~/Desktop');
end
try
    fprintf('Desktop path:  %s\n', desktopPath);
    desktopPath = filesepStandard(desktopPath); 
    desktopPath = desktopPath(1:end-1);
catch
    fprintf('ERROR: Desktop path not found\n');
    desktopPath = '';
end
Loading