示例#1
0
  public BuildResultStatus rebuild(TreeLogger logger) {
    logger = logger.branch(TreeLogger.INFO, "Performing an incremental rebuild");

    ResourceOracleImpl.clearCache();
    ZipFileClassPathEntry.clearCache();
    ModuleDefLoader.clearModuleCache();
    ResourceGeneratorUtilImpl.clearGeneratedFilesByName();

    long beforeComputeOutputFreshnessMs = System.currentTimeMillis();
    forgetAllOutputFreshness();
    rootBuildTarget.computeOutputFreshness(logger);
    long computeOutputFreshnessDurationMs =
        System.currentTimeMillis() - beforeComputeOutputFreshnessMs;
    logger.log(
        TreeLogger.INFO,
        String.format(
            "%.3fs -- Computing per-target output freshness",
            computeOutputFreshnessDurationMs / 1000d));

    if (rootBuildTarget.isOutputFreshAndGood()) {
      logger.log(TreeLogger.INFO, NO_FILES_HAVE_CHANGED);
      return BuildResultStatus.SUCCESS_NO_CHANGES;
    }

    TreeLogger branch = logger.branch(TreeLogger.INFO, "Compiling target graph");
    boolean success = rootBuildTarget.link(branch);
    return BuildResultStatus.get(success);
  }
    // VisibleForTesting
    protected void runGeneratorsToFixedPoint(RebindPermutationOracle rpo)
        throws UnableToCompleteException {
      boolean fixedPoint;
      do {
        compilerContext
            .getLibraryWriter()
            .setReboundTypeSourceNames(getTypeNames(gatherReboundTypes(rpo)));

        fixedPoint = runGenerators();
      } while (!fixedPoint);

      // This is a horribly dirty hack to work around the fact that CssResourceGenerator uses a
      // completely nonstandard resource creation and caching mechanism that ignores the
      // GeneratorContext infrastructure. It and GenerateCssAst need to be fixed.
      for (Entry<String, File> entry :
          ResourceGeneratorUtilImpl.getGeneratedFilesByName().entrySet()) {
        String resourcePath = entry.getKey();
        File resourceFile = entry.getValue();
        compilerContext
            .getLibraryWriter()
            .addBuildResource(new FileResource(null, resourcePath, resourceFile));
      }
    }