Examples of CCTask


Examples of com.github.maven_nar.cpptasks.CCTask

    private void createLibrary(Project antProject, Library library)
        throws MojoExecutionException, MojoFailureException
    {
        getLog().debug( "Creating Library " + library );
        // configure task
        CCTask task = new CCTask();
        task.setCommandLogLevel( commandLogLevel );
        task.setProject(antProject);

        task.setDecorateLinkerOptions(decorateLinkerOptions);

        task.setDecorateLinkerOptions(decorateLinkerOptions);

        // subsystem
        SubsystemEnum subSystem = new SubsystemEnum();
        subSystem.setValue( library.getSubSystem() );
        task.setSubsystem( subSystem );

        // set max cores
        task.setMaxCores(getMaxCores(getAOL()));

        // outtype
        OutputTypeEnum outTypeEnum = new OutputTypeEnum();
        String type = library.getType();
        outTypeEnum.setValue(type);
        task.setOuttype(outTypeEnum);

        // stdc++
        task.setLinkCPP(library.linkCPP());

        // fortran
        task.setLinkFortran(library.linkFortran());
        task.setLinkFortranMain( library.linkFortranMain() );

        // outDir
        File outDir;
        if ( type.equals( Library.EXECUTABLE ) )
        {
            outDir =
                getLayout().getBinDirectory( getTargetDirectory(), getMavenProject().getArtifactId(),
                                             getMavenProject().getVersion(), getAOL().toString() );
        }
        else
        {
            outDir =
                getLayout().getLibDirectory( getTargetDirectory(), getMavenProject().getArtifactId(),
                                             getMavenProject().getVersion(), getAOL().toString(), type );
        }
        outDir.mkdirs();

        // outFile
        // FIXME NAR-90 we could get the final name from layout
        File outFile = new File(outDir, getOutput(getAOL(), type) );
        getLog().debug("NAR - output: '" + outFile + "'");
        task.setOutfile(outFile);

        // object directory
        File objDir = new File(getTargetDirectory(), "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);

        // IDL, MC, RC compilations should probably be 'generate source' type actions, seperate from main build.
        // Needs resolution of handling for generate sources.
        // Order is somewhat important here, IDL and MC generate outputs that are (often) included in the RC compilation
        if (getIdl() != null) {
            CompilerDef idl = getIdl().getCompiler( Compiler.MAIN, null );
            if ( idl != null )
            {
                task.addConfiguredCompiler( idl );
            }
        }
        if (getMessage() != null) {
            CompilerDef mc = getMessage().getCompiler( Compiler.MAIN, null );
            if ( mc != null )
            {
                task.addConfiguredCompiler( mc );
            }
        }
        if (getResource() != null) {
            CompilerDef res = getResource().getCompiler( Compiler.MAIN, null );
            if ( res != null )
            {
                task.addConfiguredCompiler( res );
            }
        }
       
        // 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
        if (getCpp() != null) {
            CompilerDef cpp = getCpp().getCompiler( Compiler.MAIN, null );
            if ( cpp != null )
            {
                task.addConfiguredCompiler( cpp );
            }
        }

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

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

        // add javah include path
        File jniDirectory = getJavah().getJniDirectory();
        if (jniDirectory.exists())
        {
            task.createIncludePath().setPath(jniDirectory.getPath());
        }

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

        List<NarArtifact> dependencies = getNarArtifacts();
        // add dependency include paths
        for ( Iterator i = dependencies.iterator(); i.hasNext(); )
        {
            // FIXME, handle multiple includes from one NAR
            NarArtifact narDependency = (NarArtifact) i.next();
            String binding = narDependency.getNarInfo().getBinding(getAOL(), Library.STATIC);
            getLog().debug( "Looking for " + narDependency + " found binding " + binding);
            if ( !binding.equals(Library.JNI ) )
            {
                File unpackDirectory = getUnpackDirectory();
                File include =
                    getLayout().getIncludeDirectory( unpackDirectory, narDependency.getArtifactId(),
                                                     narDependency.getBaseVersion() );
                getLog().debug( "Looking for include directory: " + include );
                if ( include.exists() )
                {
                    task.createIncludePath().setPath(include.getPath());
                } else {
                    throw new MojoExecutionException(
                            "NAR: unable to locate include path: " + include);
                }
            }
        }

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

        // add dependency libraries
        // FIXME: what about PLUGIN and STATIC, depending on STATIC, should we
        // not add all libraries, see NARPLUGIN-96
        if ( type.equals( Library.SHARED ) || type.equals( Library.JNI ) || type.equals( Library.EXECUTABLE ) )
        {

            List depLibOrder = getDependencyLibOrder();
            List depLibs = dependencies;

            // 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) )
                {
                    File unpackDirectory = getUnpackDirectory();

                    File dir =
                        getLayout().getLibDirectory( unpackDirectory, 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: Compile failed", e);
        }
View Full Code Here

Examples of com.github.maven_nar.cpptasks.CCTask

    CompilerDef baseCompiler = new CompilerDef();
    baseCompiler.setMultithreaded(false);
    CompilerDef extendedCompiler = (CompilerDef) createExtendedProcessorDef(
        baseCompiler);
    setCompilerName(extendedCompiler, "msvc");
    CCTask cctask = new CCTask();
    LinkType linkType = new LinkType();
    linkType.setStaticRuntime(true);
    CommandLineCompilerConfiguration config = (CommandLineCompilerConfiguration)
        extendedCompiler
        .createConfiguration(cctask, linkType, null, null, null);
View Full Code Here

Examples of com.github.maven_nar.cpptasks.CCTask

  // FIXME: code duplication with NarCompileMojo
  private void createVcProjFile(Project antProject, Library library)
      throws MojoExecutionException, MojoFailureException {

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

    // subsystem (console)
        SubsystemEnum subSystem = new SubsystemEnum();
        subSystem.setValue( library.getSubSystem() );
        task.setSubsystem( subSystem );
       
    // outtype
    OutputTypeEnum outTypeEnum = new OutputTypeEnum();
    String type = library.getType();
    outTypeEnum.setValue(type);
    task.setOuttype(outTypeEnum);

    // stdc++
    task.setLinkCPP(library.linkCPP());

    // TODO: this should match the standard NAR location defined by layout similar to Nar Compile
    // outDir
    File outDir = new File(getTargetDirectory(), "bin");
    outDir = new File(outDir, getAOL().toString());
    outDir.mkdirs();

    // outFile
    File outFile = new File(outDir, getOutput(getAOL(), type) );

    getLog().debug("NAR - output: '" + outFile + "'");
    task.setOutfile(outFile);

    // object directory
    File objDir = new File(getTargetDirectory(), "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
    CompilerDef cpp = getCpp().getCompiler(Compiler.MAIN,null);
    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()) {
      task.createIncludePath().setPath(jniDirectory.getPath());
    }

    // add java include paths
    getJava().addIncludePaths(task, Library.EXECUTABLE);
   
    List<NarArtifact> dependencies = getNarArtifacts();
    // add dependency include paths
    for (Iterator i = dependencies.iterator(); i.hasNext();) {
      // FIXME, handle multiple includes from one NAR
      NarArtifact narDependency = (NarArtifact) i.next();
      String binding = narDependency.getNarInfo().getBinding(getAOL(),
          Library.STATIC);
      getLog().debug(
          "Looking for " + narDependency + " found binding "
              + binding);
      if (!binding.equals(Library.JNI)) {
                File unpackDirectory = getUnpackDirectory();
                File include =
                    getLayout().getIncludeDirectory( unpackDirectory, narDependency.getArtifactId(),
                                                     narDependency.getBaseVersion() );
                getLog().debug("Looking for directory: " + include);
        if (include.exists()) {
          task.createIncludePath().setPath(include.getPath());
        } else {
          throw new MojoExecutionException(
              "NAR: unable to locate include path: " + include);
        }
      }
    }

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

    // add dependency libraries
    // FIXME: what about PLUGIN and STATIC, depending on STATIC, should we
    // not add all libraries, see NARPLUGIN-96
    if (type.equals(Library.SHARED) || type.equals(Library.JNI)
        || type.equals(Library.EXECUTABLE)) {

      List depLibOrder = getDependencyLibOrder();
      List depLibs = dependencies;

      // 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.STATIC);
        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) )
                {
                    File unpackDirectory = getUnpackDirectory();
                    File dir =
                        getLayout().getLibDirectory( unpackDirectory, 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.");

      // DS: generate project file
      getLog().debug("NAR: Writing project file...");
      ProjectWriterEnum projectWriterEnum = new ProjectWriterEnum();
      projectWriterEnum.setValue("msvc8");
      ProjectDef projectDef = new ProjectDef();
      projectDef.setType(projectWriterEnum);     
      String filename = null;
      try {
        File outputDir = new File(getTargetDirectory(), "vcproj");
        if (!outputDir.exists()) {
          boolean succeeded = outputDir.mkdir();
          if (!succeeded) {
            throw new MojoExecutionException(
                "Unable to create directory: " + outputDir);
          }
        }
        filename = outputDir + "/" + getMavenProject().getArtifactId();
        File projFile = new File(filename);
        projectDef.setOutfile(projFile.getCanonicalFile());
      } catch (IOException e) {
        throw new MojoExecutionException("Unable to create file: "
            + filename, e);
      }
      task.addProject(projectDef);
      task.setProjectsOnly(true);

      // we always want an EXE for debugging
      task.setOuttype(new OutputTypeEnum());

      // execute
      try {
        task.execute();
        getLog().info("Wrote project file: " + filename + ".vcproj");
      } catch (BuildException e) {
        throw new MojoExecutionException("NAR: Compile failed", e);
      }
    }
View Full Code Here

Examples of com.github.maven_nar.cpptasks.CCTask

     * @throws IOException
     */
    public void testLoadOpenshore() throws IOException {
        try {
            copyResourceToTmpDir("openshore/history.xml", "history.xml");
            CCTask task = new CCTask();
            String tmpDir = System.getProperty("java.io.tmpdir");
            TargetHistoryTable history = new TargetHistoryTable(task, new File(
                    tmpDir));
        } finally {
            deleteTmpFile("history.xml");
View Full Code Here

Examples of com.github.maven_nar.cpptasks.CCTask

     * @throws IOException
     */
    public void testLoadXerces() throws IOException {
        try {
            copyResourceToTmpDir("xerces-c/history.xml", "history.xml");
            CCTask task = new CCTask();
            String tmpDir = System.getProperty("java.io.tmpdir");
            TargetHistoryTable history = new TargetHistoryTable(task, new File(
                    tmpDir));
        } finally {
            deleteTmpFile("history.xml");
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

Examples of com.github.maven_nar.cpptasks.CCTask

     * @throws IOException
     */
    public void testLoadOpenshore() throws IOException {
        try {
            copyResourceToTmpDir("openshore/history.xml", "history.xml");
            CCTask task = new CCTask();
            String tmpDir = System.getProperty("java.io.tmpdir");
            TargetHistoryTable history = new TargetHistoryTable(task, new File(
                    tmpDir));
        } finally {
            deleteTmpFile("history.xml");
View Full Code Here

Examples of com.github.maven_nar.cpptasks.CCTask

     * @throws IOException
     */
    public void testLoadXerces() throws IOException {
        try {
            copyResourceToTmpDir("xerces-c/history.xml", "history.xml");
            CCTask task = new CCTask();
            String tmpDir = System.getProperty("java.io.tmpdir");
            TargetHistoryTable history = new TargetHistoryTable(task, new File(
                    tmpDir));
        } finally {
            deleteTmpFile("history.xml");
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
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.