コード例 #1
0
ファイル: IncrementalBuilder.java プロジェクト: hammoum/gwt
  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);
  }
コード例 #2
0
ファイル: BuildTargetTest.java プロジェクト: disigma/buck
 @Test
 public void testNotEquals() {
   BuildTarget utilTarget =
       BuildTarget.builder(ROOT, "//src/com/facebook/buck/util", "util").build();
   BuildTarget ioTarget = BuildTarget.builder(ROOT, "//src/com/facebook/buck/util", "io").build();
   assertFalse(utilTarget.equals(ioTarget));
 }
コード例 #3
0
ファイル: BuildTargetTest.java プロジェクト: disigma/buck
 @Test
 public void testBuildTargetWithoutFlavor() {
   BuildTarget target = BuildTarget.builder(ROOT, "//foo/bar", "baz").build();
   assertEquals(target.getShortNameAndFlavorPostfix(), "baz");
   assertEquals(ImmutableSortedSet.<Flavor>of(), target.getFlavors());
   assertFalse(target.isFlavored());
 }
コード例 #4
0
ファイル: IncrementalBuilder.java プロジェクト: hammoum/gwt
  public BuildResultStatus build(TreeLogger logger) {
    try {
      logger = logger.branch(TreeLogger.INFO, "Performing an incremental build");

      CompilerContext compilerContext =
          new CompilerContext.Builder()
              .compileMonolithic(false)
              .libraryGroup(LibraryGroup.fromLibraries(Lists.<Library>newArrayList(), false))
              .build();
      long beforeLoadRootModuleMs = System.currentTimeMillis();
      rootModule =
          ModuleDefLoader.loadFromResources(
              logger, compilerContext, rootModuleName, resourceLoader, false);
      finalProperties = rootModule.getProperties();
      long loadRootModuleDurationMs = System.currentTimeMillis() - beforeLoadRootModuleMs;
      logger.log(
          TreeLogger.INFO,
          String.format(
              "%.3fs -- Parsing and loading root module definition in %s",
              loadRootModuleDurationMs / 1000d, rootModuleName));

      long beforeCreateTargetGraphMs = System.currentTimeMillis();
      rootBuildTarget = createBuildTarget(logger, rootModuleName);
      rootBuildTarget.setModule(rootModule);
      long createdTargetGraphDurationMs = System.currentTimeMillis() - beforeCreateTargetGraphMs;
      logger.log(
          TreeLogger.INFO,
          String.format(
              "%.3fs -- Creating target graph (%s targets)",
              createdTargetGraphDurationMs / 1000d, buildTargetsByCanonicalModuleName.size()));

      if (!circularReferenceModuleNameLoops.isEmpty()) {
        for (List<String> circularReferenceModuleNameLoop : circularReferenceModuleNameLoops) {
          logger.log(
              TreeLogger.ERROR, formatCircularModulePathMessage(circularReferenceModuleNameLoop));
        }
        throw new UnableToCompleteException();
      }
      logLoadedBuildTargetGraph(logger, buildTargetsByCanonicalModuleName);

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

      TreeLogger branch = logger.branch(TreeLogger.INFO, "Compiling target graph");
      boolean success = rootBuildTarget.link(branch);
      return BuildResultStatus.get(success);
    } catch (UnableToCompleteException e) {
      // The real cause has been logged.
      return BuildResultStatus.FAILED;
    }
  }
コード例 #5
0
ファイル: BuildTargetTest.java プロジェクト: disigma/buck
 @Test
 public void testBuildTargetWithFlavor() {
   BuildTarget target =
       BuildTarget.builder(ROOT, "//foo/bar", "baz").addFlavors(ImmutableFlavor.of("dex")).build();
   assertEquals("baz#dex", target.getShortNameAndFlavorPostfix());
   assertEquals(ImmutableSortedSet.of(ImmutableFlavor.of("dex")), target.getFlavors());
   assertTrue(target.isFlavored());
 }
コード例 #6
0
ファイル: BuildTargetTest.java プロジェクト: disigma/buck
  @Test
  public void testGetUnflavoredTarget() {
    UnflavoredBuildTarget unflavoredTarget =
        UnflavoredBuildTarget.builder("//foo/bar", "baz").setCellPath(ROOT).build();

    BuildTarget flavoredTarget =
        BuildTarget.builder(ROOT, "//foo/bar", "baz").addFlavors(ImmutableFlavor.of("biz")).build();
    assertEquals(unflavoredTarget, flavoredTarget.getUnflavoredBuildTarget());
  }
コード例 #7
0
ファイル: BuildTargetTest.java プロジェクト: disigma/buck
  @Test
  public void testEqualsOtherBuildTarget() {
    BuildTarget utilTarget1 =
        BuildTarget.builder(ROOT, "//src/com/facebook/buck/util", "util").build();
    assertEquals(utilTarget1, utilTarget1);

    BuildTarget utilTarget2 =
        BuildTarget.builder(ROOT, "//src/com/facebook/buck/util", "util").build();
    assertEquals(utilTarget1, utilTarget2);
  }
コード例 #8
0
ファイル: IncrementalBuilder.java プロジェクト: hammoum/gwt
 private void logLoadedBuildTargetGraph(
     TreeLogger logger, Map<String, BuildTarget> buildTargetsByCanonicalModuleName) {
   logger.log(TreeLogger.SPAM, "Loaded build target graph:");
   for (String canonicalModuleName : buildTargetsByCanonicalModuleName.keySet()) {
     logger.log(TreeLogger.SPAM, "\t" + canonicalModuleName);
     BuildTarget gwtTarget = buildTargetsByCanonicalModuleName.get(canonicalModuleName);
     for (BuildTarget dependencyBuildTarget : gwtTarget.getDependencyBuildTargets()) {
       logger.log(TreeLogger.SPAM, "\t\t" + dependencyBuildTarget.getCanonicalModuleName());
     }
   }
 }
コード例 #9
0
ファイル: BuildTargetTest.java プロジェクト: disigma/buck
 @Test
 public void testBuildTargetTwoLevelsDeep() {
   BuildTarget rootTarget = BuildTarget.builder(ROOT, "//java/com/facebook", "fb4a").build();
   assertEquals("fb4a", rootTarget.getShortNameAndFlavorPostfix());
   assertEquals("//java/com/facebook", rootTarget.getBaseName());
   assertEquals("//java/com/facebook/", rootTarget.getBaseNameWithSlash());
   assertEquals(Paths.get("java/com/facebook"), rootTarget.getBasePath());
   assertEquals("java/com/facebook/", rootTarget.getBasePathWithSlash());
   assertEquals("//java/com/facebook:fb4a", rootTarget.getFullyQualifiedName());
   assertEquals("//java/com/facebook:fb4a", rootTarget.toString());
 }
コード例 #10
0
ファイル: BuildTargetTest.java プロジェクト: disigma/buck
 @Test
 public void testRootBuildTarget() {
   BuildTarget rootTarget = BuildTarget.builder(ROOT, "//", "fb4a").build();
   assertEquals("fb4a", rootTarget.getShortNameAndFlavorPostfix());
   assertEquals("//", rootTarget.getBaseName());
   assertEquals("//", rootTarget.getBaseNameWithSlash());
   assertEquals(Paths.get(""), rootTarget.getBasePath());
   assertEquals("", rootTarget.getBasePathWithSlash());
   assertEquals("//:fb4a", rootTarget.getFullyQualifiedName());
   assertEquals("//:fb4a", rootTarget.toString());
 }
コード例 #11
0
ファイル: BuildTargetTest.java プロジェクト: disigma/buck
 @Test
 public void testFlavorIsValid() {
   try {
     BuildTarget.builder(ROOT, "//foo/bar", "baz").addFlavors(ImmutableFlavor.of("d!x")).build();
     fail("Should have thrown IllegalArgumentException.");
   } catch (IllegalArgumentException e) {
     assertEquals("Invalid characters in flavor name: d!x", e.getMessage());
   }
 }
コード例 #12
0
ファイル: BuildTargetTest.java プロジェクト: disigma/buck
 @Test
 public void testShortNameCannotContainHashWhenFlavorSet() {
   try {
     BuildTarget.builder(ROOT, "//foo/bar", "baz#dex")
         .addFlavors(ImmutableFlavor.of("src-jar"))
         .build();
     fail("Should have thrown IllegalArgumentException.");
   } catch (IllegalArgumentException e) {
     assertEquals("Build target name cannot contain '#' but was: baz#dex.", e.getMessage());
   }
 }
コード例 #13
0
ファイル: IncrementalBuilder.java プロジェクト: hammoum/gwt
 private void forgetAllOutputFreshness() {
   for (BuildTarget buildTarget : buildTargetsByCanonicalModuleName.values()) {
     buildTarget.setOutputFreshness(OutputFreshness.UNKNOWN);
   }
 }
コード例 #14
0
ファイル: BuildTargetTest.java プロジェクト: disigma/buck
 @Test
 public void testEqualsNullReturnsFalse() {
   BuildTarget utilTarget =
       BuildTarget.builder(ROOT, "//src/com/facebook/buck/util", "util").build();
   assertNotNull(utilTarget);
 }
コード例 #15
0
ファイル: BuildTargetTest.java プロジェクト: disigma/buck
 @Test
 public void testNumbersAreValidFlavors() {
   BuildTarget.builder(ROOT, "//foo", "bar").addFlavors(ImmutableFlavor.of("1234")).build();
 }
コード例 #16
0
ファイル: BuildTargetTest.java プロジェクト: disigma/buck
 @Test
 public void testFlavorDefaultsToNoneIfNotSet() {
   assertEquals(
       ImmutableSet.<Flavor>of(),
       BuildTarget.builder(ROOT, "//foo/bar", "baz").build().getFlavors());
 }
コード例 #17
0
ファイル: BuildTargetTest.java プロジェクト: disigma/buck
 @Test(expected = IllegalArgumentException.class)
 public void testShortNamesMustNotContainTheFlavorSeparator() {
   BuildTarget.builder(ROOT, "//foo/bar", "baz#dex").build();
 }