Search in sources :

Example 1 with BuildRuleStatus

use of com.facebook.buck.rules.BuildRuleStatus in project buck by facebook.

the class BuckBuildLog method fromLogContents.

public static BuckBuildLog fromLogContents(Path root, List<String> logContents) {
    ImmutableMap.Builder<BuildTarget, BuildLogEntry> builder = ImmutableMap.builder();
    for (String line : logContents) {
        Matcher matcher = BUILD_LOG_FINISHED_RULE_REGEX.matcher(line);
        if (!matcher.matches()) {
            continue;
        }
        String buildTargetRaw = matcher.group("BuildTarget");
        BuildTarget buildTarget = BuildTargetFactory.newInstance(root, buildTargetRaw);
        String statusRaw = matcher.group("Status");
        BuildRuleStatus status = BuildRuleStatus.valueOf(statusRaw);
        String ruleKeyRaw = matcher.group("RuleKey");
        Sha1HashCode ruleKey = Sha1HashCode.of(ruleKeyRaw);
        CacheResult cacheResult = null;
        BuildRuleSuccessType successType = null;
        if (status == BuildRuleStatus.SUCCESS) {
            String cacheResultRaw = matcher.group("CacheResult");
            cacheResult = CacheResult.valueOf(cacheResultRaw);
            String successTypeRaw = matcher.group("SuccessType");
            successType = BuildRuleSuccessType.valueOf(successTypeRaw);
        }
        builder.put(buildTarget, new BuildLogEntry(status, Optional.ofNullable(successType), Optional.ofNullable(cacheResult), ruleKey));
    }
    return new BuckBuildLog(root, builder.build());
}
Also used : Matcher(java.util.regex.Matcher) BuildTarget(com.facebook.buck.model.BuildTarget) Sha1HashCode(com.facebook.buck.util.sha1.Sha1HashCode) BuildRuleSuccessType(com.facebook.buck.rules.BuildRuleSuccessType) CacheResult(com.facebook.buck.artifact_cache.CacheResult) BuildRuleStatus(com.facebook.buck.rules.BuildRuleStatus) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

CacheResult (com.facebook.buck.artifact_cache.CacheResult)1 BuildTarget (com.facebook.buck.model.BuildTarget)1 BuildRuleStatus (com.facebook.buck.rules.BuildRuleStatus)1 BuildRuleSuccessType (com.facebook.buck.rules.BuildRuleSuccessType)1 Sha1HashCode (com.facebook.buck.util.sha1.Sha1HashCode)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Matcher (java.util.regex.Matcher)1