diff --git a/dct_launch.py b/dct_launch.py index df3c42001306eb71c44e2003f337c33ac1a1cce2..d169b5603863cbb445fbae5400246f8778e6bab6 100755 --- a/dct_launch.py +++ b/dct_launch.py @@ -59,6 +59,7 @@ class DCTLauncher(object): raise ValueError("Not recognized command: %s" % self.command) def _launchMatlab(self): + from zUtil_Python.dct_compile_matlab_functions import FunctionsBuilder if os.path.exists(self.confPath) is False: raise SystemError("File conf.xml not found in DCT directory") @@ -69,6 +70,10 @@ class DCTLauncher(object): else: invoker = dct.dct_matlab_invocation.DCTMatlabInvocation(dct_dir = self.dct_dir, \ extra_args = self.args) + + func_builder = FunctionsBuilder.getInstanceFromArgs([], dct_dir = self.dct_dir) + func_builder.generateMfile() + invoker.invoke() def _launchUpdate(self): diff --git a/initialise_gt.m b/initialise_gt.m index 4f7188ddc2626858e0f9197cac47e0e59ccb4da4..48c9ee36d69276276ac10171f5780976b47149e2 100644 --- a/initialise_gt.m +++ b/initialise_gt.m @@ -214,6 +214,30 @@ function initialise_gt(ignore_id19) 'Couldn''t find matlab version in conf.xml'); end - disp('Finished adding.') + disp('Finished adding.'); + + disp('Checking compiled functions...'); + currentDir = pwd; + cd(fullfile(GT_MATLAB_HOME, 'bin', 'scripts')); + mFiles = compile(false, false); + funcNames = fieldnames(mFiles); + + defaultColor = sprintf(gtGetANSIColour()); + yellowColor = sprintf(gtGetANSIColour('yellow')); + for funcName = reshape(funcNames, [1 numel(funcNames)]) + func = mFiles.(funcName{1}); + + mat_file_path = func.('in_mfile'); + comp_file_path = func.('out_file'); + [upToDate, msg] = gtCheckFunctionUpToDate(mat_file_path, comp_file_path); + if (~upToDate) + out = [yellowColor 'Function should be recompiled: ' ... + defaultColor funcName{1}]; + disp(out); + fprintf(msg); + end + end + cd(currentDir); + disp('Finished checking.'); end diff --git a/zUtil_OAR/gtCheckFunctionUpToDate.m b/zUtil_OAR/gtCheckFunctionUpToDate.m index 846350e981488e45b77f6928bad106aa77008a26..73d37cc6ff8280c57d1d60ffbdf04f18bd3790a4 100644 --- a/zUtil_OAR/gtCheckFunctionUpToDate.m +++ b/zUtil_OAR/gtCheckFunctionUpToDate.m @@ -1,10 +1,6 @@ -function isUpToDate = gtCheckFunctionUpToDate(funcName, outputBinary, verbose) +function [isUpToDate, msg] = gtCheckFunctionUpToDate(funcName, outputBinary) % GTCHECKFUNCTIONUPTODATE Checks if a compiled function is up to date. - if (~exist('verbose', 'var')) - verbose = true; - end - srcFileInfo = dir(funcName); if (isempty(srcFileInfo)) error('CHECK:wrong_function_path', ... @@ -14,19 +10,23 @@ function isUpToDate = gtCheckFunctionUpToDate(funcName, outputBinary, verbose) binFileInfo = dir(outputBinary); if (~isempty(binFileInfo)) if (srcFileInfo(1).datenum > binFileInfo(1).datenum) - if (verbose), fprintf(' + Binary is outdated.\n'); end + msg = sprintf(' + Binary is outdated.\n'); isUpToDate = false; else deps = gtGetFunctionDeps({funcName}, {}, 'matlab_(\d*)(.?)/toolbox'); depsToRebuild = gtCheckFunctionsTimestamp(deps, binFileInfo(1).datenum); isUpToDate = isempty(depsToRebuild); - if (~isUpToDate && verbose) - cellfun(@(x)fprintf(' + "%s" was modified after it.\n', x), ... + + if (~isUpToDate) + msg = cellfun(@(x){sprintf(' + "%s" was modified after it.\n', x)}, ... depsToRebuild); + msg = [msg{:}]; + else + msg = sprintf('* Is up to date.\n'); end end else - if (verbose), fprintf(' + Binary doesn''t exist.\n'); end + msg = sprintf(' + Binary doesn''t exist.\n'); isUpToDate = false; end end diff --git a/zUtil_OAR/gtCompileFunctions.m b/zUtil_OAR/gtCompileFunctions.m index 3cbb2b37905c1600b741039f11f5d6ddd722801f..c147a8aa1e4f2f49065793073919af6effd0cac7 100644 --- a/zUtil_OAR/gtCompileFunctions.m +++ b/zUtil_OAR/gtCompileFunctions.m @@ -28,22 +28,22 @@ function gtCompileFunctions( force, mfiles, funcs_to_compile ) mat_file_path = func.('in_mfile'); comp_file_path = func.('out_file'); - if (force || ~gtCheckFunctionUpToDate(mat_file_path, comp_file_path)) - disp('Compiling..') + [upToDate, msg] = gtCheckFunctionUpToDate(mat_file_path, comp_file_path); + disp(msg); + if (force || ~upToDate) + disp('Compiling...'); comp_file_dir = fileparts(comp_file_path); if (~gt_mcc(funcName{1}, 'out_path', comp_file_dir)) error_log(1, end+1) = funcName; end - else - disp('* Is up to date.') end end for err_msg = error_log - disp(['Error while compiling: ' err_msg{1}]) + disp(['Error while compiling: ' err_msg{1}]); end for wr_name = wrong_names - disp(['Wrong m-file name: ' wr_name{1}]) + disp(['Wrong m-file name: ' wr_name{1}]); end end diff --git a/zUtil_Python/dct_compile_matlab_functions.py b/zUtil_Python/dct_compile_matlab_functions.py index 965a36aee20c539452565ab021ed837fadc56ddb..1f1e226db806e5016d561fb08be017abdfe8ed98 100755 --- a/zUtil_Python/dct_compile_matlab_functions.py +++ b/zUtil_Python/dct_compile_matlab_functions.py @@ -109,7 +109,7 @@ class FunctionsBuilder(object): searchPatterns = [ ] for method in FunctionsBuilder.submitMethods: regexpString = '[^%]*\s*' + method + "\s*\(\s*'.*'" - print('Regular expression: "' + regexpString + '"') + #print('Regular expression: "' + regexpString + '"') regexp = re.compile(regexpString) searchPatterns.append(regexp) @@ -175,7 +175,7 @@ class FunctionsBuilder(object): os.makedirs(self.script_dir) DCTOutput.printSubJob("Generating m-file that will compile those Functions..") - script_content = [ "function compile(force, varargin)\n\n", + script_content = [ "function varargout = compile(force, doCompile, varargin)\n\n", "mfiles = [];\n" ] for func in self.compile_records: out_file = self.compile_records[func][0] @@ -183,7 +183,8 @@ class FunctionsBuilder(object): script_content.append("mfiles.('%s') = struct( ...\n" % func) script_content.append(" 'out_file', '%s', ...\n" % out_file) script_content.append(" 'in_mfile', '%s' );\n" % in_mfile) - script_content.append("\ngtCompileFunctions(force, mfiles, varargin)\nend\n") + script_content.append("\nif (nargout > 0)\n varargout{1} = mfiles;\nend\n") + script_content.append("\nif (doCompile)\n gtCompileFunctions(force, mfiles, varargin)\nend\n\nend % end of function\n") script_loc = os.path.join(self.script_dir, 'compile.m') DCTOutput.printSubJob("Writing '%s' script to disk.." % script_loc) @@ -205,7 +206,7 @@ class FunctionsBuilder(object): compile_args = "'no-force" compile_args = "','".join([compile_args] + self.mfiles_to_consider) + "'" - cmd = "compile(%s);quit;" % compile_args + cmd = "compile(%s,true);quit;" % compile_args invoker = dct_matlab_invocation.DCTMatlabInvocation(dct_dir = self.dct_dir, \ work_dir = self.script_dir, \