Examples of IBuildMacroProvider


Examples of org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider

    String[] preToolCommands = depCommands.getPreToolDependencyCommands();
    if (preToolCommands != null && preToolCommands.length > 0) {
        for (String preCmd : preToolCommands) {
      try {
          String resolvedCommand;
          IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
          if (!needExplicitRuleForFile) {
        resolvedCommand = provider.resolveValueToMakefileFormat(preCmd, EMPTY_STRING, WHITESPACE,
          IBuildMacroProvider.CONTEXT_FILE, new FileContextData(sourceLocation, outputLocation, null, tool))
          .replaceFirst(" -w ", " ");
          } else {
        // if we need an explicit rule then don't use
        // any builder
        // variables, resolve everything to explicit
        // strings
        resolvedCommand = provider.resolveValue(preCmd, EMPTY_STRING, WHITESPACE, IBuildMacroProvider.CONTEXT_FILE,
          new FileContextData(sourceLocation, outputLocation, null, tool)).replaceFirst(" -w ", " ");
          }
          if (resolvedCommand != null)
        buffer.append(resolvedCommand + NEWLINE);
      } catch (BuildMacroException e) {// JABA is not going to
               // write this code
      }
        }
    }
      }

      // Generate the command line

      Vector<String> inputs = new Vector<String>();
      inputs.add(IN_MACRO);

      // Other additional inputs
      // Get any additional dependencies specified for the tool in other
      // InputType elements and AdditionalInput elements
      IPath[] addlInputPaths = getAdditionalResourcesForSource(tool);
      for (IPath addlInputPath : addlInputPaths) {
    // Translate the path from project relative to build directory
    // relative
    IPath addlPath = addlInputPath;
    if (!(addlPath.toString().startsWith("$("))) { //$NON-NLS-1$
        if (!addlPath.isAbsolute()) {
      IPath tempPath = getPathForResource(project).append(addlPath);
      if (tempPath != null) {
          addlPath = ManagedBuildManager.calculateRelativePath(getTopBuildDir(), tempPath);
      }
        }
    }
    inputs.add(addlPath.toString());
      }
      String[] inputStrings = inputs.toArray(new String[inputs.size()]);

      String[] flags = null;
      // Get the tool command line options
      try {
    flags = tool.getToolCommandFlags(sourceLocation, outputLocation);
      } catch (BuildException ex) {
    // TODO add some routines to catch this
    flags = EMPTY_STRING_ARRAY;
      }

      // If we have a TYPE_BUILD_COMMANDS dependency generator, determine
      // if there are any options that
      // it wants added to the command line
      if (depCommands != null) {
    flags = addDependencyOptions(depCommands, flags);
      }

      IManagedCommandLineInfo cmdLInfo = null;
      String outflag = null;
      String outputPrefix = null;

      if (rcInfo instanceof IFileInfo || needExplicitRuleForFile || needExplicitDependencyCommands) {
    outflag = tool.getOutputFlag();
    outputPrefix = tool.getOutputPrefix();

    // Call the command line generator
    IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator();
    cmdLInfo = cmdLGen.generateCommandLineInfo(tool, cmd, flags, outflag, outputPrefix, OUT_MACRO + otherPrimaryOutputs, inputStrings,
      tool.getCommandLinePattern());

      } else {
    outflag = tool.getOutputFlag();// config.getOutputFlag(outputExtension);
    outputPrefix = tool.getOutputPrefix();// config.getOutputPrefix(outputExtension);

    // Call the command line generator
    cmdLInfo = generateToolCommandLineInfo(tool, inputExtension, flags, outflag, outputPrefix, OUT_MACRO + otherPrimaryOutputs,
      inputStrings, sourceLocation, outputLocation);
      }

      // The command to build
      String buildCmd;
      if (cmdLInfo != null) {
    buildCmd = cmdLInfo.getCommandLine();
      } else {
    StringBuffer buildFlags = new StringBuffer();
    for (String flag : flags) {
        if (flag != null) {
      buildFlags.append(flag + WHITESPACE);
        }
    }
    buildCmd = cmd + WHITESPACE + buildFlags.toString().trim() + WHITESPACE + outflag + WHITESPACE + outputPrefix + OUT_MACRO
      + otherPrimaryOutputs + WHITESPACE + IN_MACRO;
      }

      // resolve any remaining macros in the command after it has been
      // generated
      try {
    String resolvedCommand;
    IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
    if (!needExplicitRuleForFile) {
        resolvedCommand = provider.resolveValueToMakefileFormat(buildCmd, EMPTY_STRING, WHITESPACE, IBuildMacroProvider.CONTEXT_FILE,
          new FileContextData(sourceLocation, outputLocation, null, tool)).replaceFirst(" -w ", " ");
    } else {
        // if we need an explicit rule then don't use any builder
        // variables, resolve everything to explicit strings
        resolvedCommand = provider.resolveValue(buildCmd, EMPTY_STRING, WHITESPACE, IBuildMacroProvider.CONTEXT_FILE,
          new FileContextData(sourceLocation, outputLocation, null, tool)).replaceFirst(" -w ", " ");
    }

    if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
        buildCmd = resolvedCommand;
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.