public static ProgramCommandLine wrap()

in cmake-runner-agent/src/jetbrains/buildServer/cmakerunner/agent/util/OutputRedirectProcessor.java [40:69]


  public static ProgramCommandLine wrap(@NotNull final AgentRunningBuild build, @NotNull final ProgramCommandLine pcl) throws RunBuildException {
    final Map<String, String> environment = pcl.getEnvironment();

    final String shell;
    try {
      shell = OSUtil.getCLIFullPath(environment);
    } catch (final RunBuildException e) {
      // Unsupported OS. Warn and do nothing.
      build.getBuildLogger().warning("Cannot wrap execution: " + e.getMessage());
      return pcl;
    }

    final List<String> arguments = new ArrayList<String>();
    if (SystemInfo.isUnix) {  // sh -c "make $@ 2>&1" -- clean all
      arguments.add("-c");
      arguments.add(pcl.getExecutablePath() + RUNNER_SCRIPT_UNIX);
      arguments.add("--");
      arguments.addAll(pcl.getArguments());
      return new SimpleProgramCommandLine(environment, pcl.getWorkingDirectory(), shell, arguments);
    } else if (SystemInfo.isWindows) {
      final File script = createScriptForWindows(pcl, build);
      arguments.add("/C");
      arguments.add(script.getAbsolutePath());
      return new SimpleProgramCommandLine(environment, pcl.getWorkingDirectory(), shell, arguments);
    } else {
      // Unsupported OS. Warn and do nothing.
      build.getBuildLogger().warning("Cannot wrap execution: Unsupported OS.");
      return pcl;
    }
  }