Added additional error msgs to compile scripts to make debugging/installation easier

parent a9de67d7
Pipeline #106144 passed with stages
in 8 minutes and 24 seconds
......@@ -10,15 +10,16 @@ import java.util.List;
public class BashCompilationGenerator extends CompilationGenerator {
private String PATH_TEMPLATE = "if [ -n \"$<new_exe>_HOME\" ]\n" +
"then\n"+
" export PATH=\"$<new_exe>_HOME:$PATH\"\n"+
"\texport PATH=\"$<new_exe>_HOME:$PATH\"\n" +
"fi";
private String CHECK_EXE_TEMPLATE = "if [[ `command -v <exe>` ]]\n" +
"then\n" +
" echo \"Found <exe>\"\n" +
"\techo \"Found <exe>\"\n" +
"else\n" +
" echo \"Can not find <exe> in PATH! Aborting.\"\n" +
" exit 1\n" +
"\techo \"Can not find <exe> in PATH! Aborting.\"\n" +
"<additional_error>" +
"\texit 1\n" +
"fi";
private String SOURCE_ENV_VARS_TEMPLATE = "source <env_file>";
......@@ -56,6 +57,8 @@ public class BashCompilationGenerator extends CompilationGenerator {
@Override
protected List<String> getAdditionalPathDirs() {
setAdditionalErrorMsg("roscore", defaultErrorMsg("ROS"));
setAdditionalErrorMsg("ros2", defaultErrorMsg("ROS2"));
return Arrays.asList("cmake","make");
}
......
......@@ -2,15 +2,13 @@ package de.monticore.lang.monticar.generator.middleware.compile;
import de.monticore.lang.monticar.generator.FileContent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public abstract class CompilationGenerator {
private boolean useRos = false;
private boolean useRos2 = false;
private Map<String, String> additionalErrorMsg = new HashMap<>();
public abstract boolean supportsRos();
......@@ -20,6 +18,15 @@ public abstract class CompilationGenerator {
return (supportsRos() || !useRos()) && (supportsRos2() || !useRos2());
}
protected void setAdditionalErrorMsg(String executable, String errorMsg) {
additionalErrorMsg.put(executable, errorMsg);
}
protected String getAdditionalErrorMsg(String executable) {
String s = additionalErrorMsg.getOrDefault(executable, defaultErrorMsg(executable));
return "\techo \"" + s + "\"" + getNewlineDelimiter();
}
protected abstract String getPathTemplate();
protected abstract String getCheckExeTemplate();
......@@ -55,7 +62,9 @@ public abstract class CompilationGenerator {
}
protected String fillCheckExeTemplate(String exe) {
return getCheckExeTemplate().replace("<exe>", exe);
return getCheckExeTemplate()
.replace("<exe>", exe)
.replace("<additional_error>", getAdditionalErrorMsg(exe));
}
protected String fillSourceEnvVarsTemplate(String envFile) {
......@@ -107,4 +116,8 @@ public abstract class CompilationGenerator {
res.add(new MsbuildCompilationGenerator());
return res;
}
protected String defaultErrorMsg(String executable) {
return "Try setting the environment variable " + executable + "_HOME to the base of your installation or adding it to your PATH!";
}
}
......@@ -19,6 +19,8 @@ public class MsbuildCompilationGenerator extends WindowsCompilationGenerator {
@Override
protected List<String> getAdditionalPathDirs() {
setAdditionalErrorMsg("vcvars64.bat", defaultErrorMsg("msbuild"));
setAdditionalErrorMsg("ros2", defaultErrorMsg("ROS2"));
return Arrays.asList("cmake","msbuild");
}
......
package de.monticore.lang.monticar.generator.middleware.compile;
import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.middleware.helpers.FileHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.TemplateHelper;
import de.monticore.lang.monticar.generator.roscpp.helper.NameHelper;
import java.util.ArrayList;
import java.util.List;
public abstract class WindowsCompilationGenerator extends CompilationGenerator {
private String PATH_TEMPLATE = "IF NOT [%<new_exe>_HOME%] == [] (\n" +
" set PATH=\"%<new_exe>_HOME%;%PATH%\"\n" +
"\tset PATH=\"%<new_exe>_HOME%;%PATH%\"\n" +
")";
private String CHECK_EXE_TEMPLATE = "where <exe>\n" +
"IF NOT %ERRORLEVEL% EQU 0 (\n" +
" echo \"Can not find <exe> in PATH! Aborting.\"\n" +
" exit /B 1\n" +
"\techo \"Can not find <exe> in PATH! Aborting.\"\n" +
"<additional_error>" +
"\texit /B 1\n" +
")";
private String SOURCE_ENV_VARS_TEMPLATE = "call <env_file>";
......
......@@ -4,27 +4,29 @@ set -e
# add *_HOME to PATH temporarily
if [ -n "$cmake_HOME" ]
then
export PATH="$cmake_HOME:$PATH"
export PATH="$cmake_HOME:$PATH"
fi
if [ -n "$make_HOME" ]
then
export PATH="$make_HOME:$PATH"
export PATH="$make_HOME:$PATH"
fi
# check if needed programs are in PATH
if [[ `command -v cmake` ]]
then
echo "Found cmake"
echo "Found cmake"
else
echo "Can not find cmake in PATH! Aborting."
exit 1
echo "Can not find cmake in PATH! Aborting."
echo "Try setting the environment variable cmake_HOME to the base of your installation or adding it to your PATH!"
exit 1
fi
if [[ `command -v make` ]]
then
echo "Found make"
echo "Found make"
else
echo "Can not find make in PATH! Aborting."
exit 1
echo "Can not find make in PATH! Aborting."
echo "Try setting the environment variable make_HOME to the base of your installation or adding it to your PATH!"
exit 1
fi
# source additional environment variables
......
@ECHO Off
:: add *_HOME to PATH temporarily
IF NOT [%cmake_HOME%] == [] (
set PATH="%cmake_HOME%;%PATH%"
set PATH="%cmake_HOME%;%PATH%"
)
IF NOT [%make_HOME%] == [] (
set PATH="%make_HOME%;%PATH%"
set PATH="%make_HOME%;%PATH%"
)
IF NOT [%g++_HOME%] == [] (
set PATH="%g++_HOME%;%PATH%"
set PATH="%g++_HOME%;%PATH%"
)
:: check if needed programs are in PATH
where cmake
IF NOT %ERRORLEVEL% EQU 0 (
echo "Can not find cmake in PATH! Aborting."
exit /B 1
echo "Can not find cmake in PATH! Aborting."
echo "Try setting the environment variable cmake_HOME to the base of your installation or adding it to your PATH!"
exit /B 1
)
where make
IF NOT %ERRORLEVEL% EQU 0 (
echo "Can not find make in PATH! Aborting."
exit /B 1
echo "Can not find make in PATH! Aborting."
echo "Try setting the environment variable make_HOME to the base of your installation or adding it to your PATH!"
exit /B 1
)
where g++
IF NOT %ERRORLEVEL% EQU 0 (
echo "Can not find g++ in PATH! Aborting."
exit /B 1
echo "Can not find g++ in PATH! Aborting."
echo "Try setting the environment variable g++_HOME to the base of your installation or adding it to your PATH!"
exit /B 1
)
:: source additional environment variables
......
@ECHO Off
:: add *_HOME to PATH temporarily
IF NOT [%cmake_HOME%] == [] (
set PATH="%cmake_HOME%;%PATH%"
set PATH="%cmake_HOME%;%PATH%"
)
IF NOT [%msbuild_HOME%] == [] (
set PATH="%msbuild_HOME%;%PATH%"
set PATH="%msbuild_HOME%;%PATH%"
)
:: check if needed programs are in PATH
where cmake
IF NOT %ERRORLEVEL% EQU 0 (
echo "Can not find cmake in PATH! Aborting."
exit /B 1
echo "Can not find cmake in PATH! Aborting."
echo "Try setting the environment variable cmake_HOME to the base of your installation or adding it to your PATH!"
exit /B 1
)
where vcvars64.bat
IF NOT %ERRORLEVEL% EQU 0 (
echo "Can not find vcvars64.bat in PATH! Aborting."
exit /B 1
echo "Can not find vcvars64.bat in PATH! Aborting."
echo "Try setting the environment variable msbuild_HOME to the base of your installation or adding it to your PATH!"
exit /B 1
)
:: source additional environment variables
......@@ -25,8 +27,9 @@ call vcvars64.bat
:: Post source check if needed programs are in PATH
where msbuild
IF NOT %ERRORLEVEL% EQU 0 (
echo "Can not find msbuild in PATH! Aborting."
exit /B 1
echo "Can not find msbuild in PATH! Aborting."
echo "Try setting the environment variable msbuild_HOME to the base of your installation or adding it to your PATH!"
exit /B 1
)
:: cmake
......
......@@ -4,27 +4,29 @@ set -e
# add *_HOME to PATH temporarily
if [ -n "$cmake_HOME" ]
then
export PATH="$cmake_HOME:$PATH"
export PATH="$cmake_HOME:$PATH"
fi
if [ -n "$make_HOME" ]
then
export PATH="$make_HOME:$PATH"
export PATH="$make_HOME:$PATH"
fi
# check if needed programs are in PATH
if [[ `command -v cmake` ]]
then
echo "Found cmake"
echo "Found cmake"
else
echo "Can not find cmake in PATH! Aborting."
exit 1
echo "Can not find cmake in PATH! Aborting."
echo "Try setting the environment variable cmake_HOME to the base of your installation or adding it to your PATH!"
exit 1
fi
if [[ `command -v make` ]]
then
echo "Found make"
echo "Found make"
else
echo "Can not find make in PATH! Aborting."
exit 1
echo "Can not find make in PATH! Aborting."
echo "Try setting the environment variable make_HOME to the base of your installation or adding it to your PATH!"
exit 1
fi
# source additional environment variables
......@@ -33,10 +35,11 @@ source "$ROS_HOME"/setup.bash
# Post source check if needed programs are in PATH
if [[ `command -v roscore` ]]
then
echo "Found roscore"
echo "Found roscore"
else
echo "Can not find roscore in PATH! Aborting."
exit 1
echo "Can not find roscore in PATH! Aborting."
echo "Try setting the environment variable ROS_HOME to the base of your installation or adding it to your PATH!"
exit 1
fi
# cmake
......
......@@ -4,27 +4,29 @@ set -e
# add *_HOME to PATH temporarily
if [ -n "$cmake_HOME" ]
then
export PATH="$cmake_HOME:$PATH"
export PATH="$cmake_HOME:$PATH"
fi
if [ -n "$make_HOME" ]
then
export PATH="$make_HOME:$PATH"
export PATH="$make_HOME:$PATH"
fi
# check if needed programs are in PATH
if [[ `command -v cmake` ]]
then
echo "Found cmake"
echo "Found cmake"
else
echo "Can not find cmake in PATH! Aborting."
exit 1
echo "Can not find cmake in PATH! Aborting."
echo "Try setting the environment variable cmake_HOME to the base of your installation or adding it to your PATH!"
exit 1
fi
if [[ `command -v make` ]]
then
echo "Found make"
echo "Found make"
else
echo "Can not find make in PATH! Aborting."
exit 1
echo "Can not find make in PATH! Aborting."
echo "Try setting the environment variable make_HOME to the base of your installation or adding it to your PATH!"
exit 1
fi
# source additional environment variables
......@@ -33,10 +35,11 @@ source "$ROS2_HOME"/setup.bash
# Post source check if needed programs are in PATH
if [[ `command -v ros2` ]]
then
echo "Found ros2"
echo "Found ros2"
else
echo "Can not find ros2 in PATH! Aborting."
exit 1
echo "Can not find ros2 in PATH! Aborting."
echo "Try setting the environment variable ROS2_HOME to the base of your installation or adding it to your PATH!"
exit 1
fi
# cmake
......
@ECHO Off
:: add *_HOME to PATH temporarily
IF NOT [%cmake_HOME%] == [] (
set PATH="%cmake_HOME%;%PATH%"
set PATH="%cmake_HOME%;%PATH%"
)
IF NOT [%msbuild_HOME%] == [] (
set PATH="%msbuild_HOME%;%PATH%"
set PATH="%msbuild_HOME%;%PATH%"
)
:: check if needed programs are in PATH
where cmake
IF NOT %ERRORLEVEL% EQU 0 (
echo "Can not find cmake in PATH! Aborting."
exit /B 1
echo "Can not find cmake in PATH! Aborting."
echo "Try setting the environment variable cmake_HOME to the base of your installation or adding it to your PATH!"
exit /B 1
)
where vcvars64.bat
IF NOT %ERRORLEVEL% EQU 0 (
echo "Can not find vcvars64.bat in PATH! Aborting."
exit /B 1
echo "Can not find vcvars64.bat in PATH! Aborting."
echo "Try setting the environment variable msbuild_HOME to the base of your installation or adding it to your PATH!"
exit /B 1
)
:: source additional environment variables
......@@ -26,13 +28,15 @@ call %ROS2_HOME%\local_setup.bat
:: Post source check if needed programs are in PATH
where msbuild
IF NOT %ERRORLEVEL% EQU 0 (
echo "Can not find msbuild in PATH! Aborting."
exit /B 1
echo "Can not find msbuild in PATH! Aborting."
echo "Try setting the environment variable msbuild_HOME to the base of your installation or adding it to your PATH!"
exit /B 1
)
where ros2
IF NOT %ERRORLEVEL% EQU 0 (
echo "Can not find ros2 in PATH! Aborting."
exit /B 1
echo "Can not find ros2 in PATH! Aborting."
echo "Try setting the environment variable ROS2_HOME to the base of your installation or adding it to your PATH!"
exit /B 1
)
:: cmake
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment