Skip to content

Commit

Permalink
fixed: spaces in path + "=" breaking builds on macOS (#52)
Browse files Browse the repository at this point in the history
* fixed: spaces in path + "=" breaking builds on macOS

* minor cleanup

* fixes #54

* can view stack trace on Julia error without breaking MATLAB process

* warnings can be turned off using warning off

* fixed a bug where warnings broke jl.m
  • Loading branch information
sg-s authored and twadleigh committed Jan 14, 2019
1 parent bc92f1a commit 79ba8b1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
*.mexw64
*.mexa64
*.mexmaci64
*.o
*.asv
*.pdp
*.mexw64.pdb
pathdef.m
jldict.mat
*DS_Store
26 changes: 20 additions & 6 deletions jl.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,24 @@
function varargout = mexn(nout, fn, varargin)
jl.check_initialized;
outputs = cell(nout+1, 1);
[outputs{:}] = mexjulia('jl_mex', fn, varargin{:});
varargout = outputs(2:end);
result = outputs{1};
if ~islogical(result)
throw(result);
try
[outputs{:}] = mexjulia('jl_mex', fn, varargin{:});
varargout = outputs(2:end);
result = outputs{1};
if ~islogical(result)
throw(result);
end
catch err
warning('Something went wrong')
warning(err.message)
warning('Stack trace follows:')
w = warning('query');
for i = 1:length(err.stack)
if ~strcmp(w(1).state,'off')
disp(err.stack(i))
end
end
varargout{1} = [];
end
end

Expand Down Expand Up @@ -229,7 +242,7 @@ function config(exe)
% set ldflags
ldflags = ['-L"' jl.get('lib_dir') '"'];
if ~ispc
ldflags = [ldflags ' -Wl,-rpath="' jl.get('lib_dir') '"'];
ldflags = [ldflags ' -Wl,-rpath "' jl.get('lib_dir') '"'];
end
jl.set('build_ldflags', ldflags);

Expand Down Expand Up @@ -283,6 +296,7 @@ function build()
else
mex_ptrn = 'mex LDFLAGS=''%s $LDFLAGS'' -v -largeArrayDims -outdir "%s" %s %s %s';
end
src = ['"' src '"'];
mex_cmd = sprintf(mex_ptrn, ldflags, jl.this_dir, cflags, src, ldlibs);
fprintf('The mex command to be executed:\n%s\n', mex_cmd);
eval(mex_cmd);
Expand Down

0 comments on commit 79ba8b1

Please sign in to comment.