VA_build.m.proto 2.05 KB
Newer Older
1
% THIS FILE WILL BE OVERWRITTEN BY CMAKE WITHOUT WARNING
2 3 4 5 6 7 8 9
%
% Code generator for the VA Matlab interface facade class
%
% Desc:     This script generates the code for the Matlab
%           facade class to the VAInterface MEXExtension.
%           It takes the class template code and inserts
%           all stubs for the functions in the VAConnector
%           interface. These are derived using the reflexion
10
%           mechanism ('enumerate_functions')
11
%
12

13 14 15 16
va_base_dir = '@VAMATLAB_BASE_DIR@'; % VA folder with bin, lib, matlab, data etc.
va_script_dir = fullfile( va_base_dir, 'matlab' ); % Matlab scripts target directory
va_bin_dir = fullfile( va_base_dir, 'bin' );
va_lib_dir = fullfile( va_base_dir, 'lib' );
17

18 19
if exist( va_bin_dir, 'dir' ) ~= 7
    error( 'Deploy dir ''%s'' does not exist. Please build and install VAMatlab first.', va_bin_dir )
20
end
21

22 23
if exist( va_script_dir, 'dir' ) ~= 7
   mkdir( va_script_dir );
24 25
end

Jonas Stienen's avatar
Jonas Stienen committed
26
if exist( [ 'VAMatlab' '.' mexext ], 'file' )
27 28
    warning( 'VAMatlab already found at location "%s", are you sure to build itaVA against this executable? Will proceed now.', which( 'VAMatlab' ) )
else
29
    % Add to PATH temporarily and attempt to move lib to bin dir
30
    addpath( va_script_dir, va_bin_dir )
31

32
    [ s ] = movefile( fullfile( va_lib_dir, 'VAMatlab*' ), va_bin_dir );
33
    if ~s && ~exist( [ 'VAMatlab' '.' mexext ], 'file' )
34
        error( 'Could not locate VAMatlab executable. Please make sure that it can be found.' )
35
    end
36
end
37 38

% Parameters
39
templateFile = 'itaVA.m.proto';
40
outputFile = fullfile( va_script_dir, 'itaVA.m' );
41 42 43

fprintf( 'Generating code for itaVA Matlab class ''%s'' ...\n', outputFile );
code = fileread( templateFile );
44
stubCode = itaVA_generateStubs();
45 46 47 48 49 50 51 52

code = strrep( code, '###STUBCODE###', stubCode );

% Write the results
fid = fopen( outputFile, 'w' );
fprintf( fid, '%s', code );
fclose( fid );

53
fprintf( 'Matlab class ''%s'' successfully built\n', outputFile );
54

55

56
% Remove from MATLABPATH (otherwise naming conflicts may occur with
57
% ITA-Toolbox/applications/VirtualAcoustics/VA/* scripts)
58
rmpath( va_script_dir, va_bin_dir )