-% Copyright (C) 2013-2014 Czech Technical University in Prague
+% Copyright (C) 2013-2015 Czech Technical University in Prague
%
% Authors:
% - Carlos Jenkins <carlos@jenkins.co.cr>
% - Michal Sojka <sojkam1@fel.cvut.cz>
%
-% This document contains proprietary information belonging to Czech
-% Technical University in Prague. Passing on and copying of this
-% document, and communication of its contents is not permitted
-% without prior written authorization.
+% 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:
else
op = 'update';
end
-open('rpp_lib');
-set_param('rpp_lib', 'Lock', 'off');
-blocks = find_system('rpp_lib', 'Type', 'block');
+block_libs = rpp_get_blocks();
updated = 0;
-for i=1:length(blocks),
- block = blocks{i};
- params = get_param(block, 'ObjectParameters');
- fields = fieldnames(params);
-
- disp(['Processing ' blocks{i}]);
+for i=1:length(block_libs),
+ block_lib = block_libs{i};
+ last_updated = updated;
+ load_system(block_lib);
+ set_param(block_lib, 'Lock', 'off');
+ blocks = find_system(block_lib, 'Type', 'block');
+ for j=1:length(blocks),
+ block = blocks{j};
+ params = get_param(block, 'ObjectParameters');
+ fields = fieldnames(params);
- updated = updated + process_param(op, block, 'MaskType', '--masktype');
- updated = updated + process_param(op, block, 'MaskDescription', '--html --printdesc');
- updated = updated + process_param(op, block, 'MaskPromptString', '--maskpromptstring');
- updated = updated + process_param(op, block, 'MaskHelp', '--html --printhelp');
- updated = updated + process_param(op, block, 'Name', '--name'); % Name must be changed last!!!
+ disp(['Processing ' blocks{j}]);
+ updated = updated + process_param(op, block, 'MaskType', '--masktype');
+ updated = updated + process_param(op, block, 'MaskDescription', '--html --printdesc');
+ updated = updated + process_param(op, block, 'MaskPromptString', '--maskpromptstring');
+ updated = updated + process_param(op, block, 'MaskHelp', '--html --printhelp');
+ updated = updated + process_param(op, block, 'Name', '--name'); % Name must be changed last!!!
+ end
+ set_param(block_lib, 'Lock', 'on');
+ if strcmp(op, 'update') && updated ~= last_updated,
+ save_system(block_lib);
+ end
+ close_system(block_lib);
end
-set_param('rpp_lib', 'Lock', 'on');
function output = run_doc_parse(fn, opts)
% We have to unset Matlab's library path in order to run pandoc - it
throw(MException('rpp:pandoc_failure', ['Failed to extract doc from ' fn '.c']))
end
-function print_diff(fn, param, old, new)
+function print_diff(fn, param, old, new, diffopts)
fnold = [fn '.' param '.old'];
f = fopen(fnold, 'w');
fprintf(f, '%s', old);
fprintf(f, '%s', new);
fclose(f);
- [rc, diff] = system(['diff -u ' fnold ' ' fnnew]);
+ [rc, diff] = system(['git --no-pager diff --no-index ' diffopts ' --word-diff=plain ' fnold ' ' fnnew]);
disp(diff);
delete(fnold);
delete(fnnew);
if ~strcmp(old_content, new_content),
if strcmp(op, 'diff'),
disp([block ': ' param ' not up-to-date'])
- print_diff(fn, param, old_content, new_content)
+ print_diff(fn, param, old_content, new_content, '')
else
set_param(block, param, new_content)
+ print_diff(fn, param, old_content, new_content, '--no-color')
end
updated = 1;
else