]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/blobdiff - rpp/blocks/compile_blocks.m
Change license to MIT
[jenkicar/rpp-simulink.git] / rpp / blocks / compile_blocks.m
index 8d509b173da99178ee979e715a854200bdce5fd3..c90a0f42d410d00872414b27f2b1096b94bfb00a 100644 (file)
@@ -1,20 +1,28 @@
-% Copyright (C) 2013 Czech Technical University in Prague
+% Copyright (C) 2013-2014 Czech Technical University in Prague
 %
 % Authors:
 %     - Carlos Jenkins <carlos@jenkins.co.cr>
 %
-% This program is free software; you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation; either version 2 of the License, or
-% (at your option) any later version.
-%
-% This program is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with this program.  If not, see <http://www.gnu.org/licenses/>.
+% Permission is hereby granted, free of charge, to any person
+% obtaining a copy of this software and associated documentation
+% files (the "Software"), to deal in the Software without
+% restriction, including without limitation the rights to use,
+% copy, modify, merge, publish, distribute, sublicense, and/or sell
+% copies of the Software, and to permit persons to whom the
+% Software is furnished to do so, subject to the following
+% conditions:
+
+% The above copyright notice and this permission notice shall be
+% included in all copies or substantial portions of the Software.
+
+% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+% HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+% OTHER DEALINGS IN THE SOFTWARE.
 %
 % File : compile_blocks.m
 % Abstract:
@@ -37,14 +45,29 @@ function compile_blocks()
     %           arguments are considered. Prints each compile step and final
     %           link step fully evaluated.
     % options = '-v -g';
-    options = ' ';
-    mex = fullfile(matlabroot(), 'bin', 'mex');
+    options = '';
+    matlabRootPath=strcat('"',matlabroot(),'"');
+    mex = fullfile(matlabRootPath, 'bin', 'mex');
+
     sources = dir('sfunction_*.c');
 
     for i = sources'
-        command = [mex, ' ', options, i.name];
+        local_opts = options;
+        if strcmp(i.name, 'sfunction_canreceive.c') || ...
+           strcmp(i.name, 'sfunction_cantransmit.c'),
+            local_opts = [local_opts ' ' ...
+                '-I' matlabRootPath '/toolbox/shared/can/src/scanutil ' ...
+               '-I' matlabRootPath '/toolbox/rtw/targets/common/can/datatypes ' ...
+                matlabRootPath '/toolbox/rtw/targets/common/can/datatypes/sfun_can_util.c '...
+                matlabRootPath '/toolbox/rtw/targets/common/can/datatypes/can_msg.c'];
+        end
+        command = [mex ' ' i.name ' ' local_opts];
         disp(command);
-        system(command);
+        [status, result] = system(command);
+        if status ~= 0,
+            disp(result)
+            throw(MException('rpp:compile_block_failure', [i.name, ' failed to compile']))
+        end
     end
 
 end