Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 14188 invoked from network); 22 Oct 2007 19:23:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Oct 2007 19:23:45 -0000 Received: (qmail 32306 invoked by uid 500); 22 Oct 2007 19:23:33 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 32273 invoked by uid 500); 22 Oct 2007 19:23:33 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 32264 invoked by uid 99); 22 Oct 2007 19:23:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Oct 2007 12:23:33 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Oct 2007 19:23:45 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 640321A9838; Mon, 22 Oct 2007 12:22:54 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071022192254.640321A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 sources = null; + protected ArrayList 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; + } + +}