%% Build Script
% This script will build the mcode for the Rankine Excel demo.
%
% This demo shows Excel deployment of MATLAB using Builder for
% Excel. See the included readme.doc for more information.
%
% The bulk of the demo is written in Excel and referenced
% in the Visual Studio project. The example MATLAB code
% used, "rankine.m," was created my Mike Agostini.
%
% David Forstot
% Copyright 2006-2010 The MathWorks, Inc.
%
% This code is provided as an example only.
%% Determine path names
workdir = pwd();
basedir = fileparts(workdir);
outdir = fullfile(basedir, 'Output');
builddir = fullfile(workdir, 'rankine_addin');
%% Determine file names
mfile_rankine = fullfile(workdir, 'rankine.m');
mfile_steam = fullfile(workdir, 'XSteam.m' );
addinbas = fullfile(builddir, 'rankine_addin.bas');
addindll = fullfile(builddir, 'rankine_addin_1_0.dll');
%% Verify mfiles can be found
if (exist(mfile_rankine, 'file') ~= 2)
error('Unable to find mfile rankine.m');
end
if (exist(mfile_steam, 'file') ~= 2)
error('Unable to find mfile XSteam.m');
end
%% Create directories if needed
if (exist(outdir, 'dir') ~= 7)
mkdir(outdir);
end
if (exist(builddir, 'dir') ~= 7)
mkdir(builddir);
end
%% Build Excel AddIn
disp('Compiling Excel AddIn...');
eval(['mcc -d ' builddir ' -W ''excel:rankine_addin,' ...
'rankine_addin_class,1.0'' -T link:lib -b ' mfile_rankine]);
% verify assembly was created
if ( (exist(addinbas, 'file') ~= 2) || ...
(exist(addindll, 'file') ~= 2) )
error('Failed to successfully compile Excel AddIn.');
else
fprintf('\tDone\n');
end
%% Copy .NET Assembly to Output
Copy1 = copyfile(addinbas, fullfile(outdir, 'rankine_addin.bas'));
Copy2 = copyfile(addindll, fullfile(outdir, 'rankine_addin_1_0.dll'));
if ( (Copy1 ~= 1) || (Copy2 ~= 1) )
error('Unable to copy Excel AddIn to output directory.');
end
%% Clean up
clear Copy1 Copy2 sbasedir builddir addinbas ...
mfile_rankine mfile_steam outdir workdir addindll basedir;