Commit 615901b8 authored by Jay Dubb's avatar Jay Dubb
Browse files

-- Small improvements in build process

-- Fix unit test bug where log file is erased when UnitTestsAll_MainGUI is included
parent d48b4ca3
Loading
Loading
Loading
Loading

Install/Buildexe.m

0 → 100644
+114 −0
Original line number Diff line number Diff line
function Buildexe(appName, exclList, flags)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BuildExe allows building of the current directories project in 
% without having to change the output directory or update the .m 
% files list, every time (as seems to be the case with deploytool)
%
% Also it finds all the .m files under the current directory 
%

rootdir = filesepStandard(pwd);

% Args 
if ~exist('appName','var')
    [~, appName] = fileparts(rootdir);
end
rootdir = filesepStandard(fileparts(which(appName)));

if ~exist('exclList','var')
    exclList = {};
end
if ~exist('flags','var')
    flags = {};
end

% Matlab compiler generates a readme file that overwrites the app readme
% that already xists. Before we start build , move readme to temp file and 
% at end of build delete the newly generated readme and move the temp one 
% back. 
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
appDotMFilesStr = sprintf('-v %s', appDotMFileMain');

% Get all .m files which will go into making the app executable
appDotMFiles = findDotMFiles(rootdir, exclList);

% Create compile switches string
compileSwitches = '';
for ii = 1:length(flags)
    compileSwitches = [compileSwitches, flags{ii}, ' ']; %#ok<*AGROW>
end
compileSwitches = [compileSwitches, ' -w enable:specified_file_mismatch'];
compileSwitches = [compileSwitches, ' -w enable:repeated_file'];
compileSwitches = [compileSwitches, ' -w enable:switch_ignored'];
compileSwitches = [compileSwitches, ' -w enable:missing_lib_sentinel'];
compileSwitches = [compileSwitches, ' -w enable:demo_license'];

%%% Go through all the apps, contruct a string listing all the .m files 
%%% on which each app depends and then compile the app using mcc.


% Remove main m file and remove Buildme.m from app files list 
appDotMFiles = removeEntryFromList(appDotMFileMain, appDotMFiles);
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, '==================================:\n');
for jj=2:length(appDotMFiles)
    appDotMFilesStr = sprintf('%s -a ''%s''', appDotMFilesStr, appDotMFiles{jj});
    fprintf(fid, '%s\n', appDotMFiles{jj});
end
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);
disp(buildcmdstr);
eval(buildcmdstr);

% Delete useless readme generated by mcc and replace it with our own
% readme.txt that already exsisted
if ispathvalid('./README.txt', 'file')
    delete('./README.txt');
end
if ispathvalid('./TEMP.txt', 'file')
    movefile('TEMP.txt','./README.txt');
end




+28 −117
Original line number Diff line number Diff line
function Buildme(appName, inclList, exclList, flags)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Buildme allows building of the current directories project in 
% without having to change the output directory or update the .m 
% files list, every time (as seems to be the case with deploytool)
%
% Also it finds all the .m files under the current directory 
%

DEBUG = 1;

currDir = pwd;

% Args 
if ~exist('appName','var')
    [~, appName] = fileparts(currDir);
end
if ~exist('inclList','var')
    inclList = {};
end
if ~exist('exclList','var')
    exclList = {};
end
if ~exist('flags','var')
    flags = {};
end

% Matlab compiler generates a readme file that overwrites the app readme
% that already xists. Before we start build , move readme to temp file and 
% at end of build delete the newly generated readme and move the temp one 
% back. 
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);
    targetName = filesepStandard(sprintf('.%s%s.exe', filesep, appName), 'nameonly');
    
    % Check to make sure main .m file exists
    if ~ispathvalid(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%s', currDir, filesep, appDotMFileMain'));
function  Buildme(targetname)
if nargin==0
    targetname = 'Homer3';
end

    sanity = sanity-1;
    if sanity<=0
        return;
platform = setplatformparams();
currdir = pwd;
dirnameApp = ffpath('Homer3.m');
if exist(dirnameApp,'dir')
    cd(dirnameApp);
end

end
appDotMFilesStr = sprintf('-v %s', appDotMFileMain');

% Get all .m files which will go into making the app executable
appDotMFiles = findDotMFiles('.', exclList);
for ii = 1:length(inclList)
    appDotMFiles = [appDotMFiles, findDotMFiles(inclList{ii}, exclList)];
end

% Create compile switches string
compileSwitches = '';
for ii = 1:length(flags)
    compileSwitches = [compileSwitches, flags{ii}, ' '];
end
compileSwitches = [compileSwitches, ' -w enable:specified_file_mismatch'];
compileSwitches = [compileSwitches, ' -w enable:repeated_file'];
compileSwitches = [compileSwitches, ' -w enable:switch_ignored'];
compileSwitches = [compileSwitches, ' -w enable:missing_lib_sentinel'];
compileSwitches = [compileSwitches, ' -w enable:demo_license'];

%%% Go through all the apps, contruct a string listing all the .m files 
%%% on which each app depends and then compile the app using mcc.

exclLst = { ...
    '.git'; ...
    'Docs'; ...
    'UnitTests'; ...
    'Install'; ...
    'setpaths.m'; ...
    'getpaths.m'; ...
    };

% Remove main m file and remove Buildme.m from app files list 
appDotMFiles = removeEntryFromList(appDotMFileMain, appDotMFiles);
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, '==================================:\n');
for jj=2:length(appDotMFiles)
    appDotMFilesStr = sprintf('%s -a ''%s''', appDotMFilesStr, appDotMFiles{jj});
    fprintf(fid, '%s\n', appDotMFiles{jj});
Buildexe(targetname, exclLst)
for ii=1:length(platform.exename)
    if exist(['./',  platform.exename{ii}],'file')
        movefile(['./',  platform.exename{ii}], currdir);
    end
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, currDir, compileSwitches, appDotMFilesStr);
disp(buildcmdstr);
eval(buildcmdstr);

% Delete useless readme generated by mcc and replace it with our own
% readme.txt that already exsisted
if ispathvalid('./README.txt', 'file')
    delete('./README.txt');
end
if ispathvalid('./TEMP.txt', 'file')
    movefile('TEMP.txt','./README.txt');
if ispathvalid('./Buildme.log','file')
    movefile('./Buildme.log',currdir);
end




cd(currdir);

Install/Buildme_Homer3.m

deleted100644 → 0
+0 −19
Original line number Diff line number Diff line
function Buildme_Homer3(dirnameApp)
platform = setplatformparams();
currdir = pwd;
if ~exist('dirnameApp','var') | isempty(dirnameApp)
    dirnameApp = ffpath('Homer3.m');
end
if exist(dirnameApp,'dir')
    cd(dirnameApp);
end
Buildme('Homer3', {}, {'.git','setpaths.m','getpaths.m'});
for ii=1:length(platform.exename)
    if exist(['./',  platform.exename{ii}],'file')
        movefile(['./',  platform.exename{ii}], currdir);
    end
end
if ispathvalid('./Buildme.log','file')
    movefile('./Buildme.log',currdir);
end
cd(currdir);
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
function Buildme_Setup(dirnameInstall)
currdir = pwd;
if ~exist('dirnameInstall','var') | isempty(dirnameInstall)
    dirnameInstall = ffpath('Buildme_setup.m');
    dirnameInstall = ffpath('Buildme.m');
end
if exist(dirnameInstall,'dir')
    cd(dirnameInstall);
+1 −1
Original line number Diff line number Diff line
@@ -37,8 +37,8 @@ mkdir([dirnameInstall, 'homer3_install/SubjDataSample']);

% Generate executables
if ~strcmp(options, 'nobuild')
	Buildme();
	Buildme_Setup();
	Buildme_Homer3();
    if islinux()
        perl('./makesetup.pl','./run_setup.sh','./setup.sh');
    elseif ismac()
Loading