VA_build_absolute.m 2.06 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

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
13
va_base_dir = 'D:/Users/stienen/dev/VA/dist/win32-x64.vc14'; % VA folder with bin, lib, matlab, data etc.
14 15 16
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
    warning( 'VAMatlab already found at location "%s", are you sure to build VA against this executable? Will proceed now.', which( 'VAMatlab' ) )
28
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 40
templateFile = 'VA.m.proto';
outputFile = fullfile( va_script_dir, 'VA.m' );
41

42
fprintf( 'Generating code for VA Matlab class ''%s'' ...\n', outputFile );
43
code = fileread( templateFile );
44
stubCode = VA_generate_stubs();
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 )