Skip to content
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

Matlab Updates #162

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions cmake/MatlabWrap.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ function(wrap_library_internal interfaceHeader moduleName linkLibraries extraInc
set(mexModuleExt mexglx)
endif()
elseif(APPLE)
set(mexModuleExt mexmaci64)
check_cxx_compiler_flag("-arch arm64" arm64Supported)
if (arm64Supported)
set(mexModuleExt mexmaca64)
else()
set(mexModuleExt mexmaci64)
endif()
elseif(MSVC)
if(CMAKE_CL_64)
set(mexModuleExt mexw64)
Expand Down Expand Up @@ -299,7 +304,12 @@ function(wrap_library_internal interfaceHeader moduleName linkLibraries extraInc
APPEND
PROPERTY COMPILE_FLAGS "/bigobj")
elseif(APPLE)
set(mxLibPath "${MATLAB_ROOT}/bin/maci64")
check_cxx_compiler_flag("-arch arm64" arm64Supported)
if (arm64Supported)
set(mxLibPath "${MATLAB_ROOT}/bin/maca64")
else()
set(mxLibPath "${MATLAB_ROOT}/bin/maci64")
endif()
target_link_libraries(
${moduleName}_matlab_wrapper "${mxLibPath}/libmex.dylib"
"${mxLibPath}/libmx.dylib" "${mxLibPath}/libmat.dylib")
Expand Down Expand Up @@ -367,7 +377,12 @@ function(check_conflicting_libraries_internal libraries)
if(UNIX)
# Set path for matlab's built-in libraries
if(APPLE)
set(mxLibPath "${MATLAB_ROOT}/bin/maci64")
check_cxx_compiler_flag("-arch arm64" arm64Supported)
if (arm64Supported)
set(mxLibPath "${MATLAB_ROOT}/bin/maca64")
else()
set(mxLibPath "${MATLAB_ROOT}/bin/maci64")
endif()
else()
if(CMAKE_CL_64)
set(mxLibPath "${MATLAB_ROOT}/bin/glnxa64")
Expand Down
9 changes: 8 additions & 1 deletion gtwrap/matlab_wrapper/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,8 @@ def _collector_return(self,
[instantiated_class.name])
else:
# Get the full namespace
class_name = ".".join(instantiated_class.parent.full_namespaces()[1:])
class_name = ".".join(
instantiated_class.parent.full_namespaces()[1:])

if class_name != "":
class_name += '.'
Expand Down Expand Up @@ -1860,6 +1861,7 @@ def generate_content(self, cc_content, path):
"""
for c in cc_content:
if isinstance(c, list):
# c is a namespace
if len(c) == 0:
continue

Expand All @@ -1875,18 +1877,21 @@ def generate_content(self, cc_content, path):
self.generate_content(sub_content[1], path_to_folder)

elif isinstance(c[1], list):
# c is a wrapped function
path_to_folder = osp.join(path, c[0])

if not osp.isdir(path_to_folder):
try:
os.makedirs(path_to_folder, exist_ok=True)
except OSError:
pass

for sub_content in c[1]:
path_to_file = osp.join(path_to_folder, sub_content[0])
with open(path_to_file, 'w') as f:
f.write(sub_content[1])
else:
# c is a wrapped class
path_to_file = osp.join(path, c[0])

if not osp.isdir(path_to_file):
Expand Down Expand Up @@ -1921,6 +1926,8 @@ def wrap(self, files, path):
for module in modules.values():
# Wrap the full namespace
self.wrap_namespace(module)

# Generate the wrapping code (both C++ and .m files)
self.generate_wrapper(module)

# Generate the corresponding .m and .cpp files
Expand Down
Loading