Skip to content

Commit

Permalink
matlabBindings: update interface generation
Browse files Browse the repository at this point in the history
Signed-off-by: IonutMuthi <ionut.muthi@analog.com>
  • Loading branch information
IonutMuthi committed Feb 7, 2025
1 parent 6e52211 commit 96a0f8e
Showing 1 changed file with 61 additions and 49 deletions.
110 changes: 61 additions & 49 deletions bindings/matlab/build_library.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,26 @@
% 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';
libs = fullfile(pwd, 'libm2k/linux', 'libm2k.so');
myPkg = 'libm2k_linux';

elseif ismac
% on mac pc we need to specify the compiler
mex -setup C++
libs = fullfile(pwd, 'libm2k', 'libm2k.dylib');
myPkg = 'libm2k';
if strcmp(system('arch'), 'arma64')
libs = fullfile(pwd, 'libm2k/mac_arm64', 'libm2k.dylib');
myPkg = 'libm2k_mac_arm64';
else
libs = fullfile(pwd, 'libm2k/mac_x86_64', 'libm2k.dylib');
myPkg = 'libm2k_mac_x86_64';
end

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';
myPkg = 'libm2k_windows';

else
error('Build did not find any recognized system');
Expand Down Expand Up @@ -78,51 +83,58 @@
h1 = fullfile(hppPath, 'enums.hpp'); h = [{h1}, h(:)'];
headers = h;

%% Build interface file
% delete definelibm2k.m

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;
% first run this variable is 1 after you manually update the define file
% set it to 0
isBuildInterface = 1;

if isBuildInterface
%% Build interface file
if isunix && not(ismac)
% delete definelibm2k_linux.m
clibgen.generateLibraryDefinition(headers, ...
'IncludePath', includepath, ...
'Libraries', libs, ...
'PackageName', myPkg, ...
'Verbose', true)
delete definelibm2k_linux.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
else
%% Build library once manually updated
if isunix && not(ismac)
pkg = definelibm2k_linux;

elseif ismac
if strcmp(computer('arch'), 'maca64')
pkg = definelibm2k_macM1;
else
pkg = definelibm2k_mac86;
end

elseif ispc
pkg = definelibm2k_win64;
end

build(pkg);

elseif ispc
pkg = definelibm2k_win64;
end

%% Build library once manually updated
% build(pkg);

0 comments on commit 96a0f8e

Please sign in to comment.