Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2016-04-18 04:34:21 -0400
committerHenrik Rentz-Reichert2016-04-18 04:34:21 -0400
commit2d6f3784a8c0dde32cb8bf05f92a97be5831f001 (patch)
tree17f99ca4a8423fe3f70250b4d6a09284a97fe35f
parentf7e62f7bc4fe98822a874c96befc9d765f40bac0 (diff)
downloadorg.eclipse.etrice-2d6f3784a8c0dde32cb8bf05f92a97be5831f001.tar.gz
org.eclipse.etrice-2d6f3784a8c0dde32cb8bf05f92a97be5831f001.tar.xz
org.eclipse.etrice-2d6f3784a8c0dde32cb8bf05f92a97be5831f001.zip
Bug 491885 - add generator option that allows to change the main name
https://bugs.eclipse.org/bugs/show_bug.cgi?id=491885 Change-Id: I4c138449eab8bd8a21bf6373869a2afdc4d6eb82
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeRunnerGen.xtend6
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/NodeRunnerGen.java18
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.xtend8
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.java20
-rw-r--r--plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorConfigTab.java20
-rw-r--r--plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchConfigurationDelegate.java4
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java11
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/GlobalGeneratorSettings.xtend1
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/base/GlobalGeneratorSettings.java11
9 files changed, 81 insertions, 18 deletions
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeRunnerGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeRunnerGen.xtend
index 53ac1a14e..3e56fdcd3 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeRunnerGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeRunnerGen.xtend
@@ -69,11 +69,11 @@ class NodeRunnerGen {
#include "osal/etPlatformLifecycle.h"
/**
- * main function
- * creates component and starts and stops the lifecycle
+ * «Main.getSettings.mainMethodName» function
+ * creates components and starts and stops the lifecycle
*/
- int main(int argc, char** argv) {
+ int «Main.getSettings.mainMethodName»(int argc, char** argv) {
etBool runAsTest = ET_FALSE;
#ifdef ET_DO_NOT_USE_ARGC_ARGV
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/NodeRunnerGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/NodeRunnerGen.java
index 47fd4d7be..244121ba3 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/NodeRunnerGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/NodeRunnerGen.java
@@ -154,17 +154,25 @@ public class NodeRunnerGen {
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
- _builder.append("* main function");
- _builder.newLine();
+ _builder.append("* ");
+ GlobalGeneratorSettings _settings_1 = Main.getSettings();
+ String _mainMethodName = _settings_1.getMainMethodName();
+ _builder.append(_mainMethodName, " ");
+ _builder.append(" function");
+ _builder.newLineIfNotEmpty();
_builder.append(" ");
- _builder.append("* creates component and starts and stops the lifecycle");
+ _builder.append("* creates components and starts and stops the lifecycle");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.newLine();
- _builder.append("int main(int argc, char** argv) {");
- _builder.newLine();
+ _builder.append("int ");
+ GlobalGeneratorSettings _settings_2 = Main.getSettings();
+ String _mainMethodName_1 = _settings_2.getMainMethodName();
+ _builder.append(_mainMethodName_1, "");
+ _builder.append("(int argc, char** argv) {");
+ _builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("etBool runAsTest = ET_FALSE;");
_builder.newLine();
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.xtend
index f83fe8682..1331db758 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.xtend
@@ -17,11 +17,11 @@ import org.eclipse.etrice.core.etmap.util.ETMapUtil
import org.eclipse.etrice.core.genmodel.etricegen.Root
import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance
import org.eclipse.etrice.core.genmodel.etricegen.SystemInstance
+import org.eclipse.etrice.generator.cpp.Main
import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers
import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo
import org.eclipse.etrice.generator.generic.RoomExtensions
-
@Singleton
class NodeRunnerGen {
@@ -90,10 +90,10 @@ class NodeRunnerGen {
using namespace etRuntime;
/**
- * main function
- * creates component and starts and stops the lifecycle
+ * «Main.getSettings.mainMethodName» function
+ * creates components and starts and stops the lifecycle
*/
- int main(int argc, char* argv[]) {
+ int «Main.getSettings.mainMethodName»(int argc, char* argv[]) {
// instantiate the main component
RTSystem* sys = «IF ssc.eContainer instanceof SystemInstance»new RTSystem("«(ssc.eContainer as SystemInstance).name»")«ELSE»0«ENDIF»;
«clsname»* main_component = new «clsname»(sys, "«ssc.name»");
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.java
index f545a6b45..85a376d1e 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.java
@@ -23,6 +23,8 @@ import org.eclipse.etrice.core.genmodel.etricegen.StructureInstance;
import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
import org.eclipse.etrice.core.genmodel.etricegen.SystemInstance;
import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.base.GlobalGeneratorSettings;
+import org.eclipse.etrice.generator.cpp.Main;
import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers;
import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo;
@@ -190,16 +192,24 @@ public class NodeRunnerGen {
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
- _builder.append("* main function");
- _builder.newLine();
+ _builder.append("* ");
+ GlobalGeneratorSettings _settings = Main.getSettings();
+ String _mainMethodName = _settings.getMainMethodName();
+ _builder.append(_mainMethodName, " ");
+ _builder.append(" function");
+ _builder.newLineIfNotEmpty();
_builder.append(" ");
- _builder.append("* creates component and starts and stops the lifecycle");
+ _builder.append("* creates components and starts and stops the lifecycle");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
- _builder.append("int main(int argc, char* argv[]) {");
- _builder.newLine();
+ _builder.append("int ");
+ GlobalGeneratorSettings _settings_1 = Main.getSettings();
+ String _mainMethodName_1 = _settings_1.getMainMethodName();
+ _builder.append(_mainMethodName_1, "");
+ _builder.append("(int argc, char* argv[]) {");
+ _builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("// instantiate the main component");
_builder.newLine();
diff --git a/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorConfigTab.java b/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorConfigTab.java
index fe1d38b51..0afbc39a2 100644
--- a/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorConfigTab.java
+++ b/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorConfigTab.java
@@ -20,6 +20,7 @@ import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.etrice.generator.base.AbstractGenerator;
import org.eclipse.etrice.generator.ui.preferences.PreferenceConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -67,6 +68,7 @@ public abstract class GeneratorConfigTab extends AbstractLaunchConfigurationTab
public static final String GEN_MODEL_PATH = "GenModelPath";
public static final String SAVE_GEN_MODEL = "SaveGenModel";
+ public static final String MAIN_METHOD_NAME = "MainMethodName";
public static final String LIB = "Lib";
public static final String DEBUG = "Debug";
public static final String MSC_INSTR = "MSC";
@@ -92,6 +94,7 @@ public abstract class GeneratorConfigTab extends AbstractLaunchConfigurationTab
private Text infoPath;
private Text docPath;
protected Button dataButton;
+ private Text mainMethodName;
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
@@ -170,6 +173,19 @@ public abstract class GeneratorConfigTab extends AbstractLaunchConfigurationTab
verboseButton = createCheckButton(mainComposite, "generate instrumentation for verbose output");
verboseButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1));
verboseButton.addSelectionListener(new UpdateConfig());
+
+ Label label = new Label(mainComposite, SWT.NONE);
+ label.setText("The main method name:");
+ mainMethodName = new Text(mainComposite, SWT.SINGLE | SWT.BORDER);
+ mainMethodName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ mainMethodName.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ validate();
+ setDirty(true);
+ updateLaunchConfigurationDialog();
+ }
+ });
createSeparator(mainComposite, 2);
@@ -187,7 +203,7 @@ public abstract class GeneratorConfigTab extends AbstractLaunchConfigurationTab
});
- Label label = new Label(mainComposite, SWT.NONE);
+ label = new Label(mainComposite, SWT.NONE);
label.setText("The directory for &generated code:");
srcgenPath = new Text(mainComposite, SWT.SINGLE | SWT.BORDER);
srcgenPath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@@ -315,6 +331,7 @@ public abstract class GeneratorConfigTab extends AbstractLaunchConfigurationTab
genModelPath.setEnabled(save);
browsePath.setEnabled(save);
genModelPath.setText(configuration.getAttribute(GEN_MODEL_PATH, ""));
+ mainMethodName.setText(configuration.getAttribute(MAIN_METHOD_NAME, AbstractGenerator.DEFAULT_MAIN_NAME));
boolean genDocu = configuration.getAttribute(GEN_DOCUMENTATION, false);
if (configuration.getAttribute(GEN_INSTANCE_DIAGRAM, false))
genDocu = true;
@@ -360,6 +377,7 @@ public abstract class GeneratorConfigTab extends AbstractLaunchConfigurationTab
configuration.setAttribute(LIB, libButton.getSelection());
configuration.setAttribute(SAVE_GEN_MODEL, saveGenModel.getSelection());
configuration.setAttribute(GEN_MODEL_PATH, genModelPath.getText());
+ configuration.setAttribute(MAIN_METHOD_NAME, mainMethodName.getText());
configuration.setAttribute(GEN_INSTANCE_DIAGRAM, documentationButton.getSelection());
configuration.setAttribute(GEN_DOCUMENTATION, documentationButton.getSelection());
configuration.setAttribute(DEBUG, debugButton.getSelection());
diff --git a/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchConfigurationDelegate.java b/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchConfigurationDelegate.java
index 5d8ccc209..1a0961ac5 100644
--- a/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchConfigurationDelegate.java
+++ b/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchConfigurationDelegate.java
@@ -184,6 +184,10 @@ public abstract class GeneratorLaunchConfigurationDelegate extends AbstractJavaL
argString.append(" "+AbstractGenerator.OPTION_SAVE_GEN_MODEL);
argString.append(" "+configuration.getAttribute(GeneratorConfigTab.GEN_MODEL_PATH, "?"));
}
+ if (!configuration.getAttribute(GeneratorConfigTab.MAIN_METHOD_NAME, AbstractGenerator.DEFAULT_MAIN_NAME).equals(AbstractGenerator.DEFAULT_MAIN_NAME)) {
+ argString.append(" "+AbstractGenerator.OPTION_MAIN_NAME);
+ argString.append(" "+configuration.getAttribute(GeneratorConfigTab.MAIN_METHOD_NAME, AbstractGenerator.DEFAULT_MAIN_NAME));
+ }
if (configuration.getAttribute(GeneratorConfigTab.GEN_DOCUMENTATION, false)
|| configuration.getAttribute(GeneratorConfigTab.GEN_INSTANCE_DIAGRAM, false))
argString.append(" "+AbstractGenerator.OPTION_DOCUMENTATION);
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
index 58582a554..6549df561 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
@@ -75,6 +75,8 @@ public abstract class AbstractGenerator implements IDetailCodeTranslator {
public static final String OPTION_NOEXIT = "-noexit";
public static final String OPTION_DOCUMENTATION = "-genDocu";
public static final String OPTION_SAVE_GEN_MODEL = "-saveGenModel";
+ public static final String OPTION_MAIN_NAME = "-mainName";
+ public static final String DEFAULT_MAIN_NAME = "main";
public static final String OPTION_GEN_INCREMENTAL = "-inc";
public static final String OPTION_GEN_DIR = "-genDir";
public static final String OPTION_GEN_INFO_DIR = "-genInfoDir";
@@ -221,6 +223,7 @@ public abstract class AbstractGenerator implements IDetailCodeTranslator {
* <li>{@value #OPTION_MSC_INSTR}</li>
* <li>{@value #OPTION_NOEXIT}</li>
* <li>{@value #OPTION_SAVE_GEN_MODEL}</li>
+ * <li>{@value #OPTION_MAIN_NAME}</li>
* <li>{@value #OPTION_VERBOSE_RT}</li>
* <li>{@value #OPTION_HELP}</li>
* </ul>
@@ -239,6 +242,14 @@ public abstract class AbstractGenerator implements IDetailCodeTranslator {
return usageError(OPTION_SAVE_GEN_MODEL+" needs path");
}
}
+ else if (arg.equals(OPTION_MAIN_NAME)) {
+ if (it.hasNext()) {
+ generatorSettings.setMainMethodName(it.next());
+ }
+ else {
+ return usageError(OPTION_MAIN_NAME+" needs a name for the main method");
+ }
+ }
else if (arg.equals(OPTION_GEN_DIR)) {
if (it.hasNext()) {
RoomExtensions.setGenDir(it.next());
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/GlobalGeneratorSettings.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/GlobalGeneratorSettings.xtend
index c057da8ab..5821bb7fd 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/GlobalGeneratorSettings.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/GlobalGeneratorSettings.xtend
@@ -27,6 +27,7 @@ class GlobalGeneratorSettings {
boolean generateMSCInstrumentation = false
boolean generateDataInstrumentation = false
boolean noTranslation = false
+ String mainMethodName = "main"
// extra generators
String generatorModelPath = null
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/base/GlobalGeneratorSettings.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/base/GlobalGeneratorSettings.java
index 2ecf06a43..2b60bb84b 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/base/GlobalGeneratorSettings.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/base/GlobalGeneratorSettings.java
@@ -29,6 +29,8 @@ public class GlobalGeneratorSettings {
private boolean noTranslation = false;
+ private String mainMethodName = "main";
+
private String generatorModelPath = null;
private boolean generateDocumentation = false;
@@ -79,6 +81,15 @@ public class GlobalGeneratorSettings {
}
@Pure
+ public String getMainMethodName() {
+ return this.mainMethodName;
+ }
+
+ public void setMainMethodName(final String mainMethodName) {
+ this.mainMethodName = mainMethodName;
+ }
+
+ @Pure
public String getGeneratorModelPath() {
return this.generatorModelPath;
}

Back to the top