Package net.sf.antcontrib.cpptasks

Examples of net.sf.antcontrib.cpptasks.CompilerDef


    RuntimeType runtimeType = new RuntimeType();
    runtimeType.setValue(getRuntime(getAOL()));
    task.setRuntime(runtimeType);

    // add C++ compiler
    CompilerDef cpp = getCpp().getCompiler(Compiler.MAIN,
        getOutput(getAOL()));
    if (cpp != null) {
      task.addConfiguredCompiler(cpp);
    }
   
    // add VCPROJ_MOJO def (see UnitTestDriverImpl.cpp generated by Krusoe plugin)
    DefineSet defineSet = new DefineSet();
    DefineArgument defineArgument = new DefineArgument();
    defineArgument.setName("VCPROJ_MOJO");
    defineSet.addDefine(defineArgument);
    cpp.addConfiguredDefineset(defineSet);
   
   
    // add javah include path
    File jniDirectory = getJavah().getJniDirectory();
    if (jniDirectory.exists()) {
View Full Code Here


        task.setRuntime(runtimeType);

        // Darren Sargent Feb 11 2010: Use Compiler.MAIN for "type"...appears the wrong "type" variable was being used
        // since getCompiler() expects "main" or "test", whereas the "type" variable here is "executable", "shared" etc.
        // add C++ compiler
        CompilerDef cpp = getCpp().getCompiler( Compiler.MAIN, getOutput( getAOL() ) );
        if ( cpp != null )
        {
            task.addConfiguredCompiler( cpp );
        }

        // add C compiler
        CompilerDef c = getC().getCompiler( Compiler.MAIN, getOutput( getAOL() ) );
        if ( c != null )
        {
            task.addConfiguredCompiler( c );
        }

        // add Fortran compiler
        CompilerDef fortran = getFortran().getCompiler( Compiler.MAIN, getOutput( getAOL() ) );
        if ( fortran != null )
        {
            task.addConfiguredCompiler( fortran );
        }
        // end Darren
View Full Code Here

        RuntimeType runtimeType = new RuntimeType();
        runtimeType.setValue( getRuntime( getAOL() ) );
        task.setRuntime( runtimeType );

        // add C++ compiler
        CompilerDef cpp = getCpp().getCompiler( type, test.getName() );
        if ( cpp != null )
        {
            task.addConfiguredCompiler( cpp );
        }

        // add C compiler
        CompilerDef c = getC().getCompiler( type, test.getName() );
        if ( c != null )
        {
            task.addConfiguredCompiler( c );
        }

        // add Fortran compiler
        CompilerDef fortran = getFortran().getCompiler( type, test.getName() );
        if ( fortran != null )
        {
            task.addConfiguredCompiler( fortran );
        }
View Full Code Here

        throws MojoFailureException, MojoExecutionException
    {
        String name = getName();
        if (name == null) return null;
       
        CompilerDef compiler = new CompilerDef();
        compiler.setProject( mojo.getAntProject() );
        CompilerEnum compilerName = new CompilerEnum();
        compilerName.setValue( name );
        compiler.setName( compilerName );

        // debug, exceptions, rtti, multiThreaded
        compiler.setDebug( debug );
        compiler.setExceptions( exceptions );
        compiler.setRtti( rtti );
        compiler.setMultithreaded( mojo.getOS().equals( "Windows" ) ? true : multiThreaded );

        // optimize
        OptimizationEnum optimization = new OptimizationEnum();
        optimization.setValue( optimize );
        compiler.setOptimize( optimization );

        // add options
        if ( options != null )
        {
            for ( Iterator i = options.iterator(); i.hasNext(); )
            {
                CompilerArgument arg = new CompilerArgument();
                arg.setValue( (String) i.next() );
                compiler.addConfiguredCompilerArg( arg );
            }
        }

        if ( optionSet != null )
        {

            String[] opts = optionSet.split( "\\s" );

            for ( int i = 0; i < opts.length; i++ )
            {

                CompilerArgument arg = new CompilerArgument();

                arg.setValue( opts[i] );
                compiler.addConfiguredCompilerArg( arg );
            }
        }

        if ( !clearDefaultOptions )
        {
            String optionsProperty = NarProperties.getInstance(mojo.getMavenProject()).getProperty( getPrefix() + "options" );
            if ( optionsProperty != null )
            {
                String[] option = optionsProperty.split( " " );
                for ( int i = 0; i < option.length; i++ )
                {
                    CompilerArgument arg = new CompilerArgument();
                    arg.setValue( option[i] );
                    compiler.addConfiguredCompilerArg( arg );
                }
            }
        }

        // add defines
        if ( defines != null )
        {
            DefineSet ds = new DefineSet();
            for ( Iterator i = defines.iterator(); i.hasNext(); )
            {
                DefineArgument define = new DefineArgument();
                String[] pair = ( (String) i.next() ).split( "=", 2 );
                define.setName( pair[0] );
                define.setValue( pair.length > 1 ? pair[1] : null );
                ds.addDefine( define );
            }
            compiler.addConfiguredDefineset( ds );
        }

        if ( defineSet != null )
        {

            String[] defList = defineSet.split( "," );
            DefineSet defSet = new DefineSet();

            for ( int i = 0; i < defList.length; i++ )
            {

                String[] pair = defList[i].trim().split( "=", 2 );
                DefineArgument def = new DefineArgument();

                def.setName( pair[0] );
                def.setValue( pair.length > 1 ? pair[1] : null );

                defSet.addDefine( def );
            }

            compiler.addConfiguredDefineset( defSet );
        }

        if ( !clearDefaultDefines )
        {
            DefineSet ds = new DefineSet();
            String defaultDefines = NarProperties.getInstance(mojo.getMavenProject()).getProperty( getPrefix() + "defines" );
            if ( defaultDefines != null )
            {
                ds.setDefine( new CUtil.StringArrayBuilder( defaultDefines ) );
            }
            compiler.addConfiguredDefineset( ds );
        }

        // add undefines
        if ( undefines != null )
        {
            DefineSet us = new DefineSet();
            for ( Iterator i = undefines.iterator(); i.hasNext(); )
            {
                DefineArgument undefine = new DefineArgument();
                String[] pair = ( (String) i.next() ).split( "=", 2 );
                undefine.setName( pair[0] );
                undefine.setValue( pair.length > 1 ? pair[1] : null );
                us.addUndefine( undefine );
            }
            compiler.addConfiguredDefineset( us );
        }

        if ( undefineSet != null )
        {

            String[] undefList = undefineSet.split( "," );
            DefineSet undefSet = new DefineSet();

            for ( int i = 0; i < undefList.length; i++ )
            {

                String[] pair = undefList[i].trim().split( "=", 2 );
                DefineArgument undef = new DefineArgument();

                undef.setName( pair[0] );
                undef.setValue( pair.length > 1 ? pair[1] : null );

                undefSet.addUndefine( undef );
            }

            compiler.addConfiguredDefineset( undefSet );
        }

        if ( !clearDefaultUndefines )
        {
            DefineSet us = new DefineSet();
            String defaultUndefines = NarProperties.getInstance(mojo.getMavenProject()).getProperty( getPrefix() + "undefines" );
            if ( defaultUndefines != null )
            {
                us.setUndefine( new CUtil.StringArrayBuilder( defaultUndefines ) );
            }
            compiler.addConfiguredDefineset( us );
        }

        // add include path
        for ( Iterator i = getIncludePaths( type ).iterator(); i.hasNext(); )
        {
            String path = (String) i.next();
            // Darren Sargent, 30Jan2008 - fail build if invalid include path(s) specified.
      if ( ! new File(path).exists() ) {
        throw new MojoFailureException("NAR: Include path not found: " + path);
      }
            compiler.createIncludePath().setPath( path );
        }

        // add system include path (at the end)
        if ( systemIncludePaths != null )
        {
            for ( Iterator i = systemIncludePaths.iterator(); i.hasNext(); )
            {
                String path = (String) i.next();
                compiler.createSysIncludePath().setPath( path );
            }
        }

        // Add default fileset (if exists)
        List srcDirs = getSourceDirectories( type );
        Set includeSet = getIncludes();
        Set excludeSet = getExcludes();

        // now add all but the current test to the excludes
        for ( Iterator i = mojo.getTests().iterator(); i.hasNext(); )
        {
            Test test = (Test) i.next();
            if ( !test.getName().equals( output ) )
            {
                excludeSet.add( "**/" + test.getName() + ".*" );
            }
        }

        for ( Iterator i = srcDirs.iterator(); i.hasNext(); )
        {
            File srcDir = (File) i.next();
            mojo.getLog().debug( "Checking for existence of " + getLanguage() + " source directory: " + srcDir );
            if ( srcDir.exists() )
            {
                if ( compileOrder != null )
                {
                    compiler.setOrder( Arrays.asList( StringUtils.split( compileOrder, ", " ) ) );
                }

                ConditionalFileSet fileSet = new ConditionalFileSet();
                fileSet.setProject( mojo.getAntProject() );
                fileSet.setIncludes( StringUtils.join( includeSet.iterator(), "," ) );
                fileSet.setExcludes( StringUtils.join( excludeSet.iterator(), "," ) );
                fileSet.setDir( srcDir );
                compiler.addFileset( fileSet );
            }
        }

        return compiler;
    }
View Full Code Here

TOP

Related Classes of net.sf.antcontrib.cpptasks.CompilerDef

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.