tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jk/jkant/java/org/apache/jk/ant/compilers GcjLinker.java GcjCompiler.java
Date Sat, 10 Nov 2001 16:48:38 GMT
costin      01/11/10 08:48:38

  Modified:    jk/jkant/java/org/apache/jk/ant/compilers GcjCompiler.java
  Added:       jk/jkant/java/org/apache/jk/ant/compilers GcjLinker.java
  Log:
  The GCJ compiler is now operational ( it's the GCC frontent for java ). I used
  GCC3.0.1, there are still some bugs with embeded classes and .write method
  ( which is declared to throw exception, as in the javadocs, but doesn't in the
  'official' sdk ), but after minor changes in the code I was able to compile
  almost everything rhud has.
  
  ( thanks to Caltrain and my longer commute I have time to play with cool toys :-)
  
  Revision  Changes    Path
  1.3       +30 -12    jakarta-tomcat-connectors/jk/jkant/java/org/apache/jk/ant/compilers/GcjCompiler.java
  
  Index: GcjCompiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/jkant/java/org/apache/jk/ant/compilers/GcjCompiler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GcjCompiler.java	2001/11/09 18:18:18	1.2
  +++ GcjCompiler.java	2001/11/10 16:48:38	1.3
  @@ -68,32 +68,51 @@
    * 
    * @author Costin Manolache
    */
  -public class GcjCompiler extends BaseCompiler {
  +public class GcjCompiler extends CompilerAdapter {
  +    static GlobPatternMapper co_mapperS=new GlobPatternMapper();
  +    static {
  +	co_mapperS.setFrom("*.java");
  +	co_mapperS.setTo("*.o");
  +    }
       
       public GcjCompiler() {
   	super();
       }
   
       public GlobPatternMapper getOMapper() {
  -	GlobPatternMapper co_mapper=new GlobPatternMapper();
  -	co_mapper.setFrom("*.java");
  -	co_mapper.setTo("*.o");
  -
  -	return co_mapper;
  +	return co_mapperS;
       }
   
       /** Compile using libtool.
        */
  -    public void compileSingleFile(String source) throws BuildException {
  +    public void compileSingleFile(Source sourceObj) throws BuildException {
  +	File f=sourceObj.getFile();
  +	String source=f.toString();
   	Commandline cmd = new Commandline();
   
   	cmd.setExecutable( "gcj" );
  -	cmd.createArgument().setValue("-c");
   
  -	addDebug(cmd);
  +	cmd.createArgument().setValue("-c" );
  +	
  +	if( optG ) {
  +	    cmd.createArgument().setValue("-g" );
  +	    //  cmd.createArgument().setValue("-Wall");
  +	}
   	addOptimize( cmd );
  -
  +	addExtraFlags( cmd );
  +	cmd.createArgument().setValue("-fPIC" );
   	addIncludes( cmd );
  +
  +	cmd.createArgument().setValue( "-o" );
  +	File ff=new File( buildDir, sourceObj.getTargetFile(co_mapperS));
  +	cmd.createArgument().setValue( ff.toString() );
  +	try {
  +	    String targetDir=sourceObj.getPackage();
  +	    File f1=new File( buildDir, targetDir );
  +	    f1.mkdirs();
  +	} catch( Exception ex ) {
  +	    ex.printStackTrace();
  +	}
   	
   	cmd.createArgument().setValue( source );
   	project.log( "Compiling " + source);
  @@ -111,8 +130,7 @@
   	String [] includeList = ( includes==null ) ?
   	    new String[] {} : includes.getIncludePatterns(project); 
   	for( int i=0; i<includeList.length; i++ ) {
  -	    cmd.createArgument().setValue("-I");
  -	    cmd.createArgument().setValue(includeList[i] );
  +	    cmd.createArgument().setValue("-I" + includeList[i] );
   	}
       }
   
  
  
  
  1.1                  jakarta-tomcat-connectors/jk/jkant/java/org/apache/jk/ant/compilers/GcjLinker.java
  
  Index: GcjLinker.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.jk.ant.compilers;
  
  import org.apache.tools.ant.types.*;
  import org.apache.tools.ant.util.*;
  import org.apache.tools.ant.taskdefs.*;
  import org.apache.tools.ant.*;
  
  import org.apache.jk.ant.*;
  
  import java.io.*;
  import java.util.*;
  
  /**
   * Link java using gcj.
   * 
   * @author Costin Manolache
   */
  public class GcjLinker extends SoTask implements LinkerAdapter {
      SoTask so;
      protected static GlobPatternMapper lo_mapper=new GlobPatternMapper();
      static {
  	lo_mapper.setFrom("*.java");
  	lo_mapper.setTo("*.o");
      }
      public GcjLinker() {
  	so=this;
      };
  
      public void setSoTask(SoTask so ) {
  	this.so=so;
  	so.duplicateTo( this );
      }
  
      public void execute() throws BuildException {
  	findSourceFiles();
  	link(this.srcList);
      }
  
      /** Link using libtool.
       */
      public boolean link(Vector srcList) throws BuildException {
  	Commandline cmd = new Commandline();
  
  	cmd.setExecutable( "gcj" );
  
  	cmd.createArgument().setValue( "--shared" );
  	cmd.createArgument().setValue( "-o" );
  	cmd.createArgument().setValue( soFile + ".so" );
  
  	project.log( "Linking " + buildDir + "/" + soFile + ".so");
  
  	for( int i=0; i<srcList.size(); i++ ) {
  	    Source source=(Source)srcList.elementAt(i);
  	    File srcF=new File(buildDir, source.getTargetFile(co_mapper));
  	    cmd.createArgument().setValue( srcF.toString() );
  	}
  	
  	int result=execute( cmd );
  	if( result!=0 ) {
  	    log("Link failed " + result );
  	    log("Command:" + cmd.toString());
  	    log("Output:" );
  	    if( outputstream!=null ) 
  		log( outputstream.toString());
  	    log("StdErr:" );
  	    if( errorstream!=null ) 
  		log( errorstream.toString());
  	    
  	    throw new BuildException("Link failed " + soFile);
  	}
  	closeStreamHandler();
  
  	return true;
      }
  }
  
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message