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