public ProgramCommandLine makeProgramCommandLine()

in cmake-runner-agent/src/jetbrains/buildServer/cmakerunner/agent/MakeTasksBuildService.java [43:106]


  public ProgramCommandLine makeProgramCommandLine() throws RunBuildException {

    final List<String> arguments = new ArrayList<String>();
    final Map<String, String> runnerParameters = getRunnerParameters(); // all server-ui options
    final Map<String, String> environment = new HashMap<String, String>(getBuildParameters().getEnvironmentVariables());

    // Path to 'make'

    String programPath = runnerParameters.get(UI_MAKE_PROGRAM_PATH);
    if (programPath == null) {
      programPath = DEFAULT_MAKE_PROGRAM;
    }

    // Check for program exist
//    if (!FileUtil2.checkIfExists(programPath) && FileUtil2.findExecutableByNameInPATH(programPath, environment) == null)
//      throw new RunBuildException("Cannot locate `" + programPath + "' executable");


    // Make options

    // Custom Makefile if specified
    final File buildFile = getBuildFile(runnerParameters);
    if (buildFile != null) {
      arguments.add(MAKE_CMDLINE_OPTIONS_MAKEFILE);
      arguments.add(buildFile.getAbsolutePath());
    }

    // Keep-going
    if (Boolean.valueOf(runnerParameters.get(UI_MAKE_KEEP_GOING))) {
      arguments.add(MAKE_CMDLINE_OPTIONS_KEEP_GOING);
    }

    // Other arguments
    addCustomArguments(arguments, runnerParameters.get(UI_MAKE_ADDITIONAL_CMD_PARAMS));

    // Tasks names
    final String makeTasksStr = runnerParameters.get(UI_MAKE_TASKS);
    addCustomArguments(arguments, makeTasksStr);

    myMakeTasks.set(splitMakeTasks(makeTasksStr));

    final String customPattersFilePath = getRunnerContext().getConfigParameters().get(TEAMCITY_MAKE_OUTPUT_PATTERNS_FILE_PROPERTY);
    if (!StringUtil.isEmptyOrSpaces(customPattersFilePath) && FileUtil2.checkIfExists(customPattersFilePath)) {
      final File file = FileUtil.getCanonicalFile(new File(customPattersFilePath));
      if (file.exists()) {
        myCustomPatternsFile.set(file);
      }
    }
    final String defaultParsers = getRunnerContext().getConfigParameters().get(TEAMCITY_MAKE_OUTPUT_DEFAULT_PATTERNS_ENABLED_PROPERTY);
    if (!StringUtil.isEmptyOrSpaces(defaultParsers)) {
      myDefaultParsersEnabled = PropertiesUtil.getBoolean(defaultParsers);
      if (!myDefaultParsersEnabled) {
        getLogger().message("Default messages parser disabled");
      }
    }

    final boolean redirectStdErr = Boolean.valueOf(runnerParameters.get(UI_REDIRECT_STDERR));
    // Result:
    final SimpleProgramCommandLine pcl = new SimpleProgramCommandLine(environment,
            getWorkingDirectory().getAbsolutePath(),
            programPath,
            arguments);
    return redirectStdErr ? OutputRedirectProcessor.wrap(getBuild(), pcl) : pcl;
  }