Skip to content

Commit

Permalink
Add support for Mac OS on Apple silicon (64-bit ARM; mexmaca64).
Browse files Browse the repository at this point in the history
This change includes the MySQL client library from MySQL 8.4.0 LTS.

Possible fix for issues datajoint#99 and datajoint#100.
  • Loading branch information
cnuahs committed May 13, 2024
1 parent c4b67cb commit b895cf5
Show file tree
Hide file tree
Showing 45 changed files with 15,875 additions and 3 deletions.
Binary file removed distribution/mexa64/dialog.so
Binary file not shown.
1 change: 0 additions & 1 deletion distribution/mexa64/libmysqlclient.so

This file was deleted.

1 change: 0 additions & 1 deletion distribution/mexa64/libmysqlclient.so.18

This file was deleted.

1 change: 0 additions & 1 deletion distribution/mexa64/libz.so.1

This file was deleted.

Binary file removed distribution/mexa64/libz.so.1.2.3
Binary file not shown.
Binary file removed distribution/mexa64/mym.mexa64
Binary file not shown.
Binary file added distribution/mexmaca64/lib/libcrypto.3.dylib
Binary file not shown.
Binary file added distribution/mexmaca64/lib/libcrypto.dylib
Binary file not shown.
Binary file not shown.
Binary file added distribution/mexmaca64/lib/libmysqlclient.a
Binary file not shown.
Binary file added distribution/mexmaca64/lib/libmysqlclient.dylib
Binary file not shown.
Binary file added distribution/mexmaca64/lib/libssl.3.dylib
Binary file not shown.
Binary file added distribution/mexmaca64/lib/libssl.dylib
Binary file not shown.
File renamed without changes.
Binary file added distribution/mexmaca64/mym.mexmaca64
Binary file not shown.
49 changes: 49 additions & 0 deletions mex_compilation/compile_mexmaca64.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
function compile_mexmaca64()
% Build script for MyM (64-bit ARM Mac OS)
%
% Notes:
%
% 1. we're relying on the system zlib.

mym_base = fileparts(fileparts(mfilename('fullpath')));
mym_src = fullfile(mym_base, 'src');
build_out = fullfile(mym_base, 'build', mexext());
distrib_out = fullfile(mym_base, 'distribution', mexext());

% Set up input and output directories
mysql_base = fullfile(mym_base, 'mysqlclient');
mysql_include = fullfile(mysql_base, 'include');
% mysql_platform_include = fullfile(mysql_base, ['include_' mexext()]);
mysql_lib = fullfile(mysql_base, ['lib_' mexext()]);
% mariadb_lib = fullfile(mym_base, ['maria-plugin/','lib_',mexext()]);

mkdir(build_out);
mkdir(distrib_out);
oldp = cd(build_out);
pwd_reset = onCleanup(@() cd(oldp));

mex( ...
'-v', ...
'-largeArrayDims', ...
sprintf('-I"%s"', mysql_include), ... % sprintf('-I"%s"', mysql_platform_include), ...
sprintf('-L"%s"', mysql_lib), ... % sprintf('-L"%s"', mariadb_lib), ...
'-lmysqlclient', ...
'-lz', ...
fullfile(mym_src, 'mym.cpp'));


% Find old libmysqlclient path
[~,old_link] = system(['otool -L ' ...
fullfile(build_out, ['mym.' mexext()]) ...
' | grep libmysqlclient.24.dylib | tail -1 |awk ''{print $1}''']);

% Change libmysqlclient reference to mym mex directory
system(['install_name_tool -change "' strip(old_link) '" "' ...
fullfile('@loader_path','lib', 'libmysqlclient.24.dylib') '" "' ...
fullfile(build_out, ['mym.' mexext()]) '"']);

% Pack mex with all dependencies into distribution directory
copyfile(['mym.' mexext()], distrib_out, 'f');
copyfile(fullfile(mym_src, 'mym.m'), distrib_out, 'f');
copyfile(fullfile(mysql_lib, 'lib*'), fullfile(distrib_out,'lib'), 'f');
% copyfile(fullfile(mariadb_lib, 'dialog.so'), distrib_out, 'f');
43 changes: 43 additions & 0 deletions mktbx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
function tbx = mktbx(varargin)
% package as toolbox for distribution (and optionally install)

install = false;
if nargin > 0
install = varargin{1};
end

root = fileparts(mfilename('fullpath'));

wd = pwd;
cd(fullfile('distribution',mexext()));
docs = help('mym');
cd(wd);

% exclude = {'.vscode', '.git', '.gitignore', 'build', 'lib', 'maria-plugin', ...
% 'mex_compilation', 'mysql-connector', 'notebook', 'src', 'zlib', ...
% '*.txt', '*.env', '*.prf', '*.md', '*.yml', 'tests', '.github'};
d = dir(pwd);
exclude = {d(~endsWith({d.name},'distribution')).name};

d = dir('distribution');
% include = {d(~startsWith({d.name},".")).name};
include = fullfile('distribution',{d(~startsWith({d.name},".")).name});

ghtb.package('mym', ...
'Raphael Guzman', ...
'[email protected]', ...
'MySQL API for MATLAB with support for BLOB objects', ...
docs, ...
exclude, ...
@() strjoin(cellfun(@(x) num2str(x), ...
struct2cell(mym('version')),'UniformOutput',false), ...
'.'), ...
include, ...
'toolboxVersionDir', fullfile('distribution',mexext()), ...
'toolboxRootDir', pwd);

tbx = [];
if install
tbx = matlab.addons.toolbox.installToolbox('mym.mltbx');
end
end
Loading

0 comments on commit b895cf5

Please sign in to comment.