Home > utility > mexCompile.m

mexCompile

PURPOSE ^

mexCompile: 對所有的 mex/dll 檔案進行必要的編譯

SYNOPSIS ^

function mexCompile(cFileList)

DESCRIPTION ^

 mexCompile: 對所有的 mex/dll 檔案進行必要的編譯

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mexCompile(cFileList)
0002 % mexCompile: 對所有的 mex/dll 檔案進行必要的編譯
0003 
0004 if nargin<1
0005     cFiles=dir('*.cpp');
0006     cFileList = {cFiles.name};
0007 end
0008 
0009 if strcmp(class(cFileList), 'char')
0010     cFileList={cFileList};
0011 end
0012 
0013 clear mex
0014 
0015 for i=1:length(cFileList),
0016     cFile = cFileList{i};
0017     [junk, main, junk, junk]=fileparts(cFileList{i});
0018     dllFile = [main, '.dll'];
0019     includedFiles = findinc(cFile);
0020     includedFiles = {includedFiles{:}, cFile};
0021     needCompile = 0;
0022     if isempty(dir(dllFile)),
0023         needCompile = 1;
0024     else    % Check dependency
0025         fileInfo = dir(dllFile);
0026 %        fprintf('dllFile=%s\n', dllFile);
0027 %        fprintf('size=%d\n', length(fileInfo));
0028 %        fprintf('fileInfo.date=%s\n', fileInfo.date);
0029         dllDate = datenum(c2emonth(fileInfo.date));
0030         for j=1:length(includedFiles),
0031             if exist(includedFiles{j}),
0032                 fileInfo = dir(includedFiles{j});
0033                 incDate = datenum(c2emonth(fileInfo.date));
0034                 if incDate>dllDate,
0035                     needCompile=1;
0036                     break;
0037                 end
0038             end
0039         end
0040     end
0041 
0042     if needCompile,
0043         fprintf('Compiling %s... ===> ', cFile);
0044         eval(['mex ', cFile]);
0045         currDir=pwd;                % D:\users\jang\matlab\toolbox\audio_mex
0046         targetDir=currDir(1:end-4);        % D:\users\jang\matlab\toolbox\audio
0047         copyfile(dllFile, targetDir);
0048         fprintf('Copied %s to %s directory.\n', dllFile, targetDir);
0049     else
0050         fprintf('No need to recompile "%s"\n', cFile);
0051     end
0052 end

Generated on Tue 01-Jun-2010 09:50:34 by m2html © 2003