コード例 #1
0
  /**
   * Create an Ansi object appropriate for the current output. First respect the user's preferences,
   * if set. Next, respect any default provided by the caller. (This is used by buckd to tell the
   * daemon about the client's terminal.) Finally, allow the Ansi class to autodetect whether the
   * current output is a tty.
   *
   * @param defaultColor Default value provided by the caller (e.g. the client of buckd)
   */
  public Ansi createAnsi(Optional<String> defaultColor) {
    String color = getValue("color", "ui").or(defaultColor).or("auto");

    switch (color) {
      case "false":
      case "never":
        return Ansi.withoutTty();
      case "true":
      case "always":
        return Ansi.forceTty();
      case "auto":
      default:
        return new Ansi(
            AnsiEnvironmentChecking.environmentSupportsAnsiEscapes(platform, environment));
    }
  }
コード例 #2
0
ファイル: ParallelPerBuildState.java プロジェクト: lgyjg/buck
  public ParallelPerBuildState(
      ParallelDaemonicParserState permState,
      ConstructorArgMarshaller marshaller,
      BuckEventBus eventBus,
      Cell rootCell,
      boolean enableProfiling) {
    this.permState = permState;
    this.marshaller = marshaller;
    this.eventBus = eventBus;
    this.enableProfiling = enableProfiling;
    this.cells = new ConcurrentHashMap<>();
    this.cellSymlinkAllowability = new ConcurrentHashMap<>();
    this.parsers =
        new ThreadLocal<Map<Cell, ProjectBuildFileParser>>() {
          @Override
          protected Map<Cell, ProjectBuildFileParser> initialValue() {
            return new HashMap<>();
          }
        };
    this.buildInputPathsUnderSymlink = Sets.newHashSet();
    this.symlinkExistenceCache = new ConcurrentHashMap<>();

    this.stdout = new PrintStream(ByteStreams.nullOutputStream());
    this.stderr = new PrintStream(ByteStreams.nullOutputStream());
    this.console = new Console(Verbosity.STANDARD_INFORMATION, stdout, stderr, Ansi.withoutTty());

    this.symlinkCheckers =
        new TargetNodeListener() {
          @Override
          public void onCreate(Path buildFile, TargetNode<?> node) throws IOException {
            registerInputsUnderSymlinks(buildFile, node);
          }
        };

    this.closer = Closer.create();

    this.pendingWorkQueueCount = new AtomicInteger(0);
    this.pendingBuildTargets = new LinkedBlockingQueue<>();
    this.pendingBuildFiles = new LinkedBlockingQueue<>();
    this.completionNotifier = new CountDownLatch(1);

    register(rootCell);
  }
コード例 #3
0
ファイル: GenruleTest.java プロジェクト: h87kg/buck
  private ExecutionContext newEmptyExecutionContext(Platform platform) {
    return ExecutionContext.builder()
        .setConsole(new Console(Verbosity.SILENT, System.out, System.err, Ansi.withoutTty()))
        .setProjectFilesystem(
            new ProjectFilesystem(new File(".")) {
              @Override
              public Function<String, Path> getPathRelativizer() {
                return IdentityPathRelativizer.getIdentityRelativizer();
              }

              @Override
              public Path resolve(Path path) {
                return path;
              }
            })
        .setEventBus(BuckEventBusFactory.newInstance())
        .setPlatform(platform)
        .build();
  }
コード例 #4
0
ファイル: Project.java プロジェクト: jamesgpearce/buck
  private ExitCodeAndOutput processJsonConfig(File jsonTempFile, boolean generateMinimalProject)
      throws IOException {
    ImmutableList.Builder<String> argsBuilder =
        ImmutableList.<String>builder()
            .add(pythonInterpreter)
            .add(PATH_TO_INTELLIJ_PY)
            .add(jsonTempFile.getAbsolutePath());

    if (generateMinimalProject) {
      argsBuilder.add("--generate_minimum_project");
    }

    final ImmutableList<String> args = argsBuilder.build();

    ShellStep command =
        new ShellStep() {

          @Override
          public String getShortName() {
            return "python";
          }

          @Override
          protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) {
            return args;
          }
        };

    Console console = executionContext.getConsole();
    Console childConsole =
        new Console(Verbosity.SILENT, console.getStdOut(), console.getStdErr(), Ansi.withoutTty());
    ExecutionContext childContext =
        ExecutionContext.builder()
            .setExecutionContext(executionContext)
            .setConsole(childConsole)
            .build();
    int exitCode = command.execute(childContext);
    return new ExitCodeAndOutput(exitCode, command.getStdout(), command.getStderr());
  }
コード例 #5
0
 private ProcessExecutor createProcessExecutor(PrintStream stdout, PrintStream stderr) {
   return new ProcessExecutor(new Console(Verbosity.SILENT, stdout, stderr, Ansi.withoutTty()));
 }