Examples of CCTask


Examples of com.github.maven_nar.cpptasks.CCTask

        throws MojoExecutionException, MojoFailureException
    {
        String type = "test";

        // configure task
        CCTask task = new CCTask();
        task.setProject( antProject );

        // subsystem
        SubsystemEnum subSystem = new SubsystemEnum();
        subSystem.setValue( "console" );
        task.setSubsystem( subSystem );

        // outtype
        OutputTypeEnum outTypeEnum = new OutputTypeEnum();
        outTypeEnum.setValue( Library.EXECUTABLE );
        task.setOuttype( outTypeEnum );

        // outDir
        File outDir = new File( getTestTargetDirectory(), "bin" );
        outDir = new File( outDir, getAOL().toString() );
        outDir.mkdirs();

        // outFile
        File outFile = new File( outDir, test.getName() );
        getLog().debug( "NAR - output: '" + outFile + "'" );
        task.setOutfile( outFile );

        // object directory
        File objDir = new File( getTestTargetDirectory(), "obj" );
        objDir = new File( objDir, getAOL().toString() );
        objDir.mkdirs();
        task.setObjdir( objDir );

        // failOnError, libtool
        task.setFailonerror( failOnError( getAOL() ) );
        task.setLibtool( useLibtool( getAOL() ) );

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

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

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

        // add Fortran compiler
        Fortran fortran = getFortran();
        if ( fortran != null )
        {
            CompilerDef fortranCompiler = getFortran().getTestCompiler( type, test.getName() );
            if ( fortranCompiler != null )
            {
                task.addConfiguredCompiler( fortranCompiler );
            }
        }

        // add java include paths
        getJava().addIncludePaths( task, type );

        List depLibs = getNarArtifacts();
        // add dependency include paths
        for ( Iterator i = depLibs.iterator(); i.hasNext(); )
        {
            Artifact artifact = (Artifact) i.next();
           
            // check if it exists in the normal unpack directory
            File include =
                getLayout().getIncludeDirectory( getUnpackDirectory(), artifact.getArtifactId(), artifact.getBaseVersion() );
            if ( !include.exists() )
            {
                // otherwise try the test unpack directory
                include =
                    getLayout().getIncludeDirectory( getTestUnpackDirectory(), artifact.getArtifactId(), artifact.getBaseVersion() );
            }
            if ( include.exists() )
            {               
                task.createIncludePath().setPath( include.getPath() );
            }
        }
       
        // add javah generated include path
        File jniIncludeDir = getJavah().getJniDirectory();
        if (jniIncludeDir.exists()) {
          task.createIncludePath().setPath(jniIncludeDir.getPath());
        }

        // add linker
        LinkerDef linkerDefinition =
            getLinker().getTestLinker( this, antProject, getOS(), getAOL().getKey() + ".linker.", type );
        task.addConfiguredLinker( linkerDefinition );

        File includeDir =
            getLayout().getIncludeDirectory( getTargetDirectory(), getMavenProject().getArtifactId(),
                                             getMavenProject().getVersion() );

        File libDir =
            getLayout().getLibDirectory( getTargetDirectory(), getMavenProject().getArtifactId(),
                                         getMavenProject().getVersion(), getAOL().toString(), test.getLink() );

        // copy shared library
        // FIXME why do we do this ?
        /*
         * Removed in alpha-10 if (test.getLink().equals(Library.SHARED)) { try { // defaults are Unix String libPrefix
         * = NarUtil.getDefaults().getProperty( getAOLKey() + "shared.prefix", "lib"); String libExt =
         * NarUtil.getDefaults().getProperty( getAOLKey() + "shared.extension", "so"); File copyDir = new
         * File(getTargetDirectory(), (getOS().equals( "Windows") ? "bin" : "lib") + "/" + getAOL() + "/" +
         * test.getLink()); FileUtils.copyFileToDirectory(new File(libDir, libPrefix + libName + "." + libExt),
         * copyDir); if (!getOS().equals(OS.WINDOWS)) { libDir = copyDir; } } catch (IOException e) { throw new
         * MojoExecutionException( "NAR: Could not copy shared library", e); } }
         */
        // FIXME what about copying the other shared libs?

        // add include of this package
        if ( includeDir.exists() )
        {
            task.createIncludePath().setLocation( includeDir );
        }

        // add library of this package
        if ( libDir.exists() )
        {
            LibrarySet libSet = new LibrarySet();
            libSet.setProject( antProject );
            String libs = getNarInfo().getLibs( getAOL() );
            getLog().debug( "Searching for parent to link with " + libs );
            libSet.setLibs( new CUtil.StringArrayBuilder( libs ) );
            LibraryTypeEnum libType = new LibraryTypeEnum();
            libType.setValue( test.getLink() );
            libSet.setType( libType );
            libSet.setDir( libDir );
            task.addLibset( libSet );
        }

        // add dependency libraries
        List depLibOrder = getDependencyLibOrder();

        // reorder the libraries that come from the nar dependencies
        // to comply with the order specified by the user
        if ( ( depLibOrder != null ) && !depLibOrder.isEmpty() )
        {

            List tmp = new LinkedList();

            for ( Iterator i = depLibOrder.iterator(); i.hasNext(); )
            {

                String depToOrderName = (String) i.next();

                for ( Iterator j = depLibs.iterator(); j.hasNext(); )
                {

                    NarArtifact dep = (NarArtifact) j.next();
                    String depName = dep.getGroupId() + ":" + dep.getArtifactId();

                    if ( depName.equals( depToOrderName ) )
                    {

                        tmp.add( dep );
                        j.remove();
                    }
                }
            }

            tmp.addAll( depLibs );
            depLibs = tmp;
        }

        for ( Iterator i = depLibs.iterator(); i.hasNext(); )
        {
            NarArtifact dependency = (NarArtifact) i.next();

            // FIXME no handling of "local"

            // FIXME, no way to override this at this stage
            String binding = dependency.getNarInfo().getBinding( getAOL(), Library.NONE );
            getLog().debug( "Using Binding: " + binding );
            AOL aol = getAOL();
            aol = dependency.getNarInfo().getAOL( getAOL() );
            getLog().debug( "Using Library AOL: " + aol.toString() );

            if ( !binding.equals( Library.JNI ) && !binding.equals( Library.NONE ) && !binding.equals( Library.EXECUTABLE) )
            {
                // check if it exists in the normal unpack directory
                File dir =
                    getLayout().getLibDirectory( getUnpackDirectory(), dependency.getArtifactId(),
                                                  dependency.getBaseVersion(), aol.toString(), binding );
                getLog().debug( "Looking for Library Directory: " + dir );
                if ( !dir.exists() )
                {
                    getLog().debug( "Library Directory " + dir + " does NOT exist." );

                    // otherwise try the test unpack directory
                    dir = getLayout().getLibDirectory( getTestUnpackDirectory(), dependency.getArtifactId(),
                                                        dependency.getBaseVersion(), aol.toString(), binding );
                    getLog().debug( "Looking for Library Directory: " + dir );
                }
                if ( dir.exists() )
                {
                    LibrarySet libSet = new LibrarySet();
                    libSet.setProject( antProject );

                    // FIXME, no way to override
                    String libs = dependency.getNarInfo().getLibs( getAOL() );
                    if ( ( libs != null ) && !libs.equals( "" ) )
                    {
                        getLog().debug( "Using LIBS = " + libs );
                        libSet.setLibs( new CUtil.StringArrayBuilder( libs ) );
                        libSet.setDir( dir );
                        task.addLibset( libSet );
                    }
                }
                else
                {
                    getLog().debug( "Library Directory " + dir + " does NOT exist." );
                }

                // FIXME, look again at this, for multiple dependencies we may need to remove duplicates
                String options = dependency.getNarInfo().getOptions( getAOL() );
                if ( ( options != null ) && !options.equals( "" ) )
                {
                    getLog().debug( "Using OPTIONS = " + options );
                    LinkerArgument arg = new LinkerArgument();
                    arg.setValue( options );
                    linkerDefinition.addConfiguredLinkerArg( arg );
                }

                String sysLibs = dependency.getNarInfo().getSysLibs( getAOL() );
                if ( ( sysLibs != null ) && !sysLibs.equals( "" ) )
                {
                    getLog().debug( "Using SYSLIBS = " + sysLibs );
                    SystemLibrarySet sysLibSet = new SystemLibrarySet();
                    sysLibSet.setProject( antProject );

                    sysLibSet.setLibs( new CUtil.StringArrayBuilder( sysLibs ) );
                    task.addSyslibset( sysLibSet );
                }
            }
        }

        // Add JVM to linker
        getJava().addRuntime( task, getJavaHome( getAOL() ), getOS(), getAOL().getKey() + ".java." );

        // execute
        try
        {
            task.execute();
        }
        catch ( BuildException e )
        {
            throw new MojoExecutionException( "NAR: Test-Compile failed", e );
        }
View Full Code Here

Examples of com.github.maven_nar.cpptasks.CCTask

        assertEquals(1, args.size());
        assertEquals("-shared", args.elementAt(0));
    }
    public void testAddLibrarySetDirSwitch() {
        AbstractLdLinker linker = getLinker();
        CCTask task = new CCTask();
        LibrarySet[] sets = new LibrarySet[]{new LibrarySet()};
        /* throws an Exception in setLibs otherwise */
        sets[0].setProject(new org.apache.tools.ant.Project());
        sets[0].setDir(new File("/foo"));
        sets[0].setLibs(new CUtil.StringArrayBuilder("bart,cart,dart"));
View Full Code Here

Examples of com.github.maven_nar.cpptasks.CCTask

        assertTrue(!libdirSwitch.substring(2, 3).equals(" "));
        assertEquals(libdirSwitch.substring(libdirSwitch.length() - 3), "foo");
    }
    public void testAddLibrarySetLibSwitch() {
        AbstractLdLinker linker = getLinker();
        CCTask task = new CCTask();
        LibrarySet[] sets = new LibrarySet[]{new LibrarySet()};
        /* throws an Exception in setLibs otherwise */
        sets[0].setProject(new org.apache.tools.ant.Project());
        sets[0].setDir(new File("/foo"));
        sets[0].setLibs(new CUtil.StringArrayBuilder("bart,cart,dart"));
View Full Code Here

Examples of com.github.maven_nar.cpptasks.CCTask

        assertEquals(endargs.size(), 4);
    }
    public void testAddLibrarySetLibFrameworkNonDarwin() {
        System.setProperty("os.name", "VAX/VMS");
        AbstractLdLinker linker = getLinker();
        CCTask task = new CCTask();
        LibrarySet[] sets = new LibrarySet[]{new LibrarySet()};
        /* throws an Exception in setLibs otherwise */
        sets[0].setProject(new org.apache.tools.ant.Project());
        sets[0].setDir(new File("/foo"));
        LibraryTypeEnum libType = new LibraryTypeEnum();
View Full Code Here

Examples of com.github.maven_nar.cpptasks.CCTask

     // ENDFREEHEP
    }
    public void testAddLibrarySetLibFrameworkDarwin() {
        System.setProperty("os.name", "Mac OS X");
        AbstractLdLinker linker = getLinker();
        CCTask task = new CCTask();
        LibrarySet[] sets = new LibrarySet[]{new LibrarySet()};
        /* throws an Exception in setLibs otherwise */
        sets[0].setProject(new org.apache.tools.ant.Project());
        sets[0].setDir(new File("/foo"));
        LibraryTypeEnum libType = new LibraryTypeEnum();
View Full Code Here

Examples of com.github.maven_nar.cpptasks.CCTask

        assertEquals(endargs.size(), 5);
// ENDFREEHEP
    }
    public void testAddLibraryStatic() {
        AbstractLdLinker linker = getLinker();
        CCTask task = new CCTask();
        LibrarySet[] sets = new LibrarySet[]{
            new LibrarySet(),
        new LibrarySet(),
        new LibrarySet()};
        /* throws an Exception in setLibs otherwise */
 
View Full Code Here

Examples of com.github.maven_nar.cpptasks.CCTask

        }
// ENDFREEHEP
    }
    public void testLibReturnValue() {
        AbstractLdLinker linker = getLinker();
        CCTask task = new CCTask();
        LibrarySet[] sets = new LibrarySet[]{new LibrarySet()};
        /* throws an Exception in setLibs otherwise */
        sets[0].setProject(new org.apache.tools.ant.Project());
        sets[0].setDir(new File("/foo"));
        sets[0].setLibs(new CUtil.StringArrayBuilder("bart,cart,dart"));
View Full Code Here

Examples of com.github.maven_nar.cpptasks.CCTask

  /**
   * Tests that the default value of failonerror is true.
   */
  public void testGetFailOnError() {
    CCTask task = new CCTask();
    boolean failOnError = task.getFailonerror();
    assertEquals(true, failOnError);
  }
View Full Code Here

Examples of com.github.maven_nar.cpptasks.CCTask

  /**
   * Tests that setting failonerror is effective.
   */
  public void testSetFailOnError() {
    CCTask task = new CCTask();
    task.setFailonerror(false);
    boolean failOnError = task.getFailonerror();
    assertEquals(false, failOnError);
    task.setFailonerror(true);
    failOnError = task.getFailonerror();
    assertEquals(true, failOnError);
  }
View Full Code Here

Examples of com.github.maven_nar.cpptasks.CCTask

   *            processor under test
   * @return configuration
   */
  protected final ProcessorConfiguration getConfiguration(
      final ProcessorDef extendedProcessor) {
    CCTask cctask = new CCTask();
    LinkType linkType = new LinkType();
    return extendedProcessor.createConfiguration(cctask,
                                                 linkType,
                                                 null,
                                                 null,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.