Robochameleon  v1.0
compileMex.m
1 function compileMex(varargin)
2  if nargin > 0
3  roboRoot = varargin{1};
4  else
5  roboRoot = getpref('robochameleon','roboRootFolder','NULL');
6  if strcmp(roboRoot,'NULL')
7  error('A folder must be specified or "robochameleon" must be run before');
8  end
9  end
10  fileList = getAllFiles(roboRoot);
11  for i=1:length(fileList)
12  [~,~,ext] = fileparts(fileList{i});
13  if strcmp(ext, '.c') || strcmp(ext, '.cpp')
14  %Strip the root path from the current file for log purposes
15  tokens = regexp(fileList{i}, [roboRoot '(.*)'], 'tokens');
16  cfile = tokens{1};
17  robolog('Compiling %s', cfile{:});
18  %Perform the compilation. May fail if a compiler is missing, or external libraries are missing
19  try
20  mex(fileList{i});
21  catch ME
22  robolog('Failed compiling %s\nError is:\n%s', 'WRN', cfile{:}, ME.message);
23  end
24  end
25  end
26 end
function robolog(in msg, in varargin)
This function allows the user to print log messages in a standard way.
function robochameleon(in varargin)
Add robochameleon related directories to the MATLAB path.
function end(in obj, in k, in n)
Overload of indexing end statement.