diff options
author | 2018-01-07 14:48:53 -0800 | |
---|---|---|
committer | 2018-01-07 14:50:48 -0800 | |
commit | 590057a58b67e7aa073e55fc4719914e2bf48e22 (patch) | |
tree | 1e61a3cbad3c59149245e4389afb8c8f3522beec /src/main | |
parent | 8ab32fcb0affb45a9c299cac580f1251fb6a16bc (diff) |
Deletes FakeAutoCodecProcessor.
This is not needed for bootstrapping, which can be done using the real
AutoCodecProcessor anyway.
PiperOrigin-RevId: 181099386
Diffstat (limited to 'src/main')
2 files changed, 3 insertions, 118 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec/BUILD b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec/BUILD index 3b0d365196..da038b425e 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec/BUILD +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec/BUILD @@ -45,12 +45,12 @@ java_library( name = "autocodec-processor", srcs = [ "AutoCodecProcessor.java", + "AutoCodecUtil.java", "Marshaller.java", "Marshallers.java", ], deps = [ ":autocodec-annotation", - ":autocodec-util", ":unsafe-provider", "//src/main/java/com/google/devtools/build/lib/skyframe/serialization", "//third_party:auto_service", @@ -61,32 +61,6 @@ java_library( ], ) -# Code shared between autocodec-processor and fake-autocodec-processor. -java_library( - name = "autocodec-util", - srcs = ["AutoCodecUtil.java"], - deps = [ - ":autocodec-annotation", - "//src/main/java/com/google/devtools/build/lib/skyframe/serialization", - "//third_party:guava", - "//third_party:jsr305", - "//third_party/java/javapoet", - "//third_party/protobuf:protobuf_java", - ], -) - -# This is a fake implementation for bootstrapping. It must *not* be used in production. -java_library( - name = "fake-autocodec-processor", - srcs = ["FakeAutoCodecProcessor.java"], - deps = [ - ":autocodec-util", - "//third_party:auto_service", - "//third_party:guava", - "//third_party/java/javapoet", - ], -) - load("//tools/build_defs/pkg:pkg.bzl", "pkg_tar") # .tar archive of dependencies used for bootstrapping. @@ -97,8 +71,8 @@ pkg_tar( # from the LIBRARY_JARS rule of bazel/scripts/bootstrap/compile.sh. files = { ":libautocodec-annotation.jar": "third_party/bazel_bootstrap/libautocodec-annotation.jar", - ":libautocodec-util.jar": "third_party/bazel_bootstrap/libautocodec-util.jar", - ":libfake-autocodec-processor.jar": "third_party/bazel_bootstrap/libfake-autocodec-processor.jar", + ":libautocodec-processor.jar": "third_party/bazel_bootstrap/libautocodec-processor.jar", + ":libunsafe-provider.jar": "third_party/bazel_bootstrap/libunsafe-provider.jar", "//src/main/java/com/google/devtools/build/lib/skyframe/serialization:libserialization.jar": "third_party/bazel_bootstrap/libserialization.jar", }, visibility = ["//visibility:public"], diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec/FakeAutoCodecProcessor.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec/FakeAutoCodecProcessor.java deleted file mode 100644 index 7a46fbb12f..0000000000 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec/FakeAutoCodecProcessor.java +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2017 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.devtools.build.lib.skyframe.serialization.autocodec; - -import com.google.auto.service.AutoService; -import com.google.common.collect.ImmutableSet; -import com.squareup.javapoet.JavaFile; -import com.squareup.javapoet.TypeSpec; -import java.io.IOException; -import java.util.Set; -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.ProcessingEnvironment; -import javax.annotation.processing.Processor; -import javax.annotation.processing.RoundEnvironment; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.Element; -import javax.lang.model.element.TypeElement; -import javax.tools.Diagnostic; - -/** - * A fake annotation processor for bootstrapping. - * - * <p>When bootstrapping, annotation processors inside the Bazel source tree are not available which - * means that if there are dependencies on generated code, bootstrapping will fail. This processor - * generates stub code to pass the initial boostrapping phase. - */ -@AutoService(Processor.class) -public class FakeAutoCodecProcessor extends AbstractProcessor { - private ProcessingEnvironment env; // Captured from `init` method. - - @Override - public Set<String> getSupportedAnnotationTypes() { - return ImmutableSet.of(AutoCodecUtil.ANNOTATION.getCanonicalName()); - } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latestSupported(); // Supports all versions of Java. - } - - @Override - public synchronized void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - this.env = processingEnv; - } - - @Override - public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { - for (Element element : roundEnv.getElementsAnnotatedWith(AutoCodecUtil.ANNOTATION)) { - TypeElement encodedType = (TypeElement) element; - TypeSpec.Builder codecClassBuilder = AutoCodecUtil.initializeCodecClassBuilder(encodedType); - codecClassBuilder.addMethod( - AutoCodecUtil.initializeGetEncodedClassMethod(encodedType) - .addStatement("throw new RuntimeException(\"Shouldn't be called.\")") - .build()); - codecClassBuilder.addMethod( - AutoCodecUtil.initializeSerializeMethodBuilder(encodedType) - .addStatement("throw new RuntimeException(\"Shouldn't be called.\")") - .build()); - codecClassBuilder.addMethod( - AutoCodecUtil.initializeDeserializeMethodBuilder(encodedType) - .addStatement("throw new RuntimeException(\"Shouldn't be called.\")") - .build()); - String packageName = - env.getElementUtils().getPackageOf(encodedType).getQualifiedName().toString(); - try { - JavaFile file = JavaFile.builder(packageName, codecClassBuilder.build()).build(); - file.writeTo(env.getFiler()); - } catch (IOException e) { - env.getMessager() - .printMessage( - Diagnostic.Kind.ERROR, "Failed to generate output file: " + e.getMessage()); - } - } - return true; - } -} |