From ad3a765dbddf067f2c788eb5ab01c3578ac7f0dc Mon Sep 17 00:00:00 2001 From: aymanhab Date: Tue, 22 Oct 2024 15:07:15 -0700 Subject: [PATCH] Modify configure script to handle API distribution. --- Bindings/Java/Matlab/configureOpenSim.m.in | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Bindings/Java/Matlab/configureOpenSim.m.in b/Bindings/Java/Matlab/configureOpenSim.m.in index bf082979c9..b92d77426c 100644 --- a/Bindings/Java/Matlab/configureOpenSim.m.in +++ b/Bindings/Java/Matlab/configureOpenSim.m.in @@ -95,6 +95,10 @@ function [openSimFolder] = uiGetOpenSimFolder() appDir = fullfile(openSimFolder, [name ext '.app']); if exist(appDir, 'dir') openSimFolder = fullfile(appDir, 'Contents', 'Resources', 'OpenSim'); + else + % This could be an API install + api_distro = true + showMessage('Application not found, assuming API distribution.', 'Info', false); end end end @@ -120,8 +124,13 @@ try while ~correctFolder openSimFolder = uiGetOpenSimFolder(); % Check if the user selected a valid folder. + if api_distro + subfoldername = 'etc'; + else + subfoldername = '@CMAKE_INSTALL_SYSCONFDIR@'; + end buildInfoFile = fullfile(openSimFolder, ... - '@CMAKE_INSTALL_SYSCONFDIR@', 'OpenSim_buildinfo.txt'); + subfoldername, 'OpenSim_buildinfo.txt'); if exist(buildInfoFile) correctFolder = true; else @@ -137,8 +146,13 @@ try %% Edit the Java class path (need full path for print) toolboxLocal = fullfile(matlabroot, 'toolbox', 'local'); % Create the string names used + if api_distro + jarPath = 'share/java' + else + jarPath = '@OPENSIM_INSTALL_JAVAJARDIR@' + end OpenSimJarPath = fullfile(openSimFolder, ... - '@OPENSIM_INSTALL_JAVAJARDIR@', '@SWIG_JAVA_JAR_NAME@'); + jarPath, '@SWIG_JAVA_JAR_NAME@'); classFileTool = fullfile(toolboxLocal, 'classpath.txt'); % Keep track of if (1) we detected existing OpenSim % and (2) if we had issues removing existing OpenSim entries. @@ -162,8 +176,13 @@ try end %% Edit the Java library path. + if api_distro + libPath = 'lib' + else + libPath = '@OPENSIM_INSTALL_SHAREDLIBDIR@' + end % Create the string names used - OpenSimLibPath = fullfile(openSimFolder, '@OPENSIM_INSTALL_SHAREDLIBDIR@'); + OpenSimLibPath = fullfile(openSimFolder, libPath); libraryFileTool = fullfile(toolboxLocal, 'librarypath.txt'); if matlabOlderThan2012b rmPrev = rmPrev | editPathTxtFile(libraryFileTool, OpenSimLibPath);