summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShevek <[email protected]>2008-05-08 20:08:23 +0000
committerShevek <[email protected]>2008-05-08 20:08:23 +0000
commit932a35e8b2734dfc14aac56c8b1dc96174a5b009 (patch)
treef179b742735e285311c281f9a7f7d3dc03611ebe
parentd7362497e323ee1d2e94165f9642e4b9a663a542 (diff)
add cpp task
-rw-r--r--etc/build.properties2
-rw-r--r--src/java/org/anarres/cpp/CppTask.java88
-rw-r--r--src/scripts/release.sh2
3 files changed, 90 insertions, 2 deletions
diff --git a/etc/build.properties b/etc/build.properties
index cb853cb..8d59b87 100644
--- a/etc/build.properties
+++ b/etc/build.properties
@@ -1,4 +1,4 @@
-global.version = 1.0.10
+global.version = 1.2.0
global.name = anarres-cpp
global.dir.arch = ${global.dir.root}/arch
diff --git a/src/java/org/anarres/cpp/CppTask.java b/src/java/org/anarres/cpp/CppTask.java
new file mode 100644
index 0000000..b3d2e4c
--- /dev/null
+++ b/src/java/org/anarres/cpp/CppTask.java
@@ -0,0 +1,88 @@
+package de.tu_darmstadt.informatik.rbg.mhartle.cpp;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+import org.anarres.cpp.LexerException;
+import org.anarres.cpp.Preprocessor;
+import org.anarres.cpp.Token;
+
+public class CppTask extends Task {
+
+ public static class Macro {
+ private String name;
+ private String value;
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+ }
+
+ private File input = null;
+ private File output = null;
+ private Preprocessor cpp;
+
+ public CppTask() {
+ super();
+ cpp = new Preprocessor();
+ }
+
+ public void setInput(File input) {
+ this.input = input;
+ }
+
+ public void setOutput(File output) {
+ this.output = output;
+ }
+
+ public void addMacro(Macro macro) {
+ try {
+ cpp.addMacro(macro.getName(), macro.getValue());
+ }
+ catch (LexerException e) {
+ throw new BuildException(e);
+ }
+ }
+
+ public void execute() {
+ FileWriter writer = null;
+ try {
+ writer = new FileWriter(this.output);
+ for (;;) {
+ Token tok = cpp.token();
+ if (tok != null && tok.getType() == Token.EOF)
+ break;
+ writer.write(tok.getText());
+ }
+ }
+ catch (Exception e) {
+ throw new BuildException(e);
+ }
+ finally {
+ if (writer != null) {
+ try {
+ writer.close();
+ }
+ catch (IOException e) {
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/scripts/release.sh b/src/scripts/release.sh
index 620ce96..7904468 100644
--- a/src/scripts/release.sh
+++ b/src/scripts/release.sh
@@ -1,4 +1,4 @@
scp build/dist/anarres-cpp-*.tar.gz [email protected]:public_html/projects/jcpp/
scp -r build/javadoc/ [email protected]:public_html/projects/jcpp/
-cp build/tar/lib/anarres-cpp.jar /home/shevek/java/iengine/lib/runtime/jcpp/
+cp build/tar/lib/anarres-cpp.jar /home/shevek/java/iengine/trunk/lib/runtime/jcpp/
cp build/tar/lib/anarres-cpp.jar /home/shevek/java/karma/trunk/lib/dp/