1 16 17 package org.apache.jk.ant.compilers; 18 19 import java.io.File ; 20 import java.util.Enumeration ; 21 import java.util.Vector ; 22 23 import org.apache.jk.ant.Source; 24 import org.apache.tools.ant.BuildException; 25 import org.apache.tools.ant.types.Commandline; 26 27 37 public class LibtoolCompiler extends CcCompiler { 38 39 public LibtoolCompiler() { 40 super(); 41 }; 42 43 public void compile(Vector sourceFiles ) throws BuildException { 44 compileList=findCompileList(sourceFiles); 45 46 log("Compiling " + compileList.size() + " out of " + sourceFiles.size()); 47 Enumeration en=compileList.elements(); 48 while( en.hasMoreElements() ) { 49 Source source=(Source)en.nextElement(); 50 compileSingleFile(source); 51 } 52 } 53 54 55 57 public void compileSingleFile(Source sourceObj) throws BuildException { 58 File f=sourceObj.getFile(); 59 String source=f.toString(); 60 Commandline cmd = new Commandline(); 61 62 String libtool=project.getProperty("build.native.libtool"); 63 if(libtool==null) libtool="libtool"; 64 65 cmd.setExecutable( libtool ); 66 67 cmd.createArgument().setValue("--mode=compile"); 68 69 String cc=project.getProperty("build.native.cc"); 70 if(cc==null) cc="cc"; 71 72 cmd.createArgument().setValue( cc ); 73 74 cmd.createArgument().setValue( "-c" ); 75 76 cmd.createArgument().setValue( "-o" ); 77 78 File ff=new File ( buildDir, sourceObj.getTargetFile(co_mapper)); 79 cmd.createArgument().setValue( ff.toString() ); 80 try { 81 String targetDir=sourceObj.getPackage(); 82 File f1=new File ( buildDir, targetDir ); 83 f1.mkdirs(); 84 } catch( Exception ex ) { 86 ex.printStackTrace(); 87 } 88 89 addIncludes(cmd); 90 addExtraFlags( cmd ); 91 addDebug(cmd); 92 addDefines( cmd ); 93 addOptimize( cmd ); 94 addProfile( cmd ); 95 96 project.log( "Compiling " + source); 97 cmd.createArgument().setValue( source ); 98 99 if( debug > 0 ) project.log(cmd.toString()); 100 int result=execute( cmd ); 101 displayError( result, source, cmd ); 102 closeStreamHandler(); 103 } 104 } 105 106 | Popular Tags |