Search in sources :

Example 1 with SupportsWorkers

use of com.google.devtools.build.lib.rules.java.JavaToolchainData.SupportsWorkers in project bazel by bazelbuild.

the class JavaToolchainDataParser method parseBuildRuleProto.

private static JavaToolchainData parseBuildRuleProto(Build.Rule rule) {
    String source = "";
    String target = "";
    ImmutableList<String> bootclasspath = ImmutableList.of();
    ImmutableList<String> extclasspath = ImmutableList.of();
    String encoding = "";
    ImmutableList<String> xlint = ImmutableList.of();
    ImmutableList<String> misc = ImmutableList.of();
    ImmutableList<String> jvmOpts = ImmutableList.of();
    SupportsWorkers javacSupportsWorkers = SupportsWorkers.NO;
    for (Build.Attribute attribute : rule.getAttributeList()) {
        switch(attribute.getName()) {
            case "source_version":
                source = attribute.getStringValue();
                break;
            case "target_version":
                target = attribute.getStringValue();
                break;
            case "bootclasspath":
                bootclasspath = ImmutableList.copyOf(attribute.getStringListValueList());
                break;
            case "extclasspath":
                extclasspath = ImmutableList.copyOf(attribute.getStringListValueList());
                break;
            case "encoding":
                encoding = attribute.getStringValue();
                break;
            case "xlint":
                xlint = ImmutableList.copyOf(attribute.getStringListValueList());
                break;
            case "misc":
                {
                    List<String> options = new ArrayList<>();
                    for (String option : attribute.getStringListValueList()) {
                        try {
                            ShellUtils.tokenize(options, option);
                        } catch (ShellUtils.TokenizationException e) {
                            // Tokenization failed; this likely means that the user
                            // did not want tokenization to happen on the argument.
                            // (see JavaHelper.tokenizeJavaOptions)
                            options.add(option);
                        }
                    }
                    misc = ImmutableList.copyOf(options);
                    break;
                }
            case "jvm_opts":
                jvmOpts = ImmutableList.copyOf(attribute.getStringListValueList());
                break;
            case "javac_supports_workers":
                if (attribute.getBooleanValue()) {
                    javacSupportsWorkers = SupportsWorkers.YES;
                }
                break;
        }
    }
    return new JavaToolchainData(source, target, bootclasspath, extclasspath, encoding, xlint, misc, jvmOpts, javacSupportsWorkers);
}
Also used : SupportsWorkers(com.google.devtools.build.lib.rules.java.JavaToolchainData.SupportsWorkers) Build(com.google.devtools.build.lib.query2.proto.proto2api.Build) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ArrayList(java.util.ArrayList)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 Build (com.google.devtools.build.lib.query2.proto.proto2api.Build)1 SupportsWorkers (com.google.devtools.build.lib.rules.java.JavaToolchainData.SupportsWorkers)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1