Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gradle/etGenerator.gradle2
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/GeneratorApplication.java78
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/GeneratorFileIO.java271
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/IGeneratorFileIO.java12
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/IncrementalGeneratorFileIO.java140
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationModule.java2
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationOptions.java16
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeRunnerGen.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorConfigTab.java22
-rw-r--r--plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchConfigurationDelegate.java9
-rw-r--r--plugins/org.eclipse.etrice.generator.ui.cdt/src/org/eclipse/etrice/generator/ui/cdt/ProjectConfigurator.java17
-rw-r--r--plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/GeneratorPreferencePage.java10
-rw-r--r--plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceConstants.java2
-rw-r--r--plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceInitializer.java2
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java4
15 files changed, 338 insertions, 251 deletions
diff --git a/gradle/etGenerator.gradle b/gradle/etGenerator.gradle
index 4dc201d8b..051a2b929 100644
--- a/gradle/etGenerator.gradle
+++ b/gradle/etGenerator.gradle
@@ -17,7 +17,7 @@ ext.createGeneratorTask = { name, lang, models, genDir = 'src-gen', options = []
return tasks.create(name: name, type: JavaExec, dependsOn: "$generator:classes") {
main = project(generator).mainClassName
classpath = project(generator).sourceSets.main.runtimeClasspath
- args '-msc_instr', '-genDir', genDir
+ args '-clean', '-msc_instr', '-genDir', genDir
args options
args models
inputs.files models
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/GeneratorApplication.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/GeneratorApplication.java
index febb60870..deba8a4f2 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/GeneratorApplication.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/GeneratorApplication.java
@@ -25,17 +25,16 @@ import org.eclipse.etrice.generator.base.args.Options;
import org.eclipse.etrice.generator.base.cli.CommandLineParseException;
import org.eclipse.etrice.generator.base.cli.ICommandLineParser;
import org.eclipse.etrice.generator.base.cli.IHelpFormatter;
-import org.eclipse.etrice.generator.base.io.IGeneratorFileIO;
+import org.eclipse.etrice.generator.base.io.GeneratorFileIO;
import org.eclipse.etrice.generator.base.io.ILineOutput;
import org.eclipse.etrice.generator.base.io.IGeneratorResourceLoader;
-import org.eclipse.etrice.generator.base.io.IncrementalGeneratorFileIO;
import org.eclipse.etrice.generator.base.io.LineOutput;
-import org.eclipse.etrice.generator.base.logging.ILogger;
import org.eclipse.etrice.generator.base.logging.Logger;
import org.eclipse.etrice.generator.base.logging.Loglevel;
import org.eclipse.etrice.generator.base.setup.GeneratorApplicationOptions;
import org.eclipse.etrice.generator.base.setup.IGeneratorOptions;
import org.eclipse.etrice.generator.base.validation.IGeneratorResourceValidator;
+
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
@@ -74,7 +73,7 @@ public class GeneratorApplication {
private ICommandLineParser commandLineParser;
private IHelpFormatter helpFormatter;
private Provider<Logger> loggerProvider;
- private Provider<IncrementalGeneratorFileIO> fileIOProvider;
+ private Provider<GeneratorFileIO> fileIOProvider;
private Provider<IGenerator> generatorProvider;
private IGeneratorResourceLoader resourceLoader;
private IGeneratorResourceValidator resourceValidator;
@@ -82,7 +81,7 @@ public class GeneratorApplication {
@Inject
public GeneratorApplication(IGeneratorOptions optionsModule, ICommandLineParser commandLineParser,
IHelpFormatter helpFormatter, Provider<Logger> loggerProvider,
- Provider<IncrementalGeneratorFileIO> fileIOProvider, Provider<IGenerator> generatorProvider,
+ Provider<GeneratorFileIO> fileIOProvider, Provider<IGenerator> generatorProvider,
IGeneratorResourceLoader resourceLoader, IGeneratorResourceValidator resourceValidator) {
this.options = new Options(new GeneratorApplicationOptions(), optionsModule);
this.commandLineParser = commandLineParser;
@@ -134,10 +133,25 @@ public class GeneratorApplication {
* @param out the output
*/
public void run(Arguments arguments, ILineOutput out) throws GeneratorException {
- ILogger logger = createLogger(arguments, out);
- IGeneratorFileIO fileIO = createGeneratorFileIO(arguments, logger);
+ Logger logger = createLogger(arguments, out);
+
+ try {
+ GeneratorFileIO fileIO = createGeneratorFileIO(arguments, logger);
+
+ logArguments(arguments, fileIO, logger);
+
+ List<Resource> resources = load(arguments, logger);
+
+ validate(resources, arguments, logger);
- execute(arguments, fileIO, logger);
+ generate(resources, arguments, fileIO, logger);
+
+ cleanOutputDirectory(arguments, fileIO, logger);
+ }
+ catch (Exception e) {
+ logException(e, logger);
+ throw e;
+ }
}
/**
@@ -157,59 +171,53 @@ public class GeneratorApplication {
public Arguments createArguments() {
return new Arguments(getOptions());
}
-
- private void execute(Arguments arguments, IGeneratorFileIO fileIO, ILogger logger) throws GeneratorException {
- try {
- logger.logDebug(arguments.toString());
-
- List<Resource> resources = load(arguments.get(GeneratorApplicationOptions.FILES), arguments, logger);
-
- validate(resources, arguments, logger);
-
- generate(resources, arguments, fileIO, logger);
- }
- catch (Exception e) {
- logException(e, logger);
- throw e;
- }
- }
private void printHelp(ILineOutput out) {
String help = helpFormatter.getHelp(options, GeneratorApplicationOptions.FILES);
out.println(help);
}
- private ILogger createLogger(Arguments arguments, ILineOutput out) {
+ private Logger createLogger(Arguments arguments, ILineOutput out) {
Logger logger = loggerProvider.get();
logger.setLoglevel(arguments.get(GeneratorApplicationOptions.LOGLEVEL));
logger.setOutput(out);
return logger;
}
- private IGeneratorFileIO createGeneratorFileIO(Arguments arguments, ILogger logger) {
- IncrementalGeneratorFileIO fileIO = fileIOProvider.get();
- fileIO.setGenDir(arguments.get(GeneratorApplicationOptions.GEN_DIR));
- fileIO.setGenInfoDir(arguments.get(GeneratorApplicationOptions.GEN_INFO_DIR));
- fileIO.setGenerateIncremental(arguments.get(GeneratorApplicationOptions.GEN_INCREMENTAL));
+ private GeneratorFileIO createGeneratorFileIO(Arguments arguments, Logger logger) {
+ GeneratorFileIO fileIO = fileIOProvider.get();
+ fileIO.setOutputDirectory(arguments.get(GeneratorApplicationOptions.GEN_DIR));
fileIO.setLogger(logger);
return fileIO;
}
- private List<Resource> load(List<String> files, Arguments arguments, ILogger logger) {
+ private List<Resource> load(Arguments arguments, Logger logger) {
+ List<String> files = arguments.get(GeneratorApplicationOptions.FILES);
return resourceLoader.load(files, arguments, logger);
}
- private void validate(List<Resource> models, Arguments arguments, ILogger logger) {
+ private void validate(List<Resource> models, Arguments arguments, Logger logger) {
resourceValidator.validate(models, arguments, logger);
}
- private void generate(List<Resource> resources, Arguments arguments, IGeneratorFileIO fileIO, ILogger logger) {
+ private void generate(List<Resource> resources, Arguments arguments, GeneratorFileIO fileIO, Logger logger) {
// Create new generator to avoid problems with static states in eTrice AbstractGenerator
IGenerator generator = generatorProvider.get();
generator.generate(resources, arguments, fileIO, logger);
}
-
- private void logException(Exception e, ILogger logger) {
+
+ private void cleanOutputDirectory(Arguments arguments, GeneratorFileIO fileIO, Logger logger) {
+ if(arguments.get(GeneratorApplicationOptions.CLEAN)) {
+ fileIO.cleanOutputDirectory();
+ }
+ }
+
+ private void logArguments(Arguments arguments, GeneratorFileIO fileIO, Logger logger) {
+ logger.logDebug("Arguments: " + arguments);
+ logger.logDebug("Output directory: " + fileIO.getOutputDirectory().toAbsolutePath());
+ }
+
+ private void logException(Exception e, Logger logger) {
if(Loglevel.DEBUG.compareTo(logger.getLoglevel()) >= 0) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/GeneratorFileIO.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/GeneratorFileIO.java
new file mode 100644
index 000000000..c00a14900
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/GeneratorFileIO.java
@@ -0,0 +1,271 @@
+/*******************************************************************************
+* Copyright (c) 2018 protos software gmbh (http://www.protos.de).
+* All rights reserved.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+*
+* CONTRIBUTORS:
+* Jan Belle (initial contribution)
+*
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.base.io;
+
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.FileVisitResult;
+import java.nio.file.FileVisitor;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.UserDefinedFileAttributeView;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.zip.CRC32;
+
+import org.eclipse.etrice.generator.base.logging.ILogger;
+import org.eclipse.etrice.generator.base.logging.NullLogger;
+import org.eclipse.xtext.util.RuntimeIOException;
+
+/**
+ * Incrementally writes files to an output directory.
+ *
+ * Therefore stores a checksum of the file content in the file attributes.
+ * If file attributes are not available, recomputes the checksum from the content of the file.
+ * Additionally keeps record of all generated files to allow removal of obsolete files.
+ */
+public class GeneratorFileIO implements IGeneratorFileIO {
+
+ private static final String CHECKSUM_ATTRIBUTE_NAME = "user.crc32";
+
+ private HashSet<Path> generatedFiles;
+ private Path outputPath;
+ private ILogger logger;
+
+ /**
+ * Creates a new generator file io instance that writes to the working directory.
+ */
+ public GeneratorFileIO() {
+ this("");
+ }
+
+ /**
+ * Creates a new generator file io that writes to the specified output directory.
+ *
+ * @param outputPath the path to the output directory
+ */
+ public GeneratorFileIO(String outputPath) {
+ this(outputPath, new NullLogger());
+ }
+
+ /**
+ * Creates a new generator file io that writes to the specified output directory.
+ *
+ * @param outputPath the path to the output directory
+ * @param logger the logger
+ */
+ public GeneratorFileIO(String outputPath, ILogger logger) {
+ generatedFiles = new HashSet<>();
+
+ setOutputDirectory(outputPath);
+ setLogger(logger);
+ }
+
+ /**
+ * Sets to logger.
+ *
+ * @param logger the logger
+ */
+ public void setLogger(ILogger logger) {
+ this.logger = logger;
+ }
+
+ /**
+ * Returns the output directory path.
+ *
+ * @return the path of the output directory
+ */
+ public Path getOutputDirectory() {
+ return outputPath;
+ }
+
+ /**
+ * Sets the output directory.
+ *
+ * @param path the path to the new output directory
+ */
+ public void setOutputDirectory(Path path) {
+ outputPath = path.normalize();
+ }
+
+ /**
+ * Sets the output directory.
+ *
+ * @param path the path to the new output directory
+ */
+ public void setOutputDirectory(String path) {
+ setOutputDirectory(Paths.get(path));
+ }
+
+ @Override
+ public void generateFile(String file, CharSequence content) {
+ Path path = getPath(file);
+ String contentStr = content.toString();
+ long checksum = getContentChecksum(contentStr);
+
+ if(!isUnchanged(path, checksum)) {
+ logger.logDebug("writing file " + path);
+ writeFile(path, contentStr);
+ setChecksumAttribute(path, checksum);
+ }
+ else {
+ logger.logDebug("file unchanged " + path);
+ }
+
+ generatedFiles.add(path);
+ }
+
+ @Override
+ public void generateFile(String desc, String file, CharSequence content) {
+ logger.logInfo(desc + " " + file);
+ generateFile(file, content);
+ }
+
+ /**
+ * Removes all files in the output directory that haven't been written by this instance.
+ */
+ public void cleanOutputDirectory() {
+ try {
+ FileVisitor<Path> visitor = new FileCleaner(generatedFiles, logger);
+ Files.walkFileTree(outputPath, visitor);
+ } catch (IOException e) {
+ throw new RuntimeIOException(e);
+ }
+ }
+
+ private Path getPath(String file) {
+ return outputPath.resolve(Paths.get(file)).normalize();
+ }
+
+ private void writeFile(Path path, String content) {
+ try {
+ Files.createDirectories(path.getParent());
+ BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8);
+ writer.append(content);
+ writer.close();
+ }
+ catch(IOException e) {
+ throw new RuntimeIOException(e);
+ }
+ }
+
+ private boolean isUnchanged(Path path, long checksum) {
+ if(Files.exists(path)) {
+ Long oldChecksum = getChecksumAttribute(path);
+ if(oldChecksum != null && oldChecksum.longValue() == checksum) {
+ return true;
+ }
+ oldChecksum = getFileChecksum(path);
+ if(oldChecksum != null && oldChecksum.longValue() == checksum) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private long getContentChecksum(String content) {
+ CRC32 crc = new CRC32();
+ crc.update(content.getBytes(StandardCharsets.UTF_8));
+ return crc.getValue();
+ }
+
+ private Long getChecksumAttribute(Path path) {
+ Long checksum = null;
+ try {
+ UserDefinedFileAttributeView view = Files.getFileAttributeView(path, UserDefinedFileAttributeView.class);
+ if(view != null) {
+ ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES);
+ view.read(CHECKSUM_ATTRIBUTE_NAME, buffer);
+ buffer.flip();
+ checksum = buffer.getLong();
+ }
+ }
+ catch(IOException | UnsupportedOperationException | IllegalArgumentException | ClassCastException e) {
+ logger.logDebug(e.toString());
+ }
+ return checksum;
+ }
+
+ private void setChecksumAttribute(Path path, long checksum) {
+ try {
+ UserDefinedFileAttributeView view = Files.getFileAttributeView(path, UserDefinedFileAttributeView.class);
+ if(view != null) {
+ ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES);
+ buffer.putLong(checksum);
+ buffer.flip();
+ view.write(CHECKSUM_ATTRIBUTE_NAME, buffer);
+ }
+ }
+ catch(IOException | UnsupportedOperationException | IllegalArgumentException | ClassCastException e) {
+ logger.logDebug(e.toString());
+ }
+ }
+
+ private Long getFileChecksum(Path path) {
+ Long checksum = null;
+ try {
+ byte[] bytes = Files.readAllBytes(path);
+ CRC32 crc = new CRC32();
+ crc.update(bytes);
+ checksum = crc.getValue();
+ }
+ catch(IOException e) {
+ logger.logDebug(e.toString());
+ }
+ return checksum;
+ }
+
+ private static class FileCleaner implements FileVisitor<Path> {
+
+ private Set<Path> excludedFiles;
+ private ILogger logger;
+
+ public FileCleaner(Set<Path> excludedFiles, ILogger logger) {
+ this.excludedFiles = excludedFiles;
+ this.logger = logger;
+ }
+
+ @Override
+ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
+ if(!excludedFiles.contains(file)) {
+ Files.delete(file);
+ logger.logDebug("deleting file " + file);
+ }
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
+ return FileVisitResult.CONTINUE;
+ }
+
+ };
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/IGeneratorFileIO.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/IGeneratorFileIO.java
index add4e6cb5..7e6c366c4 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/IGeneratorFileIO.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/IGeneratorFileIO.java
@@ -21,26 +21,26 @@ import com.google.inject.ImplementedBy;
* @author Henrik Rentz-Reichert
*
*/
-@ImplementedBy(IncrementalGeneratorFileIO.class)
+@ImplementedBy(GeneratorFileIO.class)
public interface IGeneratorFileIO {
/**
* Saves the contents in a file at the given path.
*
* @param filePath the file path of the generated file
- * @param contents the contents of the generated file
+ * @param content the contents of the generated file
*/
- void generateFile(String filePath, CharSequence contents);
+ void generateFile(String filePath, CharSequence content);
/**
* This method saves the contents in a file in the given path.
*
* @param description a description which may be logged
* @param filePath the file path name of the generated file
- * @param contents the contents of the generated file
+ * @param content the contents of the generated file
*/
- default void generateFile(String description, String filePath, CharSequence contents) {
- generateFile(filePath, contents);
+ default void generateFile(String description, String filePath, CharSequence content) {
+ generateFile(filePath, content);
}
}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/IncrementalGeneratorFileIO.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/IncrementalGeneratorFileIO.java
deleted file mode 100644
index 2b77dd467..000000000
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/IncrementalGeneratorFileIO.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2013 protos software gmbh (http://www.protos.de).
-* All rights reserved.
-*
-* This program and the accompanying materials are made
-* available under the terms of the Eclipse Public License 2.0
-* which is available at https://www.eclipse.org/legal/epl-2.0/
-*
-* SPDX-License-Identifier: EPL-2.0
-*
-* CONTRIBUTORS:
-* Henrik Rentz-Reichert (initial contribution)
-*
- *******************************************************************************/
-
-package org.eclipse.etrice.generator.base.io;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.zip.CRC32;
-
-import org.apache.commons.io.FileUtils;
-import org.eclipse.etrice.generator.base.logging.ILogger;
-import org.eclipse.etrice.generator.base.logging.NullLogger;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.util.RuntimeIOException;
-
-import com.google.inject.Inject;
-
-/**
- * @author Henrik Rentz-Reichert
- *
- */
-public class IncrementalGeneratorFileIO implements IGeneratorFileIO {
-
- private String genDir;
- private String genInfoDir;
- private ILogger logger;
- private boolean generateIncremental;
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- public IncrementalGeneratorFileIO(JavaIoFileSystemAccess fileAccess) {
- setGenDir("src-gen");
- setGenInfoDir("src-gen-info");
- setGenerateIncremental(false);
- setLogger(new NullLogger());
-
- this.fileAccess = fileAccess;
- }
-
- /**
- * This method computes a hash key (a {@link java.util.zip.CRC32 CRC32} value) for the file contents
- * and compares it to the
- * one stored in the {@code infopath} directory with an added extension ".info". If the values are equal
- * then the file stored in the {@code infopath} is copied to {@code path} while preserving the file data.
- * In the other case the key is stored and the file is stored to {@code infopath} and {@code path}.
- */
- @Override
- public void generateFile(String desc, String file, CharSequence contents) {
-
- long oldCRC = 0;
-
- // use local copy to avoid inconsistencies due to concurrent change
- boolean genInc = generateIncremental;
-
- if (genInc) {
- // read old CRC value
- fileAccess.setOutputPath(genInfoDir);
- try {
- CharSequence val = fileAccess.readTextFile(file+".info", JavaIoFileSystemAccess.DEFAULT_OUTPUT);
- oldCRC = Long.parseLong(val.toString());
- }
- catch (RuntimeIOException e) {
- }
- catch (NumberFormatException e) {
- }
- }
-
- boolean write = true;
- long newCRC = 0;
-
- if (genInc) {
- CRC32 crc32 = new CRC32();
- crc32.update(contents.toString().getBytes());
- newCRC = crc32.getValue();
- if (oldCRC==newCRC) {
- write = false;
- }
- else {
- fileAccess.generateFile(file+".info", ""+newCRC);
- }
- }
-
- if (write) {
- logger.logInfo(desc+" '"+file+"'");
- fileAccess.setOutputPath(genDir);
- fileAccess.generateFile(file, contents);
-
- if (genInc) {
- // save a copy in the info directory which is not cleared (and not compiled)
- fileAccess.setOutputPath(genInfoDir);
- fileAccess.generateFile(file + ".incgen.txt", contents);
- }
- }
- else {
- logger.logInfo(desc+" (unchanged) '"+file+"'");
- File src = new File(genInfoDir+file + ".incgen.txt");
- File dst = new File(genDir+file);
- try {
- FileUtils.copyFile(src, dst, true);
- }
- catch (IOException e) {
- fileAccess.setOutputPath(genDir);
- fileAccess.generateFile(file, contents);
- }
- }
- }
-
- @Override
- public void generateFile(String file, CharSequence contents) {
- generateFile("generating file", file, contents);
- }
-
- public void setGenDir(String genDir) {
- this.genDir = genDir + "/";
- }
-
- public void setGenInfoDir(String genInfoDir) {
- this.genInfoDir = genInfoDir + "/";
- }
-
- public void setGenerateIncremental(boolean generateIncremental) {
- this.generateIncremental = generateIncremental;
- }
-
- public void setLogger(ILogger logger) {
- this.logger = logger;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationModule.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationModule.java
index a019b7973..bd3c51f84 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationModule.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationModule.java
@@ -16,7 +16,6 @@
package org.eclipse.etrice.generator.base.setup;
import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.xtext.parser.IEncodingProvider;
import org.eclipse.xtext.resource.XtextResourceSet;
import com.google.inject.Binder;
@@ -30,7 +29,6 @@ public abstract class GeneratorApplicationModule implements Module {
@Override
public void configure(Binder binder) {
binder.bind(ResourceSet.class).to(XtextResourceSet.class);
- binder.bind(IEncodingProvider.class).to(IEncodingProvider.Runtime.class);
}
}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationOptions.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationOptions.java
index 0b5533d7a..7e92aeab2 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationOptions.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationOptions.java
@@ -47,27 +47,36 @@ public class GeneratorApplicationOptions implements IOptionModule {
"display this help text",
false);
+ @Deprecated
public static final BooleanOption GEN_INCREMENTAL = new BooleanOption(
GROUP_APPLICATION,
"inc",
"isInc",
- "if specified the generation is incremental",
+ "if specified the generation is incremental (deprecated)",
false);
public static final StringOption GEN_DIR = new StringOption(
GROUP_APPLICATION,
"genDir",
"directory",
- "the directory for generated files",
+ "the output directory for generated files",
"src-gen");
+ @Deprecated
public static final StringOption GEN_INFO_DIR = new StringOption(
GROUP_APPLICATION,
"genInfoDir",
"directory",
- "the directory for generated info files",
+ "the directory for generated info files (deprecated)",
"src-gen-info");
+ public static final BooleanOption CLEAN = new BooleanOption(
+ GROUP_APPLICATION,
+ "clean",
+ "isClean",
+ "if specified obsolete files in the output directory are removed",
+ false);
+
public static final EnumOption<Loglevel> LOGLEVEL = new EnumOption<>(
Loglevel.class,
GROUP_APPLICATION,
@@ -83,6 +92,7 @@ public class GeneratorApplicationOptions implements IOptionModule {
options.add(GEN_INCREMENTAL);
options.add(GEN_DIR);
options.add(GEN_INFO_DIR);
+ options.add(CLEAN);
options.add(LOGLEVEL);
}
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 9279f22a7..18e90df79 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
@@ -44,7 +44,7 @@ class NodeRunnerGen {
val clsname = nr.name+"_"+ssi.name
val path = ssi.subSystemClass.getPath
val file = clsname + "_Runner.c"
- fileIO.generateFile(path + file, root.generateSourceFile(ssi, first))
+ fileIO.generateFile("generating Node runner file", path + file, root.generateSourceFile(ssi, first))
first = false
}
}
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 fcc7ca8d4..da563b65f 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
@@ -73,7 +73,6 @@ public abstract class GeneratorConfigTab extends AbstractLaunchConfigurationTab
public static final String OVERRIDE_DIRECTORIES = "OverrideDirectories";
public static final String GEN_DEPS_WITHIN_PROJECT = "GenerateDepsWithinProject";
public static final String SRCGEN_PATH = "SrcgenPath";
- public static final String INFO_PATH = "InfoPath";
private Button libButton;
private Button saveGenModel;
@@ -86,7 +85,6 @@ public abstract class GeneratorConfigTab extends AbstractLaunchConfigurationTab
private Button generateDepsWithinProject;
private Button overrideDirectories;
private Text srcgenPath;
- private Text infoPath;
protected Button dataButton;
private Text mainMethodName;
@@ -212,19 +210,6 @@ public abstract class GeneratorConfigTab extends AbstractLaunchConfigurationTab
}
});
- label = new Label(mainComposite, SWT.NONE);
- label.setText("The directory for i&nformation about generated code:");
- infoPath = new Text(mainComposite, SWT.SINGLE | SWT.BORDER);
- infoPath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- infoPath.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- validate();
- setDirty(true);
- updateLaunchConfigurationDialog();
- }
- });
-
addFurtherControls(mainComposite);
}
@@ -246,11 +231,9 @@ public abstract class GeneratorConfigTab extends AbstractLaunchConfigurationTab
protected void handleOverrideDirectories() {
boolean override = overrideDirectories.getSelection();
srcgenPath.setEnabled(override);
- infoPath.setEnabled(override);
if (!override) {
ScopedPreferenceStore prefStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.etrice.generator.ui");
srcgenPath.setText(prefStore.getString(PreferenceConstants.GEN_DIR));
- infoPath.setText(prefStore.getString(PreferenceConstants.GEN_INFO_DIR));
}
validate();
setDirty(true);
@@ -324,17 +307,13 @@ public abstract class GeneratorConfigTab extends AbstractLaunchConfigurationTab
boolean override = configuration.getAttribute(OVERRIDE_DIRECTORIES, false);
String srcgenDir = prefStore.getString(PreferenceConstants.GEN_DIR);
- String infoDir = prefStore.getString(PreferenceConstants.GEN_INFO_DIR);
overrideDirectories.setSelection(override);
srcgenPath.setEnabled(override);
- infoPath.setEnabled(override);
if (override) {
srcgenPath.setText(configuration.getAttribute(SRCGEN_PATH, srcgenDir));
- infoPath.setText(configuration.getAttribute(INFO_PATH, infoDir));
}
else {
srcgenPath.setText(srcgenDir);
- infoPath.setText(infoDir);
}
generateDepsWithinProject.setSelection(configuration.getAttribute(GEN_DEPS_WITHIN_PROJECT, true));
@@ -363,7 +342,6 @@ public abstract class GeneratorConfigTab extends AbstractLaunchConfigurationTab
configuration.setAttribute(OVERRIDE_DIRECTORIES, override);
if (override) {
configuration.setAttribute(SRCGEN_PATH, srcgenPath.getText());
- configuration.setAttribute(INFO_PATH, infoPath.getText());
}
configuration.setAttribute(GEN_DEPS_WITHIN_PROJECT, generateDepsWithinProject.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 73f11bb4c..bc3ced09f 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
@@ -211,25 +211,18 @@ public abstract class GeneratorLaunchConfigurationDelegate extends AbstractJavaL
}
ScopedPreferenceStore prefStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.etrice.generator.ui");
- if (prefStore.getBoolean(PreferenceConstants.GEN_INCREMENTAL)) {
- argString.append(" -"+GeneratorApplicationOptions.GEN_INCREMENTAL.getName());
- }
String projectDir = project.getLocation().toString() + "/";
boolean override = configuration.getAttribute(GeneratorConfigTab.OVERRIDE_DIRECTORIES, false);
String srcgenDir = prefStore.getString(PreferenceConstants.GEN_DIR);
- String infoDir = prefStore.getString(PreferenceConstants.GEN_INFO_DIR);
if (override) {
srcgenDir = configuration.getAttribute(GeneratorConfigTab.SRCGEN_PATH, srcgenDir);
- infoDir = configuration.getAttribute(GeneratorConfigTab.INFO_PATH, infoDir);
}
argString.append(" -"+GeneratorApplicationOptions.GEN_DIR.getName());
argString.append(" \""+projectDir+srcgenDir+"\"");
-
- argString.append(" -"+GeneratorApplicationOptions.GEN_INFO_DIR.getName());
- argString.append(" \""+projectDir+infoDir+"\"");
+ argString.append(" -clean");
}
/**
diff --git a/plugins/org.eclipse.etrice.generator.ui.cdt/src/org/eclipse/etrice/generator/ui/cdt/ProjectConfigurator.java b/plugins/org.eclipse.etrice.generator.ui.cdt/src/org/eclipse/etrice/generator/ui/cdt/ProjectConfigurator.java
index 1fa24f097..e5d1174c4 100644
--- a/plugins/org.eclipse.etrice.generator.ui.cdt/src/org/eclipse/etrice/generator/ui/cdt/ProjectConfigurator.java
+++ b/plugins/org.eclipse.etrice.generator.ui.cdt/src/org/eclipse/etrice/generator/ui/cdt/ProjectConfigurator.java
@@ -15,18 +15,13 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.etrice.generator.ui.configurator.IProjectConfigurator;
-import org.eclipse.etrice.generator.ui.preferences.PreferenceConstants;
-import org.eclipse.ui.preferences.ScopedPreferenceStore;
/*
* Docs:
@@ -113,16 +108,9 @@ public abstract class ProjectConfigurator implements IProjectConfigurator {
ICProjectDescription projectDescription = CoreModel.getDefault().getProjectDescription(project, true);
- ScopedPreferenceStore prefStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.etrice.generator.ui");
- String infoDir = prefStore.getString(PreferenceConstants.GEN_INFO_DIR);
- IFolder srcGenInfoFolder = project.getFolder(infoDir);
-
// it is not necessary to actually create this folder here
// srcGenInfoFolder.create(false, true, new SubProgressMonitor(progressMonitor, 1));
- IPath srcGenInfoPath = srcGenInfoFolder.getFullPath();
- srcGenInfoPath = srcGenInfoPath.removeFirstSegments(1);
-
// all build configurations e.g. Debug, Release
for (ICConfigurationDescription configDescription : projectDescription.getConfigurations()) {
if (configDescription.getId() == null)
@@ -136,11 +124,6 @@ public abstract class ProjectConfigurator implements IProjectConfigurator {
else if (POSIX_TOOLCHAIN.equals(toolChainName))
toolChain = POSIX_TOOLCHAIN;
- IFolderInfo folderInfo = buildConfig.createFolderInfo(srcGenInfoPath);
- if (folderInfo!=null) {
- folderInfo.setExclude(true);
- }
-
customizeBuildConfig(project, buildConfig);
// set project references
diff --git a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/GeneratorPreferencePage.java b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/GeneratorPreferencePage.java
index 1f1d3e0ff..ca8a5c774 100644
--- a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/GeneratorPreferencePage.java
+++ b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/GeneratorPreferencePage.java
@@ -35,11 +35,6 @@ public class GeneratorPreferencePage
}, getFieldEditorParent()));
addField(
new BooleanFieldEditor(
- PreferenceConstants.GEN_INCREMENTAL,
- "Generate &incrementally",
- getFieldEditorParent()));
- addField(
- new BooleanFieldEditor(
PreferenceConstants.GEN_USE_TRANSLATION,
"Let wizard create new launchers with detail code translation on initially",
getFieldEditorParent()));
@@ -50,11 +45,6 @@ public class GeneratorPreferencePage
getFieldEditorParent()));
addField(
new StringFieldEditor(
- PreferenceConstants.GEN_INFO_DIR,
- "The directory for i&nformation about generated code:",
- getFieldEditorParent()));
- addField(
- new StringFieldEditor(
PreferenceConstants.GEN_DOC_DIR,
"The directory for generated &documentation:",
getFieldEditorParent()));
diff --git a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceConstants.java b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceConstants.java
index 7ec1ac5b8..f1b72f185 100644
--- a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceConstants.java
+++ b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceConstants.java
@@ -6,8 +6,6 @@ package org.eclipse.etrice.generator.ui.preferences;
public class PreferenceConstants {
public static final String GEN_DIR = "GenerationDirectory";
- public static final String GEN_INFO_DIR = "GenerationInfoDirectory";
- public static final String GEN_INCREMENTAL = "GenerateIncremental";
public static final String GEN_DOC_DIR = "GeneratedDocuDirectory";
public static final String GEN_USE_TRANSLATION = "GenerateUsingTranslation";
diff --git a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceInitializer.java b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceInitializer.java
index 766c174ed..a2e36e141 100644
--- a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceInitializer.java
+++ b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceInitializer.java
@@ -17,9 +17,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
public void initializeDefaultPreferences() {
IPreferenceStore store = Activator.getInstance().getPreferenceStore();
store.setDefault(PreferenceConstants.BUILD_KIND, PreferenceConstants.JDT);
- store.setDefault(PreferenceConstants.GEN_INCREMENTAL, true);
store.setDefault(PreferenceConstants.GEN_DIR, "src-gen");
- store.setDefault(PreferenceConstants.GEN_INFO_DIR, "src-gen-info");
store.setDefault(PreferenceConstants.GEN_DOC_DIR, "doc-gen");
store.setDefault(PreferenceConstants.GEN_USE_TRANSLATION, true);
}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java
index 6820898a2..ecffc6499 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java
@@ -19,7 +19,7 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician;
import org.eclipse.etrice.generator.base.io.IGeneratorEMFSetup;
import org.eclipse.etrice.generator.base.io.IGeneratorResourceLoader;
-import org.eclipse.etrice.generator.base.io.IncrementalGeneratorFileIO;
+import org.eclipse.etrice.generator.base.io.GeneratorFileIO;
import org.eclipse.etrice.generator.base.logging.Logger;
import org.eclipse.etrice.generator.base.setup.GeneratorApplicationModule;
import org.eclipse.etrice.generator.base.setup.GeneratorBaseOptions;
@@ -66,7 +66,7 @@ public abstract class AbstractGeneratorBaseModule extends GeneratorApplicationMo
binder.bind(ResourceSet.class).to(XtextResourceSet.class);
binder.bind(Logger.class).in(Singleton.class);
- binder.bind(IncrementalGeneratorFileIO.class).in(Singleton.class);
+ binder.bind(GeneratorFileIO.class).in(Singleton.class);
binder.bind(IGenerator.class).to(AbstractGenerator.class);
binder.bind(GeneratorBaseOptions.class).to(AbstractGeneratorOptions.class);

Back to the top