Browse Source

Merge pull request #1893 from google/3.0.0-GA

Merge 3.0.0-GA into master
Jisi Liu 9 years ago
parent
commit
169d0ca43c

+ 4 - 0
.travis.yml

@@ -57,6 +57,10 @@ matrix:
     # tests on jenkins running in parallel.
     - os: linux
       env: CONFIG=cpp_distcheck
+    # The Java compatibility test currently only runs on Linux because it will
+    # fetch pre-built Linux protoc binaries in the test.
+    - os: linux
+      env: CONFIG=java_compatibility
   allow_failures:
     # These currently do not work on OS X but are being worked on by @haberman.
     - os: osx

+ 51 - 0
CHANGES.txt

@@ -1,3 +1,54 @@
+2016-07-27 version 3.0.0 (C++/Java/Python/Ruby/Objective-C/C#/JavaScript/Lite)
+  General
+  * This log only contains changes since the beta-4 release. Summarized change
+    log since the last stable release (v2.6.1) can be found in the github
+    release page.
+
+  Compatibility Notice
+  * v3.0.0 is the first API stable release of the v3.x series. We do not expect
+    any future API breaking changes.
+  * For C++, Java Lite and Objective-C, source level compatibility is
+    guaranteed.  Upgrading from v3.0.0 to newer minor version releases will be
+    source compatible. For example, if your code compiles against protobuf
+    v3.0.0, it will continue to compile after you upgrade protobuf library to
+    v3.1.0.
+  * For other languages, both source level compatibility and binary level
+    compatibility are guaranteed. For example, if you have a Java binary built
+    against protobuf v3.0.0. After switching the protobuf runtime binary to
+    v3.1.0, your built binary should continue to work.
+  * Compatibility is only guaranteed for documented API and documented
+    behaviors. If you are using undocumented API (e.g., use anything in the C++
+    internal namespace), it can be broken by minor version releases in an
+    undetermined manner.
+
+  Ruby
+  * When you assign a string field `a.string_field = "X"`, we now call
+    #encode(UTF-8) on the string and freeze the copy. This saves you from
+    needing to ensure the string is already encoded as UTF-8. It also prevents
+    you from mutating the string after it has been assigned (this is how we
+    ensure it stays valid UTF-8).
+  * The generated file for `foo.proto` is now `foo_pb.rb` instead of just
+    `foo.rb`. This makes it easier to see which imports/requires are from
+    protobuf generated code, and also prevents conflicts with any `foo.rb` file
+    you might have written directly in Ruby. It is a backward-incompatible
+    change: you will need to update all of your `require` statements.
+  * For package names like `foo_bar`, we now translate this to the Ruby module
+    `FooBar`. This is more idiomatic Ruby than what we used to do (`Foo_bar`).
+
+  JavaScript
+  * Scalar fields like numbers and boolean now return defaults instead of
+    `undefined` or `null` when they are unset. You can test for presence
+    explicitly by calling `hasFoo()`, which we now generate for scalar fields.
+
+  Java Lite
+  * Java Lite is now implemented as a separate plugin, maintained in the
+    `javalite` branch. Both lite runtime and protoc artifacts will be available
+    in Maven.
+
+  C#
+  * Target platforms now .NET 4.5, selected portable subsets and .NET Core.
+  * legacy_enum_values option is no longer supported.
+
 2016-07-15 version 3.0.0-beta-4 (C++/Java/Python/Ruby/Objective-C/C#/JavaScript)
   General
   * Added a deterministic serialization API for C++. The deterministic

+ 1 - 1
Protobuf.podspec

@@ -5,7 +5,7 @@
 # dependent projects use the :git notation to refer to the library.
 Pod::Spec.new do |s|
   s.name     = 'Protobuf'
-  s.version  = '3.0.0-beta-4'
+  s.version  = '3.0.0'
   s.summary  = 'Protocol Buffers v.3 runtime library for Objective-C.'
   s.homepage = 'https://github.com/google/protobuf'
   s.license  = 'New BSD'

+ 1 - 1
configure.ac

@@ -17,7 +17,7 @@ AC_PREREQ(2.59)
 # In the SVN trunk, the version should always be the next anticipated release
 # version with the "-pre" suffix.  (We used to use "-SNAPSHOT" but this pushed
 # the size of one file name in the dist tarfile over the 99-char limit.)
-AC_INIT([Protocol Buffers],[3.0.0-beta-4],[protobuf@googlegroups.com],[protobuf])
+AC_INIT([Protocol Buffers],[3.0.0],[protobuf@googlegroups.com],[protobuf])
 
 AM_MAINTAINER_MODE([enable])
 

+ 1 - 1
csharp/Google.Protobuf.Tools.nuspec

@@ -5,7 +5,7 @@
     <title>Google Protocol Buffers tools</title>
     <summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
     <description>See project site for more info.</description>
-    <version>3.0.0-beta4</version>
+    <version>3.0.0</version>
     <authors>Google Inc.</authors>
     <owners>protobuf-packages</owners>
     <licenseUrl>https://github.com/google/protobuf/blob/master/LICENSE</licenseUrl>

+ 1 - 1
csharp/src/Google.Protobuf/project.json

@@ -1,5 +1,5 @@
 {
-  "version": "3.0.0-beta4",
+  "version": "3.0.0",
   "title": "Google Protocol Buffers",
   "description": "See project site for more info.",
   "authors": [ "Google Inc." ],

+ 1 - 1
java/core/pom.xml

@@ -6,7 +6,7 @@
   <parent>
     <groupId>com.google.protobuf</groupId>
     <artifactId>protobuf-parent</artifactId>
-    <version>3.0.0-beta-4</version>
+    <version>3.0.0</version>
   </parent>
 
   <artifactId>protobuf-java</artifactId>

+ 1 - 1
java/lite/pom.xml

@@ -6,7 +6,7 @@
   <parent>
     <groupId>com.google.protobuf</groupId>
     <artifactId>protobuf-parent</artifactId>
-    <version>3.0.0-beta-4</version>
+    <version>3.0.0</version>
   </parent>
 
   <artifactId>protobuf-lite</artifactId>

+ 1 - 1
java/pom.xml

@@ -11,7 +11,7 @@
 
   <groupId>com.google.protobuf</groupId>
   <artifactId>protobuf-parent</artifactId>
-  <version>3.0.0-beta-4</version>
+  <version>3.0.0</version>
   <packaging>pom</packaging>
 
   <name>Protocol Buffers [Parent]</name>

+ 1 - 1
java/util/pom.xml

@@ -6,7 +6,7 @@
   <parent>
     <groupId>com.google.protobuf</groupId>
     <artifactId>protobuf-parent</artifactId>
-    <version>3.0.0-beta-4</version>
+    <version>3.0.0</version>
   </parent>
 
   <artifactId>protobuf-java-util</artifactId>

+ 1 - 1
js/package.json

@@ -1,6 +1,6 @@
 {
   "name": "google-protobuf",
-  "version": "3.0.0-alpha.7",
+  "version": "3.0.0",
   "description": "Protocol Buffers for JavaScript",
   "main": "google-protobuf.js",
   "files": [

+ 19 - 8
protoc-artifacts/build-protoc.sh

@@ -1,17 +1,30 @@
 #!/bin/bash
 
-# Builds protoc executable into target/protoc.exe
+# Builds protoc executable into target/protoc.exe; optionally build protoc
+# plugins into target/protoc-gen-*.exe
 # To be run from Maven.
-# Usage: build-protoc.sh <OS> <ARCH>
+# Usage: build-protoc.sh <OS> <ARCH> <TARGET>
 # <OS> and <ARCH> are ${os.detected.name} and ${os.detected.arch} from os-maven-plugin
+# <TARGET> can be "protoc" or "protoc-gen-javalite"
 OS=$1
 ARCH=$2
+MAKE_TARGET=$3
 
-if [[ $# < 2 ]]; then
+if [[ $# < 3 ]]; then
   echo "No arguments provided. This script is intended to be run from Maven."
   exit 1
 fi
 
+case $MAKE_TARGET in
+  protoc-gen-javalite)
+    ;;
+  protoc)
+    ;;
+  *)
+    echo "Target ""$TARGET"" invalid."
+    exit 1
+esac
+
 # Under Cygwin, bash doesn't have these in PATH when called from Maven which
 # runs in Windows version of Java.
 export PATH="/bin:/usr/bin:$PATH"
@@ -126,7 +139,7 @@ checkDependencies ()
 }
 ############################################################################
 
-echo "Building protoc, OS=$OS ARCH=$ARCH"
+echo "Building protoc, OS=$OS ARCH=$ARCH TARGET=$TARGET"
 
 # Nested double quotes are unintuitive, but it works.
 cd "$(dirname "$0")"
@@ -134,7 +147,7 @@ cd "$(dirname "$0")"
 WORKING_DIR=$(pwd)
 CONFIGURE_ARGS="--disable-shared"
 
-MAKE_TARGET="protoc"
+TARGET_FILE=target/$MAKE_TARGET.exe
 if [[ "$OS" == windows ]]; then
   MAKE_TARGET="${MAKE_TARGET}.exe"
 fi
@@ -209,12 +222,10 @@ fi
 
 export CXXFLAGS LDFLAGS
 
-TARGET_FILE=target/protoc.exe
-
 cd "$WORKING_DIR"/.. && ./configure $CONFIGURE_ARGS &&
   cd src && make clean && make $MAKE_TARGET &&
   cd "$WORKING_DIR" && mkdir -p target &&
-  (cp ../src/protoc $TARGET_FILE || cp ../src/protoc.exe $TARGET_FILE) ||
+  cp ../src/$MAKE_TARGET $TARGET_FILE ||
   exit 1
 
 if [[ "$OS" == osx ]]; then

+ 33 - 19
protoc-artifacts/build-zip.sh

@@ -1,26 +1,30 @@
 #!/bin/bash
 
-if [ $# -eq 0 ]; then
+if [ $# -ne 2 ]; then
   cat <<EOF
-Usage: $0 <VERSION_NUMBER>
+Usage: $0 <TARGET> <VERSION_NUMBER>
+
+TARGET: protoc | protoc-gen-javalite
 
 Example:
-  $ $0 3.0.0-beta-4
+  $ $0 protoc 3.0.0
+  $ $0 protoc-gen-javalite 3.0.0
 
-This script will download pre-built protoc binaries from maven repository
-and package them with well-known type .proto files to create .zip packages
-suitable to be included in the github release page. Each invocation will
-create 5 zip packages:
-  dist/protoc-<VERSION_NUMBER>-win32.zip
-  dist/protoc-<VERSION_NUMBER>-osx-x86_32.zip
-  dist/protoc-<VERSION_NUMBER>-osx-x86_64.zip
-  dist/protoc-<VERSION_NUMBER>-linux-x86_32.zip
-  dist/protoc-<VERSION_NUMBER>-linux-x86_64.zip
+This script will download pre-built protoc or protoc plugin binaries from maven
+repository and create .zip packages suitable to be included in the github
+release page. If the target is protoc, well-known type .proto files will also be
+included. Each invocation will create 5 zip packages:
+  dist/<TARGET>-<VERSION_NUMBER>-win32.zip
+  dist/<TARGET>-<VERSION_NUMBER>-osx-x86_32.zip
+  dist/<TARGET>-<VERSION_NUMBER>-osx-x86_64.zip
+  dist/<TARGET>-<VERSION_NUMBER>-linux-x86_32.zip
+  dist/<TARGET>-<VERSION_NUMBER>-linux-x86_64.zip
 EOF
   exit 1
 fi
 
-VERSION_NUMBER=$1
+TARGET=$1
+VERSION_NUMBER=$2
 
 # <zip file name> <binary file name> pairs.
 declare -a FILE_NAMES=( \
@@ -78,17 +82,27 @@ mkdir -p ${DIR}/bin
 # Create a zip file for each binary.
 for((i=0;i<${#FILE_NAMES[@]};i+=2));do
   ZIP_NAME=${FILE_NAMES[$i]}
+  if [ ${ZIP_NAME:0:3} = "win" ]; then
+    BINARY="$TARGET.exe"
+  else
+    BINARY="$TARGET"
+  fi
   BINARY_NAME=${FILE_NAMES[$(($i+1))]}
-  BINARY_URL=http://repo1.maven.org/maven2/com/google/protobuf/protoc/${VERSION_NUMBER}/protoc-${VERSION_NUMBER}-${BINARY_NAME}
-  if ! wget ${BINARY_URL} -O ${DIR}/bin/protoc &> /dev/null; then
+  BINARY_URL=http://repo1.maven.org/maven2/com/google/protobuf/$TARGET/${VERSION_NUMBER}/$TARGET-${VERSION_NUMBER}-${BINARY_NAME}
+  if ! wget ${BINARY_URL} -O ${DIR}/bin/$BINARY &> /dev/null; then
     echo "[ERROR] Failed to download ${BINARY_URL}" >&2
-    echo "[ERROR] Skipped protoc-${VERSION_NAME}-${ZIP_NAME}" >&2
+    echo "[ERROR] Skipped $TARGET-${VERSION_NAME}-${ZIP_NAME}" >&2
     continue
   fi
-  TARGET_ZIP_FILE=`pwd`/dist/protoc-${VERSION_NUMBER}-${ZIP_NAME}
+  TARGET_ZIP_FILE=`pwd`/dist/$TARGET-${VERSION_NUMBER}-${ZIP_NAME}
   pushd $DIR &> /dev/null
-  chmod +x bin/protoc
-  zip -r ${TARGET_ZIP_FILE} include bin readme.txt &> /dev/null
+  chmod +x bin/$BINARY
+  if [ "$TARGET" = "protoc" ]; then
+    zip -r ${TARGET_ZIP_FILE} include bin readme.txt &> /dev/null
+  else
+    zip -r ${TARGET_ZIP_FILE} bin &> /dev/null
+  fi
+  rm  bin/$BINARY
   popd &> /dev/null
   echo "[INFO] Successfully created ${TARGET_ZIP_FILE}"
 done

+ 2 - 1
protoc-artifacts/pom.xml

@@ -10,7 +10,7 @@
   </parent>
   <groupId>com.google.protobuf</groupId>
   <artifactId>protoc</artifactId>
-  <version>3.0.0-beta-4</version>
+  <version>3.0.0</version>
   <packaging>pom</packaging>
   <name>Protobuf Compiler</name>
   <description>
@@ -59,6 +59,7 @@
             <argument>build-protoc.sh</argument>
             <argument>${os.detected.name}</argument>
             <argument>${os.detected.arch}</argument>
+            <argument>protoc</argument>
           </arguments>
         </configuration>
       </plugin>

+ 1 - 1
python/google/protobuf/__init__.py

@@ -30,7 +30,7 @@
 
 # Copyright 2007 Google Inc. All Rights Reserved.
 
-__version__ = '3.0.0b4'
+__version__ = '3.0.0'
 
 if __name__ != '__main__':
   try:

+ 2 - 0
python/setup.cfg

@@ -0,0 +1,2 @@
+[bdist_wheel]
+universal = 1

+ 1 - 1
ruby/google-protobuf.gemspec

@@ -1,6 +1,6 @@
 Gem::Specification.new do |s|
   s.name        = "google-protobuf"
-  s.version     = "3.0.0.alpha.7.0.0"
+  s.version     = "3.0.0"
   s.licenses    = ["BSD"]
   s.summary     = "Protocol Buffers"
   s.description = "Protocol Buffers are Google's data interchange format."

+ 1 - 1
ruby/pom.xml

@@ -86,7 +86,7 @@
         <dependency>
             <groupId>com.google.protobuf</groupId>
             <artifactId>protobuf-java</artifactId>
-            <version>3.0.0-beta-3</version>
+            <version>3.0.0-beta-4</version>
         </dependency>
     </dependencies>
 </project>

+ 4 - 0
src/Makefile.am

@@ -33,6 +33,10 @@ AM_LDFLAGS = $(PTHREAD_CFLAGS)
 # If I say "dist_include_DATA", automake complains that $(includedir) is not
 # a "legitimate" directory for DATA.  Screw you, automake.
 protodir = $(includedir)
+
+# If you are adding new files here, also remember to change the build files for
+# all other languages, //protoc-artifacts/build-zip.sh and run
+# //update_file_list.sh for bazel.
 nobase_dist_proto_DATA = google/protobuf/descriptor.proto     \
                          google/protobuf/any.proto            \
                          google/protobuf/api.proto            \

+ 3 - 3
src/google/protobuf/stubs/int128.cc

@@ -145,15 +145,15 @@ std::ostream& operator<<(std::ostream& o, const uint128& b) {
   std::streamsize div_base_log;
   switch (flags & std::ios::basefield) {
     case std::ios::hex:
-      div = GOOGLE_ULONGLONG(0x1000000000000000);  // 16^15
+      div = static_cast<uint64>(GOOGLE_ULONGLONG(0x1000000000000000));  // 16^15
       div_base_log = 15;
       break;
     case std::ios::oct:
-      div = GOOGLE_ULONGLONG(01000000000000000000000);  // 8^21
+      div = static_cast<uint64>(GOOGLE_ULONGLONG(01000000000000000000000));  // 8^21
       div_base_log = 21;
       break;
     default:  // std::ios::dec
-      div = GOOGLE_ULONGLONG(10000000000000000000);  // 10^19
+      div = static_cast<uint64>(GOOGLE_ULONGLONG(10000000000000000000));  // 10^19
       div_base_log = 19;
       break;
   }

+ 11 - 9
src/google/protobuf/stubs/port.h

@@ -109,15 +109,15 @@ typedef unsigned __int16 uint16;
 typedef unsigned __int32 uint32;
 typedef unsigned __int64 uint64;
 #else
-typedef signed char  int8;
-typedef short int16;
-typedef int int32;
-typedef long long int64;
-
-typedef unsigned char  uint8;
-typedef unsigned short uint16;
-typedef unsigned int uint32;
-typedef unsigned long long uint64;
+typedef int8_t int8;
+typedef int16_t int16;
+typedef int32_t int32;
+typedef int64_t int64;
+
+typedef uint8_t uint8;
+typedef uint16_t uint16;
+typedef uint32_t uint32;
+typedef uint64_t uint64;
 #endif
 
 // long long macros to be used because gcc and vc++ use different suffixes,
@@ -131,8 +131,10 @@ typedef unsigned long long uint64;
 #define GOOGLE_ULONGLONG(x) x##UI64
 #define GOOGLE_LL_FORMAT "I64"  // As in printf("%I64d", ...)
 #else
+// By long long, we actually mean int64.
 #define GOOGLE_LONGLONG(x) x##LL
 #define GOOGLE_ULONGLONG(x) x##ULL
+// Used to format real long long integers.
 #define GOOGLE_LL_FORMAT "ll"  // As in "%lld". Note that "q" is poor form also.
 #endif
 

+ 8 - 1
src/google/protobuf/util/time_util.cc

@@ -142,6 +142,13 @@ int64 RoundTowardZero(int64 value, int64 divider) {
 }
 }  // namespace
 
+// Actually define these static const integers. Required by C++ standard (but
+// omitting them may still work with some compilers).
+const int64 TimeUtil::kTimestampMinSeconds;
+const int64 TimeUtil::kTimestampMaxSeconds;
+const int64 TimeUtil::kDurationMaxSeconds;
+const int64 TimeUtil::kDurationMinSeconds;
+
 string TimeUtil::ToString(const Timestamp& timestamp) {
   return FormatTime(timestamp.seconds(), timestamp.nanos());
 }
@@ -174,7 +181,7 @@ string TimeUtil::ToString(const Duration& duration) {
     seconds = -seconds;
     nanos = -nanos;
   }
-  result += StringPrintf("%" GOOGLE_LL_FORMAT "d", seconds);
+  result += SimpleItoa(seconds);
   if (nanos != 0) {
     result += "." + FormatNanos(nanos);
   }

+ 9 - 0
tests.sh

@@ -195,6 +195,14 @@ build_java_oracle7() {
   use_java oracle7
   build_java oracle7
 }
+build_java_compatibility() {
+  use_java jdk7
+  internal_build_cpp
+  # Use the unit-tests extraced from 2.5.0 to test the compatibilty between
+  # 3.0.0-beta-4 and the current version.
+  cd java/compatibility_tests/v2.5.0
+  ./test.sh 3.0.0-beta-4
+}
 
 build_javanano_jdk7() {
   use_java jdk7
@@ -340,6 +348,7 @@ Usage: $0 { cpp |
             csharp |
             java_jdk7 |
             java_oracle7 |
+            java_compatibility |
             javanano_jdk7 |
             javanano_oracle7 |
             objectivec_ios |