Example #1
0
  private Optional<RuleKey> calculateDepFileRuleKey(
      BuildRule rule, Optional<ImmutableList<String>> depFile, boolean allowMissingInputs)
      throws IOException {

    Preconditions.checkState(useDependencyFileRuleKey(rule));

    // Extract the dep file from the last build.  If we don't find one, abort.
    if (!depFile.isPresent()) {
      return Optional.absent();
    }

    // Add in the inputs explicitly listed in the dep file.  If any inputs are no longer on disk,
    // this means something changed and a dep-file based rule key can't be calculated.
    ImmutableList<Path> inputs =
        FluentIterable.from(depFile.get()).transform(MorePaths.TO_PATH).toList();
    RuleKeyBuilder builder = depFileRuleKeyBuilderFactory.newInstance(rule);
    for (Path input : inputs) {
      try {
        builder.setPath(input);
      } catch (NoSuchFileException e) {
        if (!allowMissingInputs) {
          throw e;
        }
        return Optional.absent();
      }
    }

    return Optional.of(builder.build());
  }
Example #2
0
  @Test(expected = HumanReadableException.class)
  public void shouldNotAllowPathsInRuleKeysWhenSetReflectively() {
    SourcePathResolver resolver =
        new SourcePathResolver(
            new BuildRuleResolver(TargetGraph.EMPTY, new BuildTargetNodeToBuildRuleTransformer()));
    RuleKeyBuilder builder = createEmptyRuleKey(resolver);

    builder.setReflectively("path", Paths.get("some/path"));
  }
Example #3
0
 @Override
 public RuleKeyBuilder appendToRuleKey(RuleKeyBuilder builder) {
   return builder
       .setReflectively("value", value)
       .setReflectively("foo", "foo")
       .setReflectively("bar", "bar");
 }
Example #4
0
 // Put the link map into the rule key, as if it changes at all, we need to
 // re-run it.
 @Override
 public RuleKeyBuilder appendToRuleKey(RuleKeyBuilder builder) {
   for (Map.Entry<Path, SourcePath> entry : links.entrySet()) {
     builder.setReflectively(
         "link(" + entry.getKey().toString() + ")",
         getResolver().deprecatedGetPath(entry.getValue()).toString());
   }
   return builder;
 }
Example #5
0
 @Override
 public RuleKeyBuilder appendToRuleKey(RuleKeyBuilder builder) {
   return builder.setReflectively("foo", foo);
 }