activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r587210 - /activemq/activemq-cpp/trunk/src/main/java/org/apache/activemq/openwire/tool/AmqCppMakefileGenerator.java
Date Mon, 22 Oct 2007 19:22:54 GMT
Author: tabish
Date: Mon Oct 22 12:22:53 2007
New Revision: 587210

URL: http://svn.apache.org/viewvc?rev=587210&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-142

Adding in the ability to generate the makefiles for each of the gerneated targets.

Added:
    activemq/activemq-cpp/trunk/src/main/java/org/apache/activemq/openwire/tool/AmqCppMakefileGenerator.java

Added: activemq/activemq-cpp/trunk/src/main/java/org/apache/activemq/openwire/tool/AmqCppMakefileGenerator.java
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/java/org/apache/activemq/openwire/tool/AmqCppMakefileGenerator.java?rev=587210&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/java/org/apache/activemq/openwire/tool/AmqCppMakefileGenerator.java
(added)
+++ activemq/activemq-cpp/trunk/src/main/java/org/apache/activemq/openwire/tool/AmqCppMakefileGenerator.java
Mon Oct 22 12:22:53 2007
@@ -0,0 +1,151 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.openwire.tool;
+
+import java.util.Iterator;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.FixCRLF;
+
+/**
+*
+* @version $Revision: 379734 $
+*/
+public abstract class AmqCppMakefileGenerator {
+
+    protected String targetDir="./src/main";
+
+    protected ArrayList<String> sources = null;
+    protected ArrayList<String> headers = null;
+
+    protected File destDir;
+    protected File destFile;
+    protected StringBuffer buffer;
+
+    protected String getFilePostFix() {
+        return ".mk";
+    }
+
+    protected String getFilePrefix() {
+        return "srcmakefile";
+    }
+
+    /**
+     * Derived classes provide the location of the Makefile.
+     */
+    abstract protected File getDestDir();
+
+    public void run() {
+
+        destDir = getDestDir();
+
+        if( destDir == null ) {
+            throw new IllegalArgumentException("No destDir defined!");
+        }
+
+        if( sources == null || headers == null ) {
+            throw new IllegalStateException("File lists not initialized.");
+        }
+
+        System.out.println(getClass().getName() + " generating files in: " + destDir);
+        destDir.mkdirs();
+        buffer = new StringBuffer();
+
+        destFile = new File( destDir, getFilePrefix() + getFilePostFix() );
+
+        PrintWriter out = null;
+        try {
+            out = new PrintWriter(new FileWriter(destFile));
+            generateFile(out);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (out != null) {
+                out.close();
+            }
+        }
+
+        // Use the FixCRLF Ant Task to make sure the file has consistent
+        // newlines so that SVN does not complain on checkin.
+        Project project = new Project();
+        project.init();
+        FixCRLF fixCRLF = new FixCRLF();
+        fixCRLF.setProject(project);
+        fixCRLF.setSrcdir(destFile.getParentFile());
+        fixCRLF.setIncludes(destFile.getName());
+        fixCRLF.execute();
+    }
+
+    protected void generateLicence(PrintWriter out) {
+        out.println("# ---------------------------------------------------------------------------");
+        out.println("# Licensed to the Apache Software Foundation (ASF) under one or more");
+        out.println("# contributor license agreements.  See the NOTICE file distributed with");
+        out.println("# this work for additional information regarding copyright ownership.");
+        out.println("# The ASF licenses this file to You under the Apache License, Version
2.0");
+        out.println("# (the \"License\"); you may not use this file except in compliance
with");
+        out.println("# the License.  You may obtain a copy of the License at");
+        out.println("# ");
+        out.println("# http://www.apache.org/licenses/LICENSE-2.0");
+        out.println("# ");
+        out.println("# Unless required by applicable law or agreed to in writing, software");
+        out.println("# distributed under the License is distributed on an \"AS IS\" BASIS,");
+        out.println("# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
+        out.println("# See the License for the specific language governing permissions and");
+        out.println("# limitations under the License.");
+        out.println("# ---------------------------------------------------------------------------");
+    }
+
+    protected void generateFile(PrintWriter out) {
+        generateLicence(out);
+
+        out.println("");
+        out.print("cc_sources += ");
+
+        for( String source : sources ) {
+            out.println(" \\");
+            out.print("    " + source);
+        }
+
+        out.println("");
+        out.print("h_sources += ");
+
+        for( String header : headers ) {
+            out.println(" \\");
+            out.print("    " + header);
+        }
+
+        out.println("");
+    }
+
+    public void setDestDir(File destDir) {
+        this.destDir = destDir;
+    }
+
+    public File getDestFile() {
+        return destFile;
+    }
+
+    public void setDestFile(File destFile) {
+        this.destFile = destFile;
+    }
+
+}



Mime
View raw message