Simplify function for getting the path to MEX files

This function could optionally modify the path, but that possibility was never
used.
kalman-mex
Sébastien Villemot 2023-09-27 13:24:14 +02:00
parent 432fd2d1b1
commit befe645728
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
3 changed files with 9 additions and 38 deletions

View File

@ -1,6 +1,6 @@
function check_matlab_path(change_path_flag)
% Copyright © 2015-2017 Dynare Team
% Copyright © 2015-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -92,7 +92,7 @@ else
% => If DYNARE_PATH/qz is in the path while mjdgges dll is available
% it most likely means that user wrongly put all subfolders in the
% matlab's path!
mexpath = add_path_to_mex_files([DYNARE_PATH filesep], false);
mexpath = get_path_to_mex_files([DYNARE_PATH filesep]);
MATLAB_PATH = path2cell(MATLAB_PATH);
for i=1:length(mexpath)
if exist([mexpath{i} filesep 'mjdgges.' mexext],'file') && ismember([DYNARE_PATH filesep 'qz'],MATLAB_PATH)
@ -143,4 +143,4 @@ directory_indicator=cell2mat(dir_result(4,:));
dlist = dir_result(1,directory_indicator==1 & ~strcmp('.',dir_result(1,:)) & ~strcmp('..',dir_result(1,:)) & ~ismember(dir_result(1,:),excluded_directories));
function n = position(i, currentpath)
n = length(strfind(currentpath(1:i), pathsep));
n = length(strfind(currentpath(1:i), pathsep));

View File

@ -16,7 +16,7 @@ function dynareroot = dynare_config(path_to_dynare)
% SPECIAL REQUIREMENTS
% none
% Copyright © 2001-2021 Dynare Team
% Copyright © 2001-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -125,7 +125,7 @@ end
P = cellfun(@(c)[dynareroot(1:end-1) c], p, 'uni',false);
% Get mex files folder(s)
mexpaths = add_path_to_mex_files(dynareroot, false);
mexpaths = get_path_to_mex_files(dynareroot);
% Add mex files folder(s)
P(end+1:end+length(mexpaths)) = mexpaths;

View File

@ -1,4 +1,6 @@
function mexpath = add_path_to_mex_files(dynareroot, modifypath)
function mexpath = get_path_to_mex_files(dynareroot)
% Returns a cell array containing one or several directory paths
% which should contain the MEX files.
% Copyright © 2015-2023 Dynare Team
%
@ -17,17 +19,10 @@ function mexpath = add_path_to_mex_files(dynareroot, modifypath)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if nargin<2
modifypath = true;
end
build_dir = get_build_dir(dynareroot);
if ~isempty(build_dir)
% If a Meson build directory is found, use it preferably
mexpath = { build_dir };
if modifypath
addpath(build_dir)
end
elseif isoctave
% Add specific paths for Dynare Windows package
if ispc
@ -37,21 +32,15 @@ elseif isoctave
tmp = [dynareroot '../mex/octave/win64/'];
if exist(tmp, 'dir')
mexpath = tmp;
if modifypath
addpath(mexpath);
end
end
end
end
% Add generic MATLAB path (with higher priority than the previous ones)
% Add generic Octave path (with higher priority than the previous ones)
if exist('mexpath')
mexpath = { mexpath; [dynareroot '../mex/octave/'] };
else
mexpath = { [dynareroot '../mex/octave/'] };
end
if modifypath
addpath([dynareroot '../mex/octave/']);
end
else
if strcmp(computer, 'PCWIN')
warning('MEX files not available for 32-bit MATLAB')
@ -62,17 +51,11 @@ else
tmp = [dynareroot '../mex/matlab/win64-8.3-9.3/'];
if exist(tmp, 'dir')
mexpath = tmp;
if modifypath
addpath(mexpath);
end
end
else
tmp = [dynareroot '../mex/matlab/win64-9.4-23.2/'];
if exist(tmp, 'dir')
mexpath = tmp;
if modifypath
addpath(mexpath);
end
end
end
end
@ -82,17 +65,11 @@ else
tmp = [dynareroot '../mex/matlab/maci64-8.3-9.3/'];
if exist(tmp, 'dir')
mexpath = tmp;
if modifypath
addpath(mexpath);
end
end
else
tmp = [dynareroot '../mex/matlab/maci64-9.4-23.2/'];
if exist(tmp, 'dir')
mexpath = tmp;
if modifypath
addpath(mexpath);
end
end
end
end
@ -100,9 +77,6 @@ else
tmp = [dynareroot '../mex/matlab/maca64-23.2/'];
if exist(tmp, 'dir')
mexpath = tmp;
if modifypath
addpath(mexpath);
end
end
end
% Add generic MATLAB path (with higher priority than the previous ones)
@ -111,7 +85,4 @@ else
else
mexpath = { [dynareroot '../mex/matlab/'] };
end
if modifypath
addpath([dynareroot '../mex/matlab/']);
end
end