Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DCT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
graintracking
DCT
Commits
a7347898
Commit
a7347898
authored
8 years ago
by
Nicola Vigano
Browse files
Options
Downloads
Patches
Plain Diff
Matlab functions compilation: improved error reporting
Signed-off-by:
Nicola Vigano
<
nicola.vigano@esrf.fr
>
parent
fb59015d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
zUtil_OAR/gtCompileFunctions.m
+27
-25
27 additions, 25 deletions
zUtil_OAR/gtCompileFunctions.m
zUtil_OAR/gtMcc.m
+28
-31
28 additions, 31 deletions
zUtil_OAR/gtMcc.m
with
55 additions
and
56 deletions
zUtil_OAR/gtCompileFunctions.m
+
27
−
25
View file @
a7347898
function gtCompileFunctions( force, mfiles, funcs_to_compile )
function gtCompileFunctions( force, mfiles, funcs_to_compile )
error_log = {};
wrong_names = {};
force = strcmp(force, 'force');
force = strcmp(force, 'force');
tot_keys = fieldnames(mfiles);
should_compile_all = isempty(funcs_to_compile) ...
if (isempty(funcs_to_compile) ...
|| (numel(funcs_to_compile) == 1
&&
strcmp(funcs_to_compile{1}, 'all'));
|| (numel(funcs_to_compile) == 1
&&
strcmp(funcs_to_compile{1}, 'all')) )
funcs_to_compile = tot_keys;
else
valid = true(numel(funcs_to_compile), 1);
for ii = 1:numel(funcs_to_compile)
if (~ismember(funcs_to_compile{ii}, tot_keys))
valid(ii) = false;
wrong_names(1, end+1) = funcs_to_compile(ii);
end
end
all_keys = fieldnames(mfiles);
if (should_compile_all)
wrong_names = {};
funcs_to_compile = all_keys;
else
valid = ismember(funcs_to_compile, all_keys);
wrong_names = funcs_to_compile(~valid);
funcs_to_compile = funcs_to_compile(valid);
funcs_to_compile = funcs_to_compile(valid);
end
end
funcs_to_compile = reshape(funcs_to_compile, [1 numel(funcs_to_compile)]);
funcs_to_compile = reshape(funcs_to_compile, [1 numel(funcs_to_compile)]);
num_funcs = numel(funcs_to_compile);
for funcName = funcs_to_compile
error_log = cell(num_funcs, 2);
disp(['Checking function: "' funcName{1} '":'])
for ii_f = 1:numel(funcs_to_compile)
func = mfiles.(funcName{1});
func_name = funcs_to_compile{ii_f};
disp(['Checking function: "' func_name '":'])
func = mfiles.(func_name);
mat_file_path = func.('in_mfile');
mat_file_path = func.('in_mfile');
comp_file_path = func.('out_file');
comp_file_path = func.('out_file');
[up
ToD
ate, msg] = gtCheckFunctionUpToDate(mat_file_path, comp_file_path);
[up
_to_d
ate, msg] = gtCheckFunctionUpToDate(mat_file_path, comp_file_path);
fprintf(msg);
fprintf(msg);
if (force || ~up
ToD
ate)
if (force || ~up
_to_d
ate)
disp(['Compiling function: ' func
N
ame
{1}
]);
disp(['Compiling function: ' func
_n
ame]);
comp_file_dir = fileparts(comp_file_path);
comp_file_dir = fileparts(comp_file_path);
try
try
gt
_m
cc(func
N
ame
{1}, 'out
_path', comp_file_dir)
gt
M
cc(func
_n
ame
, 'bin
_path', comp_file_dir)
catch mexc
catch mexc
error_log(
1, end+1
) = func
N
ame;
error_log(
ii_f, :
) =
{
func
_n
ame
, mexc}
;
end
end
end
end
end
end
for err_msg = error_log
errors = find(~isempty(error_log(:, 1)));
disp(['Error while compiling: ' err_msg{1}]);
for ii_e = 1:numel(errors)
func_name = error_log{errors(ii_e), 1};
mexc = error_log{errors(ii_e), 2};
gtPrintException(mexc, ...
sprintf('Could not compile function: %s', func_name))
end
end
for wr_name = wrong_names
for wr_name = wrong_names
disp(['Wrong m-file name: ' wr_name{1}]);
disp(['Wrong m-file name: ' wr_name{1}]);
end
end
...
...
This diff is collapsed.
Click to expand it.
zUtil_OAR/gt
_m
cc.m
→
zUtil_OAR/gt
M
cc.m
+
28
−
31
View file @
a7347898
function
gt
_m
cc
(
myfunctionname
,
varargin
)
function
gt
M
cc
(
myfunctionname
,
varargin
)
% gt_mcc.m Compiles an executable and puts it in the right place
% gt_mcc.m Compiles an executable and puts it in the right place
if
(
isempty
(
whos
(
'global'
,
'GT_MATLAB_HOME'
)))
if
(
isempty
(
whos
(
'global'
,
'GT_MATLAB_HOME'
)))
gtE
rror
(
'COMPILE:no_such_variable'
,
...
e
rror
(
'COMPILE:no_such_variable'
,
...
[
'GT_MATLAB_HOME variable doesn
''
t exist in global workspace, '
...
[
'GT_MATLAB_HOME variable doesn
''
t exist in global workspace, '
...
'your environment is not sane, and you need to either '
...
'your environment is not sane, and you need to either '
...
're-initialise or re-run matlab.'
])
're-initialise or re-run matlab.'
])
...
@@ -23,30 +23,24 @@ function gt_mcc(myfunctionname, varargin)
...
@@ -23,30 +23,24 @@ function gt_mcc(myfunctionname, varargin)
end
end
% Parsing arguments
% Parsing arguments
conf
=
[];
conf
=
struct
(
...
conf
.
not_really
=
false
;
'dry_run'
,
false
,
...
conf
.
out_path
=
''
;
'bin_path'
,
fullfile
(
GT_MATLAB_HOME
,
'bin'
,
'compiled'
),
...
conf
.
licence_warning
=
false
;
'
licence_warning
'
,
false
,
...
'remove_old'
,
false
);
conf
=
parse_pv_pairs
(
conf
,
varargin
);
conf
=
parse_pv_pairs
(
conf
,
varargin
);
if
(
isempty
(
conf
.
out_path
))
path_for_binaries
=
fullfile
(
GT_MATLAB_HOME
,
'bin'
,
'compiled'
);
else
path_for_binaries
=
conf
.
out_path
;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Modify the M name if necessary
% Modify the M name if necessary
[
~
,
~
,
ext
]
=
fileparts
(
myfunctionname
);
[
~
,
~
,
ext
]
=
fileparts
(
myfunctionname
);
if
~
strcmp
(
ext
,
'.m'
)
if
(
~
strcmp
(
ext
,
'.m'
)
)
myfunctionname
=
[
myfunctionname
'.m'
];
myfunctionname
=
[
myfunctionname
'.m'
];
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% check the code is visible at the moment
% check the code is visible at the moment
if
~
exist
(
myfunctionname
,
'file'
)
if
(
~
exist
(
myfunctionname
,
'file'
)
)
gtE
rror
(
'gt
_m
cc:wrong_file_name'
,
...
e
rror
(
'gt
M
cc:wrong_file_name'
,
...
'Cannot find your function - is it in the path?'
)
'Cannot find your function - is it in the path?'
)
end
end
...
@@ -55,7 +49,7 @@ function gt_mcc(myfunctionname, varargin)
...
@@ -55,7 +49,7 @@ function gt_mcc(myfunctionname, varargin)
globalVars
=
whos
(
'global'
);
globalVars
=
whos
(
'global'
);
eval
([
'global'
sprintf
(
' %s'
,
globalVars
.
(
'name'
))]);
eval
([
'global'
sprintf
(
' %s'
,
globalVars
.
(
'name'
))]);
if
(
isempty
(
whos
(
'global'
,
'GT_DB'
)))
if
(
isempty
(
whos
(
'global'
,
'GT_DB'
)))
gtE
rror
(
'
COMPILE
:no_such_variable'
,
...
e
rror
(
'
gtMcc
:no_such_variable'
,
...
[
'GT_DB variable doesn
''
t exist in global workspace, '
...
[
'GT_DB variable doesn
''
t exist in global workspace, '
...
'your environment is not sane, and you need to either '
...
'your environment is not sane, and you need to either '
...
're-initialise or re-run matlab.'
])
're-initialise or re-run matlab.'
])
...
@@ -65,27 +59,30 @@ function gt_mcc(myfunctionname, varargin)
...
@@ -65,27 +59,30 @@ function gt_mcc(myfunctionname, varargin)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% startup the compiler
% startup the compiler
disp
(
'Starting to compile - this may take a few minutes...'
);
disp
(
'Starting to compile - this may take a few minutes...'
);
disp
(
'- Removing previously compiled code'
);
if
(
conf
.
remove_old
)
compFile
=
fullfile
(
path_for_binaries
,
[
myfunctionname
(
1
:
end
-
2
)]);
fprintf
(
'- Removing previously compiled code..'
);
runFile
=
fullfile
(
path_for_binaries
,
[
'run_'
myfunctionname
(
1
:
end
-
1
)
'sh'
]);
compFile
=
fullfile
(
conf
.
bin_path
,
myfunctionname
(
1
:
end
-
2
));
filesToDelele
=
{
compFile
,
runFile
};
runFile
=
fullfile
(
conf
.
bin_path
,
[
'run_'
myfunctionname
(
1
:
end
-
1
)
'sh'
]);
for
fileToDelele
=
filesToDelele
filesToDelele
=
{
compFile
,
runFile
};
if
(
conf
.
not_really
)
for
fileToDelele
=
filesToDelele
disp
([
'I should now be deleting: '
fileToDelele
{
1
}]);
if
(
conf
.
dry_run
)
elseif
exist
(
fileToDelele
{
1
},
'file'
)
disp
([
'I should now be deleting: '
fileToDelele
{
1
}]);
delete
(
fileToDelele
{
1
});
elseif
exist
(
fileToDelele
{
1
},
'file'
)
delete
(
fileToDelele
{
1
});
end
end
end
fprintf
(
'\b\b: Done.\n'
)
end
end
disp
([
'- Placing
result
in '
path_for_binaries
]);
disp
([
'- Placing
binary
in
:
'
conf
.
bin_path
]);
if
(
conf
.
not_really
)
if
(
conf
.
dry_run
)
cmd
=
sprintf
(
'mcc -m "%s" -d "%s" -a workspaceGlobal.mat'
,
myfunctionname
,
path_for_binaries
);
cmd
=
sprintf
(
'mcc -m "%s" -d "%s" -a workspaceGlobal.mat'
,
myfunctionname
,
conf
.
bin_path
);
disp
([
'I should now be executing:
''
'
cmd
'
''
'
]);
disp
([
'I should now be executing:
''
'
cmd
'
''
'
]);
else
else
try
try
mcc
(
'-m'
,
myfunctionname
,
'-d'
,
path_for_binaries
,
'-a'
,
'workspaceGlobal.mat'
);
mcc
(
'-m'
,
myfunctionname
,
'-d'
,
conf
.
bin_path
,
'-a'
,
'workspaceGlobal.mat'
);
catch
mexc
catch
mexc
if
gtCheckExceptionType
(
mexc
,
'mcc_err_checkout_failed'
)
if
(
gtCheckExceptionType
(
mexc
,
'mcc_err_checkout_failed'
)
)
disp
(
'Could not get a compiler license.'
);
disp
(
'Could not get a compiler license.'
);
disp
(
'Surf to http://compweb/public/nice/matlab_licence.php'
);
disp
(
'Surf to http://compweb/public/nice/matlab_licence.php'
);
disp
(
'and call the person with the compiler license to see if you could use it!'
);
disp
(
'and call the person with the compiler license to see if you could use it!'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment