From baae7ea12b8e41a478d7cf987a2218734e5a7722 Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Thu, 31 Aug 2017 10:49:58 -0700 Subject: Add @Deprecated annotation support for proto file. --- java/core/generate-test-sources-build.xml | 1 + .../com/google/protobuf/deprecated_file.proto | 35 ++++++++++++++++++++++ src/google/protobuf/compiler/java/java_file.cc | 7 +++-- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 java/core/src/test/proto/com/google/protobuf/deprecated_file.proto diff --git a/java/core/generate-test-sources-build.xml b/java/core/generate-test-sources-build.xml index 68951747..abcdf5dd 100644 --- a/java/core/generate-test-sources-build.xml +++ b/java/core/generate-test-sources-build.xml @@ -19,6 +19,7 @@ + diff --git a/java/core/src/test/proto/com/google/protobuf/deprecated_file.proto b/java/core/src/test/proto/com/google/protobuf/deprecated_file.proto new file mode 100644 index 00000000..a0ffadd4 --- /dev/null +++ b/java/core/src/test/proto/com/google/protobuf/deprecated_file.proto @@ -0,0 +1,35 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package deprecated_file; + +option deprecated = true; diff --git a/src/google/protobuf/compiler/java/java_file.cc b/src/google/protobuf/compiler/java/java_file.cc index 2d5465ba..21133a15 100644 --- a/src/google/protobuf/compiler/java/java_file.cc +++ b/src/google/protobuf/compiler/java/java_file.cc @@ -248,9 +248,12 @@ void FileGenerator::Generate(io::Printer* printer) { PrintGeneratedAnnotation( printer, '$', options_.annotate_code ? classname_ + ".java.pb.meta" : ""); printer->Print( - "public final class $classname$ {\n" + "$deprecation$public final class $classname$ {\n" " private $ctor$() {}\n", - "classname", classname_, "ctor", classname_); + "deprecation", file_->options().deprecated() ? + "@java.lang.Deprecated " : "", + "classname", classname_, + "ctor", classname_); printer->Annotate("classname", file_->name()); printer->Indent(); -- cgit v1.2.3 From dd69d5cb5ef208f95d26a684f49b82edaf20300a Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Thu, 31 Aug 2017 11:11:21 -0700 Subject: Fix dist check --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index 323cc683..fc47c9c5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -332,6 +332,7 @@ java_EXTRA_DIST= java/core/src/test/java/com/google/protobuf/WellKnownTypesTest.java \ java/core/src/test/java/com/google/protobuf/WireFormatTest.java \ java/core/src/test/proto/com/google/protobuf/any_test.proto \ + java/core/src/test/proto/com/google/protobuf/deprecated_file.proto \ java/core/src/test/proto/com/google/protobuf/field_presence_test.proto \ java/core/src/test/proto/com/google/protobuf/lazy_fields_lite.proto \ java/core/src/test/proto/com/google/protobuf/lite_equals_and_hash.proto \ -- cgit v1.2.3 From f9b81690f56b8153cbe8b4523ed2b4338c69fd47 Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Thu, 31 Aug 2017 11:24:05 -0700 Subject: Add TODO --- java/core/src/test/proto/com/google/protobuf/deprecated_file.proto | 3 +++ 1 file changed, 3 insertions(+) diff --git a/java/core/src/test/proto/com/google/protobuf/deprecated_file.proto b/java/core/src/test/proto/com/google/protobuf/deprecated_file.proto index a0ffadd4..ca90e927 100644 --- a/java/core/src/test/proto/com/google/protobuf/deprecated_file.proto +++ b/java/core/src/test/proto/com/google/protobuf/deprecated_file.proto @@ -33,3 +33,6 @@ syntax = "proto3"; package deprecated_file; option deprecated = true; + +// TODO (liujisi): Add deprecation options on messages, enums fields as well and +// add tests to verify those annotations are actually generated. -- cgit v1.2.3 From e3be1febf227647ec8b54f939b07a43d60450e91 Mon Sep 17 00:00:00 2001 From: drivehappy Date: Wed, 13 Sep 2017 16:10:35 -0700 Subject: Clang warning cleanup for unused parameter. --- src/google/protobuf/arena.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index f8a94705..78e8d902 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -853,7 +853,7 @@ class LIBPROTOBUF_EXPORT Arena { template GOOGLE_ATTRIBUTE_ALWAYS_INLINE static ::google::protobuf::Arena* GetArenaInternal( - const T* value, google::protobuf::internal::false_type) { + const T* /* value */, google::protobuf::internal::false_type) { return NULL; } -- cgit v1.2.3 From 3130ce03fd0439e17d30b98833568a0eb9bc1a2b Mon Sep 17 00:00:00 2001 From: Param Reddy Date: Sun, 15 Oct 2017 13:06:58 -0700 Subject: Fix iOS cc_library build for protobuf. The SDK and os versions were hard coded. Archs were mixed up. Because of this, Was getting errors with latest SDK: clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/' [-Wmissing-sysroot] clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/' [-Wmissing-sysroot] clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/' [-Wmissing-sysroot] In file included from external/com_google_protobuf/src/google/protobuf/io/printer.cc:35: In file included from external/com_google_protobuf/src/google/protobuf/io/printer.h:40: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:470: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:171: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:56: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:638: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:61: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string.h:61:15: fatal error: 'string.h' file not found ^~~~~~~~~~ 1 error generated. Currently none of these are needed when using bazel with https://github.com/bazelbuild/rules_apple. -target arm64-apple-ios is passed properly to clang. So -arch armv7 etc are not needed. OS_IOS is not used anywhere. Sources have: GOOGLE_PROTOBUF_NO_THREADLOCAL defined in src/google/protobuf/stubs/platform_macros.h for iOS. So __thread= is not needed. In fact now that bazel is using C++11 by default, __thread should ideally be moved to thread_local. -miphoneos-version-min is passed by rules_apple. --- BUILD | 45 ++------------------------------------------- 1 file changed, 2 insertions(+), 43 deletions(-) diff --git a/BUILD b/BUILD index cacd2375..d45e5952 100644 --- a/BUILD +++ b/BUILD @@ -59,37 +59,6 @@ load( "internal_protobuf_py_tests", ) -config_setting( - name = "ios_armv7", - values = { - "ios_cpu": "armv7", - }, -) - -config_setting( - name = "ios_armv7s", - values = { - "ios_cpu": "armv7s", - }, -) - -config_setting( - name = "ios_arm64", - values = { - "ios_cpu": "arm64", - }, -) - -IOS_ARM_COPTS = [ - "-DOS_IOS", - "-miphoneos-version-min=7.0", - "-arch armv7", - "-arch armv7s", - "-arch arm64", - "-D__thread=", - "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/", -] - cc_library( name = "protobuf_lite", srcs = [ @@ -121,12 +90,7 @@ cc_library( "src/google/protobuf/wire_format_lite.cc", ], hdrs = glob(["src/google/protobuf/**/*.h"]), - copts = select({ - ":ios_armv7": IOS_ARM_COPTS, - ":ios_armv7s": IOS_ARM_COPTS, - ":ios_arm64": IOS_ARM_COPTS, - "//conditions:default": [], - }) + COPTS, + copts = COPTS, includes = ["src/"], linkopts = LINK_OPTS, visibility = ["//visibility:public"], @@ -193,12 +157,7 @@ cc_library( "src/google/protobuf/wrappers.pb.cc", ], hdrs = glob(["src/**/*.h"]), - copts = select({ - ":ios_armv7": IOS_ARM_COPTS, - ":ios_armv7s": IOS_ARM_COPTS, - ":ios_arm64": IOS_ARM_COPTS, - "//conditions:default": [], - }) + COPTS, + copts = COPTS, includes = ["src/"], linkopts = LINK_OPTS, visibility = ["//visibility:public"], -- cgit v1.2.3