diff --git a/bindings/matlab/build_library.m b/bindings/matlab/build_library.m index 1aa07db9..c169a4df 100644 --- a/bindings/matlab/build_library.m +++ b/bindings/matlab/build_library.m @@ -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'; + libs = fullfile(pwd, 'libm2k/windows', 'libm2k.lib'); + myPkg = 'libm2k_windows'; else error('Build did not find any recognized system'); @@ -78,51 +83,64 @@ 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 = 0; + +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_"]) + + if strcmp(computer('arch'), 'maca64') + delete definelibm2k_mac_arm64.mlx; + else + delete definelibm2k_mac_x86_64.mlx; + + end + + 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_windows.mlx end +else + %% Build library once manually updated + if isunix && not(ismac) + pkg = definelibm2k_linux; + + elseif ismac + if strcmp(computer('arch'), 'maca64') + pkg = definelibm2k_mac_arm64; + else + pkg = definelibm2k_mac_x86_64; + end + + elseif ispc + pkg = definelibm2k_windows; + end + + build(pkg); -elseif ispc - pkg = definelibm2k_win64; -end - -%% Build library once manually updated -% build(pkg); +end \ No newline at end of file