⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sotask.java

📁 Tomcat 4.1与WebServer集成组件的源代码包.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    /** Set the target for this compilation. Don't include any     *  directory or suffix ( not sure about prefix - we may want     *  to add lib automatically for unix, and nothing on win/etc ?  ).     */    public void setTarget(String s ) {        soFile=s;    }    /** Set the extension for the target.  This will depend on the platform     *  we are compiling for.     */    public void setExtension(String s ) {        soExt=s;    }    /** Directory where intermediary objects will be     *  generated     */    public void setBuildDir( File s ) {        buildDir=s;    }    public void setCflags(String s ) {        cflags=s;    }        /** Directory where the .so file will be generated     */    public void setSoDir( String s ) {            }    public void addJniConfig( JniConfig jniCfg ) {    }    public void addApacheConfig( ApacheConfig apacheCfg ) {    }            /**     * Source files ( .c )     *     * @return a nested src element.     */    public void addSrc(FileSet fl) {        if( src==null ) src=new Vector();        src.addElement(fl);    }    /**     * Include files     */    public PatternSet createIncludes() {        includes=new PatternSet(); //Path(project);        return includes;    }    /**     * General dependencies. If any of the files is modified     * ( i.e. is newer than the oldest .o ) we'll recompile everything.     *     * This can be used for headers ( until we add support for makedepend)     * or any important file that could invalidate the build.     * Another example is checking httpd or apxs ( if a new version     * was installed, maybe some flags or symbols changed )     */    public Path createDepends() {        depends=new Path(project);        return depends;    }    /**     * Libraries ( .a, .so or .dll ) files to link to.     */    public Path createLibs() {        libs=new Path(project);        return libs;    }            /**     * The name of the target file.     * (XXX including extension - this should be automatically added )     */    public void setModule(String modName) {        this.module = module;    }    // XXX Add specific code for Netware, Windows and platforms where libtool    // is problematic    // XXX Add specific code for Linux and platforms where things are    // clean, libtool should be just a fallback.    public void execute() throws BuildException {        compiler=findCompilerAdapter();        //      co_mapper=compiler.getOMapper();        LinkerAdapter linker=findLinkerAdapter();        if( soFile==null )            throw new BuildException("No target ( " + soExt + " file )");        if (src == null)             throw new BuildException("No source files");        // XXX makedepend-type dependencies - how ??        // We could generate a dummy Makefile and parse the content...        findSourceFiles();        // Copy all settings into compiler        this.duplicateTo(compiler);        compiler.compile( srcList );        // XXX move this checking to linker        File soTarget=new File( buildDir, soFile + soExt );        if( compiler.getCompiledFiles().size() == 0 && soTarget.exists()) {            // No dependency, no need to relink            return;        }        this.duplicateTo(linker);        linker.link(srcList);    }    public CompilerAdapter findCompilerAdapter() {        CompilerAdapter compilerAdapter;        String cc;        cc=project.getProperty("build.compiler.cc");        if( cc!=null ) {            if( "cc".equals( cc ) ) {                compilerAdapter=new CcCompiler();                compilerAdapter.setSoTask( this );                return compilerAdapter;            }            if( "gcj".equals( cc ) ) {                compilerAdapter=new GcjCompiler();                compilerAdapter.setSoTask( this );                return compilerAdapter;            }            if( cc.indexOf("mwccnlm") != -1 ) {                compilerAdapter=new MwccCompiler();                compilerAdapter.setSoTask( this );                return compilerAdapter;            }            if( cc.indexOf("cl") != -1 ) {                compilerAdapter=new MsvcCompiler();                compilerAdapter.setSoTask( this );                return compilerAdapter;            }        }                compilerAdapter=new LibtoolCompiler();         compilerAdapter.setSoTask( this );        return compilerAdapter;   }    public LinkerAdapter findLinkerAdapter() {        LinkerAdapter linkerAdapter;        String ld=project.getProperty("build.compiler.ld");        if( ld!=null ) {            if( ld.indexOf("mwldnlm") != -1 ) {                linkerAdapter=new MwldLinker();                linkerAdapter.setSoTask( this );                return linkerAdapter;            }            if( ld.indexOf("link") != -1 ) {                linkerAdapter=new MsvcLinker();                linkerAdapter.setSoTask( this );                return linkerAdapter;            }            //      if( "ld".equals( cc ) ) {            //          linkerAdapter=new LdLinker();            //          linkerAdapter.setSoTask( this );            //          return cc;            //      }        }        String cc=project.getProperty("build.compiler.cc");        if( "gcj".equals( cc ) ) {            linkerAdapter=new GcjLinker();            linkerAdapter.setSoTask( this );            return linkerAdapter;        }                linkerAdapter=new LibtoolLinker();         linkerAdapter.setSoTask( this );        return linkerAdapter;   }    /** Find all source files declared with <src> elements     */    public void findSourceFiles() {        if (buildDir == null) buildDir = project.getBaseDir();        Enumeration e=src.elements();        while( e.hasMoreElements() ) {            FileSet fs=(FileSet)e.nextElement();            DirectoryScanner ds=fs.getDirectoryScanner( project );            String localList[]= ds.getIncludedFiles();             if (localList.length == 0)                 throw new BuildException("No source files ");            for( int i=0; i<localList.length; i++ ) {                srcList.addElement( new Source( fs.getDir(project), localList[i]));            }        }    }     /** If any file declared in <depend> element has changed, we'll do        a full rebuild.    */    public boolean checkDepend(long oldestO, File oldestOFile) {        if( depends==null )            return false;        String dependsA[]=depends.list();         for( int i=0; i< dependsA.length; i++ ) {            File f=new File( dependsA[i] );            if( ! f.exists() ) {                log("Depend not found " + f );                return true;            }            if( f.lastModified() > oldestO ) {                log( "Depend " + f + " newer than " + oldestOFile );                return true;            }        }        return false;    }        // ==================== Execution utils ====================     protected ExecuteStreamHandler streamhandler = null;    protected ByteArrayOutputStream outputstream = null;    protected ByteArrayOutputStream errorstream = null;    public int execute( Commandline cmd ) throws BuildException    {        createStreamHandler();        Execute exe = new Execute(streamhandler, null);        exe.setAntRun(project);        exe.setWorkingDirectory(buildDir);        exe.setCommandline(cmd.getCommandline());        int result=0;        try {            result=exe.execute();        } catch (IOException e) {            throw new BuildException(e, location);        }         return result;    }    public void createStreamHandler()  throws BuildException {        //      try {        outputstream= new ByteArrayOutputStream();        errorstream = new ByteArrayOutputStream();                streamhandler =            new PumpStreamHandler(new PrintStream(outputstream),                                  new PrintStream(errorstream));        //      }  catch (IOException e) {        //          throw new BuildException(e,location);        //      }    }    public void closeStreamHandler() {        try {            if (outputstream != null)                 outputstream.close();            if (errorstream != null)                 errorstream.close();            outputstream=null;            errorstream=null;        } catch (IOException e) {}    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -