-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
matlabBindings: add macos support #382
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
|
||
function build_installer() | ||
|
||
version = '23.1.1'; | ||
version = '24.2.2'; | ||
ml = ver('MATLAB'); | ||
ml = ml.Release(2:end-1); | ||
arch = computer('arch'); | ||
|
@@ -36,16 +36,26 @@ function build_installer() | |
if ispc | ||
win = 'true'; | ||
unix = 'false'; | ||
else | ||
mac = 'false'; | ||
|
||
elseif isunix | ||
win = 'false'; | ||
unix = 'true'; | ||
mac = 'false'; | ||
|
||
else | ||
win = 'false'; | ||
unix = 'false'; | ||
mac = 'true'; | ||
end | ||
f = strrep(f,'__PROJECT_ROOT__',p); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
f = strrep(f,'__REPO-ROOT__',p); | ||
f = strrep(f,'__VERSION__',version); | ||
f = strrep(f,'__ML-RELEASE__',ml); | ||
f = strrep(f,'__ARCH__',arch); | ||
f = strrep(f,'__LINUX__',unix); | ||
f = strrep(f,'__WINDOWS__',win); | ||
f = strrep(f,'__APPLE__',mac); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, the bsp.tmpl file needs to include macos in the platform tags. |
||
|
||
fid = fopen('bsp.prj','w'); | ||
fprintf(fid,'%s',f); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,69 +18,111 @@ | |
% along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
% | ||
|
||
clear all; clc; | ||
clear all; % clc; | ||
|
||
%% MATLAB API Builder | ||
% This script will build the basic template file for the MATLAB bindings | ||
% however since the library processor isn't perfect manual modifications | ||
% need to be done with the generated interface file | ||
|
||
includepath = fullfile(pwd, 'libm2k', 'include'); | ||
hppPath = fullfile(pwd, 'libm2k', 'include', 'libm2k'); | ||
|
||
%% | ||
% Full path to files in the library | ||
if isunix | ||
hppPath = fullfile('/usr','local','include','libm2k'); | ||
libs = fullfile('/usr','local','lib','libm2k.so'); | ||
myPkg = 'libm2k'; | ||
% check if we have an unix based system but not macos | ||
if isunix && not(ismac) | ||
% Full path to files in the library | ||
libs = fullfile(pwd, 'libm2k', 'libm2k.so'); | ||
myPkg = 'libm2k'; | ||
|
||
elseif ismac | ||
% on mac pc we need to specify the compiler | ||
mex -setup C++ | ||
libs = fullfile(pwd, 'libm2k', 'libm2k.dylib'); | ||
myPkg = 'libm2k'; | ||
|
||
elseif ispc | ||
% on windows pc we need to specify the compiler | ||
mex -setup C++ -v | ||
% Full path to files in the library | ||
libs = fullfile(pwd, 'libm2k', 'libm2k.lib'); | ||
myPkg = 'libm2k'; | ||
|
||
else | ||
error('Unix builds only tested so far'); | ||
error('Build did not find any recognized system'); | ||
end | ||
|
||
%% Add related headers | ||
h = {}; | ||
|
||
h1 = fullfile(hppPath,'m2kcalibration.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'m2kexceptions.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'logger.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'digital','genericdigital.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'digital','m2kdigital.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'analog','m2kanalogout.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'analog','m2kanalogin.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'m2kcalibration.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'analog','m2khardwaretrigger.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'analog','m2kpowersupply.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'analog','powersupply.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'utils','utils.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'utils','enums.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'contextbuilder.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'m2k.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'context.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'m2kglobal.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'digital','enums.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'analog','enums.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath,'enums.hpp'); h = [{h1},h(:)']; | ||
h1 = fullfile('/usr','include','iio.h'); h = [{h1},h(:)']; | ||
h1 = fullfile(hppPath, 'digital', 'm2kdigital.hpp'); h = [{h1}, h(:)']; | ||
h1 = fullfile(hppPath, 'digital', 'enums.hpp'); h = [{h1}, h(:)']; | ||
|
||
h1 = fullfile(hppPath, 'analog', 'm2kanalogout.hpp'); h = [{h1}, h(:)']; | ||
h1 = fullfile(hppPath, 'analog', 'm2kanalogin.hpp'); h = [{h1}, h(:)']; | ||
h1 = fullfile(hppPath, 'analog', 'm2kpowersupply.hpp'); h = [{h1}, h(:)']; | ||
h1 = fullfile(hppPath, 'analog', 'dmm.hpp'); h = [{h1}, h(:)']; | ||
h1 = fullfile(hppPath, 'analog', 'enums.hpp'); h = [{h1}, h(:)']; | ||
|
||
h1 = fullfile(hppPath, 'utils', 'utils.hpp'); h = [{h1}, h(:)']; | ||
h1 = fullfile(hppPath, 'utils', 'enums.hpp'); h = [{h1}, h(:)']; | ||
|
||
h1 = fullfile(hppPath, 'm2khardwaretrigger.hpp'); h = [{h1}, h(:)']; | ||
h1 = fullfile(hppPath, 'contextbuilder.hpp'); h = [{h1}, h(:)']; | ||
h1 = fullfile(hppPath, 'm2k.hpp'); h = [{h1}, h(:)']; | ||
h1 = fullfile(hppPath, 'm2kglobal.hpp'); h = [{h1}, h(:)']; | ||
h1 = fullfile(hppPath, 'context.hpp'); h = [{h1}, h(:)']; | ||
h1 = fullfile(hppPath, 'logger.hpp'); h = [{h1}, h(:)']; | ||
h1 = fullfile(hppPath, 'm2kcalibration.hpp'); h = [{h1}, h(:)']; | ||
h1 = fullfile(hppPath, 'm2kexceptions.hpp'); h = [{h1}, h(:)']; | ||
h1 = fullfile(hppPath, 'enums.hpp'); h = [{h1}, h(:)']; | ||
headers = h; | ||
|
||
%% Build interface file | ||
clibgen.generateLibraryDefinition(headers,... | ||
'IncludePath', hppPath,... | ||
'Libraries', libs,... | ||
'PackageName', myPkg,... | ||
'Verbose',true) | ||
delete definelibm2k.mlx | ||
|
||
%% Build library once manually updated | ||
% pkg = definelibm2k; | ||
% build(pkg); | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
% delete definelibm2k.m | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check if file exists, then delete to avoid warning |
||
|
||
if isunix && not(ismac) | ||
clibgen.generateLibraryDefinition(headers, ... | ||
'IncludePath', includepath, ... | ||
'Libraries', libs, ... | ||
'PackageName', myPkg, ... | ||
'Verbose', true) | ||
delete definelibm2k.mlx | ||
|
||
elseif ismac | ||
%% Add 'DefinedMacros' to fix bugs related to compiler versions used by matlab | ||
clibgen.generateLibraryDefinition(headers, ... | ||
'IncludePath', includepath, ... | ||
'Libraries', libs, ... | ||
'InterfaceName', myPkg, ... | ||
'Verbose', true, ... | ||
'DefinedMacros', ["_HAS_CONDITIONAL_EXPLICIT=0", "_USE_EXTENDED_LOCALES_"]) | ||
delete definelibm2k.mlx | ||
|
||
elseif ispc | ||
%% Add 'DefinedMacros' to fix builds using Visual Studio 16 2019 | ||
clibgen.generateLibraryDefinition(headers, ... | ||
'IncludePath', includepath, ... | ||
'Libraries', libs, ... | ||
'PackageName', myPkg, ... | ||
'Verbose', true, ... | ||
'DefinedMacros', ["_HAS_CONDITIONAL_EXPLICIT=0"]) | ||
delete definelibm2k.mlx | ||
end | ||
|
||
if isunix && not(ismac) | ||
pkg = definelibm2k_linux64; | ||
|
||
elseif ismac | ||
if strcmp(computer('arch'), 'maca64') | ||
pkg = definelibm2k_macM1; | ||
else | ||
pkg = definelibm2k_mac86; | ||
end | ||
|
||
elseif ispc | ||
pkg = definelibm2k_win64; | ||
end | ||
|
||
%% Build library once manually updated | ||
% build(pkg); |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current code will return true for both Linux and Mac, therefore the final
else
clause setting themac
flag will never be reached.