Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 8e880917 authored by hhakim's avatar hhakim
Browse files

Update matlab post-install scripts for linux, macos and win to rehash toolbox...

Update matlab post-install scripts for linux, macos and win to rehash toolbox as a last attempt to access the startup script, otherwise send the user to the doc.
parent a8c0126d
Branches
Tags 2.5.62rc20 2.5.62rc21 2.5.62rc22
No related merge requests found
Pipeline #833959 skipped
...@@ -17,8 +17,10 @@ function inject_matlab_code_to_update_path ...@@ -17,8 +17,10 @@ function inject_matlab_code_to_update_path
echo "addpath(['"$FAUST_MATLAB_WRAPPER_PATH"' '/tools'])" >> "$FILE" echo "addpath(['"$FAUST_MATLAB_WRAPPER_PATH"' '/tools'])" >> "$FILE"
echo "addpath(['"$FAUST_MATLAB_WRAPPER_PATH"' '/data'])" >> "$FILE" echo "addpath(['"$FAUST_MATLAB_WRAPPER_PATH"' '/data'])" >> "$FILE"
echo "matfaust.enable_gpu_mod('silent', true);end" >> "$FILE" echo "matfaust.enable_gpu_mod('silent', true);end" >> "$FILE"
return $?
} }
MATLABRC_RUN_STARTUP_CMD="if(exist('@CMAKE_INSTALL_PREFIX@'))oldpwd=pwd;startup_path=fullfile(matlabroot,'toolbox','local');cd(startup_path);startup_found=which('startup');if(isempty(startup_found))rehash('toolbox');startup_found=which('startup');if(isempty(startup_found)) disp('Faust startup code can''t be executed -- script not found. Please consult the online documentation to resolve this issue.');else;startup;end;else;startup;end;cd(oldpwd);end";
funtion inject_matlab_code_to_update_user_paths funtion inject_matlab_code_to_update_user_paths
{ {
...@@ -56,19 +58,19 @@ else ...@@ -56,19 +58,19 @@ else
STARTUP_DIR="${MATLAB_ROOT}/toolbox/local/" STARTUP_DIR="${MATLAB_ROOT}/toolbox/local/"
MATLABRC="${STARTUP_DIR}/matlabrc.m" MATLABRC="${STARTUP_DIR}/matlabrc.m"
STARTUP_FILE="${STARTUP_DIR}/startup.m" STARTUP_FILE="${STARTUP_DIR}/startup.m"
[[ -r "$STARTUP_FILE" ]] && grep -i -v faust "$STARTUP_FILE" > "${STARTUP_FILE}.tmp" 2>/dev/null && mv "${STARTUP_FILE}.tmp" "$STARTUP_FILE" [[ -r "$STARTUP_FILE" ]] && (grep -i -v faust "$STARTUP_FILE" > "${STARTUP_FILE}.tmp" 2>/dev/null; mv "${STARTUP_FILE}.tmp" "$STARTUP_FILE")
FAUST_MATLAB_WRAPPER_PATH="@CMAKE_INSTALL_MATLAB_PREFIX@" FAUST_MATLAB_WRAPPER_PATH="@CMAKE_INSTALL_MATLAB_PREFIX@"
#USR_STARTUP_FILE=$($MATLAB_BIN -nojvm -nodisplay -r "which startup;exit" | tail -n 2 | head -n 1) # useless in root #USR_STARTUP_FILE=$($MATLAB_BIN -nojvm -nodisplay -r "which startup;exit" | tail -n 2 | head -n 1) # useless in root
if [[ -d "${FAUST_MATLAB_WRAPPER_PATH}" ]] if [[ -d "${FAUST_MATLAB_WRAPPER_PATH}" ]]
then then
#echo "addpath(genpath('"$FAUST_MATLAB_WRAPPER_PATH"'))" >> "$STARTUP_FILE" #echo "addpath(genpath('"$FAUST_MATLAB_WRAPPER_PATH"'))" >> "$STARTUP_FILE"
inject_matlab_code_to_update_path "$STARTUP_FILE" inject_matlab_code_to_update_path "$STARTUP_FILE"
# add a line to force startup execution into matlabrc
echo "oldpwd = pwd; startup_path = fullfile(matlabroot, 'toolbox', 'local'); cd(startup_path); startup; cd(oldpwd)" >> $MATLABRC
RET1=$? RET1=$?
RET2=0 # add a line to force startup execution into matlabrc
# disable because it's too intrusive and maybe redundant # except if the line is already in the file
# inject_matlab_code_to_update_user_paths [[ -r "$MATLABRC" ]] && grep -q "$MATLABRC_RUN_STARTUP_CMD" "$MATLABRC" || (echo "$MATLABRC_RUN_STARTUP_CMD" >> $MATLABRC)
RET2=0 # TODO: make it useful
# inject_matlab_code_to_update_user_paths # disabled because it's too intrusive and maybe redundant
[[ $RET1 = 0 && $RET2 = 0 ]] && echo -e "\033[1mNOTICE\033[0m: Faust matlab setup is complete." || echo "ERROR: something went wrong in matlab startup script editing." [[ $RET1 = 0 && $RET2 = 0 ]] && echo -e "\033[1mNOTICE\033[0m: Faust matlab setup is complete." || echo "ERROR: something went wrong in matlab startup script editing."
else else
echo "ERROR: Faust matlab wrapper path isn't valid." echo "ERROR: Faust matlab wrapper path isn't valid."
......
...@@ -40,6 +40,8 @@ function inject_matlab_code_to_update_user_paths ...@@ -40,6 +40,8 @@ function inject_matlab_code_to_update_user_paths
} }
MATLABRC_RUN_STARTUP_CMD="if(exist('@CMAKE_INSTALL_PREFIX@'))oldpwd=pwd;startup_path=fullfile(matlabroot,'toolbox','local');cd(startup_path);startup_found=which('startup');if(isempty(startup_found))rehash('toolbox');startup_found=which('startup');if(isempty(startup_found)) disp('Faust startup code can''t be executed -- script not found. Please consult the online documentation to resolve this issue.');else;startup;end;else;startup;end;cd(oldpwd);end";
# find matlab root path from the accessible matlab in the PATH # find matlab root path from the accessible matlab in the PATH
MATLAB_BIN=$(which matlab) MATLAB_BIN=$(which matlab)
# deduce MATLAB_ROOT # deduce MATLAB_ROOT
...@@ -60,12 +62,12 @@ else ...@@ -60,12 +62,12 @@ else
STARTUP_DIR="${MATLAB_ROOT}/toolbox/local/" STARTUP_DIR="${MATLAB_ROOT}/toolbox/local/"
STARTUP_FILE=${STARTUP_DIR}/startup.m STARTUP_FILE=${STARTUP_DIR}/startup.m
MATLABRC="${STARTUP_DIR}/matlabrc.m" MATLABRC="${STARTUP_DIR}/matlabrc.m"
[[ -r "$STARTUP_FILE" ]] && grep -i -v faust "$STARTUP_FILE" > "${STARTUP_FILE}.tmp" && mv "${STARTUP_FILE}.tmp" "$STARTUP_FILE" [[ -r "$STARTUP_FILE" ]] && (grep -i -v faust "$STARTUP_FILE" > "${STARTUP_FILE}.tmp"; mv "${STARTUP_FILE}.tmp" "$STARTUP_FILE")
FAUST_MATLAB_WRAPPER_PATH="@CMAKE_INSTALL_MATLAB_PREFIX@" FAUST_MATLAB_WRAPPER_PATH="@CMAKE_INSTALL_MATLAB_PREFIX@"
#echo "addpath(genpath('"$FAUST_MATLAB_WRAPPER_PATH"'))" >> "$STARTUP_FILE" #echo "addpath(genpath('"$FAUST_MATLAB_WRAPPER_PATH"'))" >> "$STARTUP_FILE"
inject_matlab_code_to_update_path $STARTUP_FILE inject_matlab_code_to_update_path $STARTUP_FILE
# add a line to force startup execution into matlabrc # add a line to force startup execution into matlabrc
echo "oldpwd = pwd; startup_path = fullfile(matlabroot, 'toolbox', 'local'); cd(startup_path); startup; cd(oldpwd)" >> $MATLABRC # except if the line is already in the file
# disable because it's too intrusive and maybe redundant [[ -r "$MATLABRC" ]] && grep -q "$MATLABRC_RUN_STARTUP_CMD" "$MATLABRC" || (echo "$MATLABRC_RUN_STARTUP_CMD" >> $MATLABRC)
# inject_matlab_code_to_update_user_paths # inject_matlab_code_to_update_user_paths # disabled because it's too intrusive and maybe redundant
fi fi
...@@ -251,7 +251,7 @@ Function matlabFoundCb ...@@ -251,7 +251,7 @@ Function matlabFoundCb
FileOpen $1 "$R4\toolbox\local\matlabrc.m" a FileOpen $1 "$R4\toolbox\local\matlabrc.m" a
FileSeek $1 0 END ; do not erase start of file (but risk to add Faust path multiple times) FileSeek $1 0 END ; do not erase start of file (but risk to add Faust path multiple times)
FileWrite $1 "oldpwd = pwd; startup_path = fullfile(matlabroot, 'toolbox', 'local'); cd(startup_path); startup; cd(oldpwd);" FileWrite $1 "if(exist('$INSTDIR'))oldpwd=pwd;startup_path=fullfile(matlabroot,'toolbox','local');cd(startup_path);startup_found=which('startup');if(isempty(startup_found))rehash toolbox;startup_found=which('startup');if(isempty(startup_found)) disp('Faust startup code can't be executed -- script not found. Please consult the online documentation to resolve this issue.');else;startup;end;else;startup;end;cd(oldpwd);end"
FileClose $1 FileClose $1
# disable because it's redundant # disable because it's redundant
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment