Skip to content
Snippets Groups Projects
Commit 9212fd9b authored by Mark Winter's avatar Mark Winter
Browse files

Updated LEVER compile script moving cpp compiler setup to utility function.

parent 98989e39
Branches
Tags
No related merge requests found
...@@ -41,7 +41,8 @@ function CompileLEVer(forceVersion) ...@@ -41,7 +41,8 @@ function CompileLEVer(forceVersion)
Dev.MakeSegHelp(); Dev.MakeSegHelp();
%% Setup visual studio for MEX compilation %% Setup visual studio for MEX compilation
[vsStruct,comparch] = setupCompileTools(); setenv('MATLAB_DIR', matlabroot());
[compStruct,comparch] = Dev.SetupCPPCompiler('vs2015');
bindir = '..\..\bin'; bindir = '..\..\bin';
if ( strcmpi(comparch,'win64') ) if ( strcmpi(comparch,'win64') )
...@@ -55,36 +56,37 @@ function CompileLEVer(forceVersion) ...@@ -55,36 +56,37 @@ function CompileLEVer(forceVersion)
%% Compile all MEX files %% Compile all MEX files
outputFiles = {}; outputFiles = {};
newOutput = compileMEX('mexMAT', vsStruct); newOutput = compileMEX('mexMAT', compStruct);
outputFiles = [outputFiles; {newOutput}]; outputFiles = [outputFiles; {newOutput}];
newOutput = compileMEX('Tracker', vsStruct); newOutput = compileMEX('Tracker', compStruct);
outputFiles = [outputFiles; {newOutput}]; outputFiles = [outputFiles; {newOutput}];
newOutput = compileMEX('mexDijkstra', vsStruct); newOutput = compileMEX('mexDijkstra', compStruct);
outputFiles = [outputFiles; {newOutput}]; outputFiles = [outputFiles; {newOutput}];
newOutput = compileMEX('mexGraph', vsStruct); newOutput = compileMEX('mexGraph', compStruct);
outputFiles = [outputFiles; {newOutput}]; outputFiles = [outputFiles; {newOutput}];
newOutput = compileMEX('mexIntegrityCheck', vsStruct); newOutput = compileMEX('mexIntegrityCheck', compStruct);
outputFiles = [outputFiles; {newOutput}]; outputFiles = [outputFiles; {newOutput}];
newOutput = compileMEX('mexHashData', vsStruct); newOutput = compileMEX('mexHashData', compStruct);
outputFiles = [outputFiles; {newOutput}]; outputFiles = [outputFiles; {newOutput}];
%% Compile LEVER, Segmentor, and batch LEVER_SegAndTrackFolders. %% Compile LEVER, Segmentor, and batch LEVER_SegAndTrackFolders.
javaDeps = initStruct.javaList; javaDeps = initStruct.javaList;
addFiles = {'LEVER_logo.tif'; '+Segmentation\FrameSegmentor_*.m'; '+Dev\GetVersion.m'; '+Dev\VersionInfo.m'};
addImgs = {'+UI\backFrame.png'; '+UI\forwardFrame.png'; '+UI\pause.png';'+UI\play.png';'+UI\stop.png'}; addImgs = {'+UI\backFrame.png'; '+UI\forwardFrame.png'; '+UI\pause.png';'+UI\play.png';'+UI\stop.png'};
newOutput = compileMATLAB('LEVer', bindir, [javaDeps;addImgs], initStruct.toolboxList);
newOutput = compileMATLAB('LEVer', bindir, [addFiles;javaDeps;addImgs], initStruct.toolboxList);
outputFiles = [outputFiles; {newOutput}]; outputFiles = [outputFiles; {newOutput}];
newOutput = compileMATLAB('LEVER_SegAndTrackFolders', bindir, javaDeps, initStruct.toolboxList); newOutput = compileMATLAB('LEVER_SegAndTrackFolders', bindir, [addFiles;javaDeps], initStruct.toolboxList);
outputFiles = [outputFiles; {newOutput}]; outputFiles = [outputFiles; {newOutput}];
newOutput = compileMATLAB('Segmentor', bindir, javaDeps, initStruct.toolboxList); newOutput = compileMATLAB('Segmentor', bindir, [addFiles;javaDeps], initStruct.toolboxList);
outputFiles = [outputFiles; {newOutput}]; outputFiles = [outputFiles; {newOutput}];
fprintf('\n'); fprintf('\n');
...@@ -101,57 +103,36 @@ function CompileLEVer(forceVersion) ...@@ -101,57 +103,36 @@ function CompileLEVer(forceVersion)
toc(totalTime) toc(totalTime)
end end
function [vsStruct,comparch] = setupCompileTools() function outputFile = compileMEX(projectName, compStruct)
vsStruct.vstoolroot = getenv('VS140COMNTOOLS');
if ( isempty(vsStruct.vstoolroot) )
error('Cannot compile MEX files without Visual Studio 2015');
end
setenv('MATLAB_DIR', matlabroot());
comparch = computer('arch');
if ( strcmpi(comparch,'win64') )
vsStruct.buildbits = '64';
vsStruct.buildenv = fullfile(vsStruct.vstoolroot,'..','..','vc','bin','amd64','vcvars64.bat');
vsStruct.buildplatform = 'x64';
else
error('Only windows 64-bit builds are currently supported');
end
system(['"' vsStruct.buildenv '"' ]);
clear mex;
end
function outputFile = compileMEX(projectName, vsStruct)
compileTime = tic(); compileTime = tic();
outputFile = [projectName '.mexw' vsStruct.buildbits]; outputFile = [projectName '.mexw' compStruct.buildbits];
fprintf('\nVisual Studio Compiling: %s...\n', outputFile); fprintf('\nVisual Studio Compiling: %s...\n', outputFile);
projectRoot = fullfile('..','c',projectName); projectRoot = fullfile('..','c',projectName);
result = system(['"' fullfile(vsStruct.vstoolroot,'..','IDE','devenv.com') '"' ' /build "Release|' vsStruct.buildplatform '" "' projectRoot '.sln"']); result = system(['"' fullfile(compStruct.toolroot,'..','IDE','devenv.com') '"' ' /build "Release|' compStruct.buildplatform '" "' projectRoot '.sln"']);
if ( result ~= 0 ) if ( result ~= 0 )
error([projectName ': MEX compile failed.']); error([projectName ': MEX compile failed.']);
end end
system(['copy ' fullfile(projectRoot, ['Release_' vsStruct.buildplatform], [projectName '.dll']) ' ' fullfile('.', [projectName '.mexw' vsStruct.buildbits])]); system(['copy ' fullfile(projectRoot, ['Release_' compStruct.buildplatform], [projectName '.dll']) ' ' fullfile('.', [projectName '.mexw' compStruct.buildbits])]);
fprintf('Done (%f sec)\n\n', toc(compileTime)); fprintf('Done (%f sec)\n\n', toc(compileTime));
end end
function outputFile = compileEXE(projectName, vsStruct, bindir) function outputFile = compileEXE(projectName, compStruct, bindir)
compileTime = tic(); compileTime = tic();
outputFile = [projectName '.exe']; outputFile = [projectName '.exe'];
fprintf('\nVisual Studio Compiling: %s...\n', outputFile); fprintf('\nVisual Studio Compiling: %s...\n', outputFile);
projectRoot = fullfile('..','c',projectName); projectRoot = fullfile('..','c',projectName);
result = system(['"' fullfile(vsStruct.vstoolroot,'..','IDE','devenv.com') '"' ' /build "Release|' vsStruct.buildplatform '" "' projectRoot '.sln"']); result = system(['"' fullfile(compStruct.vstoolroot,'..','IDE','devenv.com') '"' ' /build "Release|' compStruct.buildplatform '" "' projectRoot '.sln"']);
if ( result ~= 0 ) if ( result ~= 0 )
error([projectName ': EXE compile failed.']); error([projectName ': EXE compile failed.']);
end end
system(['copy ' fullfile(projectRoot, ['Release_' vsStruct.buildplatform], [projectName '.exe']) ' ' fullfile('.', [projectName '.exe'])]); system(['copy ' fullfile(projectRoot, ['Release_' compStruct.buildplatform], [projectName '.exe']) ' ' fullfile('.', [projectName '.exe'])]);
system(['copy ' fullfile(projectRoot, ['Release_' vsStruct.buildplatform], [projectName '.exe']) ' ' fullfile(bindir,'.')]); system(['copy ' fullfile(projectRoot, ['Release_' compStruct.buildplatform], [projectName '.exe']) ' ' fullfile(bindir,'.')]);
fprintf('Done (%f sec)\n\n', toc(compileTime)); fprintf('Done (%f sec)\n\n', toc(compileTime));
end end
...@@ -164,10 +145,6 @@ function outputFile = compileMATLAB(projectName, bindir, extrasList, toolboxList ...@@ -164,10 +145,6 @@ function outputFile = compileMATLAB(projectName, bindir, extrasList, toolboxList
if ( ~exist('extrasList','var') ) if ( ~exist('extrasList','var') )
extrasList = {}; extrasList = {};
end end
extrasList = vertcat({'LEVER_logo.tif';
'+Segmentation\FrameSegmentor_*.m';
'+Dev\GetVersion.m';
'+Dev\VersionInfo.m'}, extrasList);
extraCommand = ''; extraCommand = '';
if ( ~isempty(extrasList) ) if ( ~isempty(extrasList) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment