From d846b0b059b4d867536b98aa29475a387aa09114 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Mon, 8 Jun 2015 16:24:57 -0400 Subject: Beta quality drop of Objective C Support. - Add more to the ObjC dir readme. - Merge the ExtensionField and ExtensionDescriptor to reduce overhead. - Fix an initialization race. - Clean up the Xcode schemes. - Remove the class/enum filter. - Remove some forced inline that were bloating things without proof of performance wins. - Rename some internal types to avoid conflicts with the well know types protos. - Drop the use of ApplyFunctions to the compiler/optimizer can do what it wants. - Better document some possible future improvements. - Add missing support for parsing repeated primitive fields in packed or unpacked forms. - Improve -hash. - Add *Count for repeated and map<> fields to avoid auto create when checking for them being set. --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Makefile.am') diff --git a/src/Makefile.am b/src/Makefile.am index 33894dc1..6affcbf4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -147,7 +147,7 @@ nobase_include_HEADERS = \ google/protobuf/compiler/java/java_names.h \ google/protobuf/compiler/javanano/javanano_generator.h \ google/protobuf/compiler/objectivec/objectivec_generator.h \ - google/protobuf/compiler/objectivec/objectivec_helpers.h \ + google/protobuf/compiler/objectivec/objectivec_helpers.h \ google/protobuf/compiler/python/python_generator.h \ google/protobuf/compiler/ruby/ruby_generator.h \ google/protobuf/compiler/csharp/csharp_generator.h -- cgit v1.2.3 From 2fe6d7bc5773b6888d0db80eca75e392b3549814 Mon Sep 17 00:00:00 2001 From: Qartar Date: Sun, 7 Jun 2015 14:22:51 -0700 Subject: Workaround for MSVC's string literal compiler limit. Escape characters don't count for string literal size, no need to pre-generate escape string. Added unit test to touch enormous cpp generated descriptor. Updated makefile to include enormous_descriptor.proto Fixed language compatibility error. --- cmake/tests.cmake | 1 + src/Makefile.am | 6 ++- src/google/protobuf/compiler/cpp/cpp_file.cc | 58 ++++++++++++++++++------ src/google/protobuf/compiler/cpp/cpp_unittest.cc | 12 +++++ 4 files changed, 62 insertions(+), 15 deletions(-) (limited to 'src/Makefile.am') diff --git a/cmake/tests.cmake b/cmake/tests.cmake index 24891521..8fb5eef1 100644 --- a/cmake/tests.cmake +++ b/cmake/tests.cmake @@ -25,6 +25,7 @@ set(tests_protos google/protobuf/unittest_drop_unknown_fields.proto google/protobuf/unittest_embed_optimize_for.proto google/protobuf/unittest_empty.proto + google/protobuf/unittest_enormous_descriptor.proto google/protobuf/unittest_import.proto google/protobuf/unittest_import_public.proto google/protobuf/unittest_lite_imports_nonlite.proto diff --git a/src/Makefile.am b/src/Makefile.am index 33894dc1..b8946bac 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -412,6 +412,7 @@ protoc_inputs = \ google/protobuf/unittest_drop_unknown_fields.proto \ google/protobuf/unittest_embed_optimize_for.proto \ google/protobuf/unittest_empty.proto \ + google/protobuf/unittest_enormous_descriptor.proto \ google/protobuf/unittest_import_lite.proto \ google/protobuf/unittest_import.proto \ google/protobuf/unittest_import_public_lite.proto \ @@ -453,8 +454,7 @@ EXTRA_DIST = \ google/protobuf/compiler/ruby/ruby_generated_code.proto \ google/protobuf/compiler/ruby/ruby_generated_code.rb \ google/protobuf/compiler/package_info.h \ - google/protobuf/compiler/zip_output_unittest.sh \ - google/protobuf/unittest_enormous_descriptor.proto + google/protobuf/compiler/zip_output_unittest.sh protoc_lite_outputs = \ google/protobuf/map_lite_unittest.pb.cc \ @@ -486,6 +486,8 @@ protoc_outputs = \ google/protobuf/unittest_embed_optimize_for.pb.h \ google/protobuf/unittest_empty.pb.cc \ google/protobuf/unittest_empty.pb.h \ + google/protobuf/unittest_enormous_descriptor.pb.cc \ + google/protobuf/unittest_enormous_descriptor.pb.h \ google/protobuf/unittest_import.pb.cc \ google/protobuf/unittest_import.pb.h \ google/protobuf/unittest_import_public.pb.cc \ diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index b997a51a..1f0a8205 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -434,20 +434,52 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { string file_data; file_proto.SerializeToString(&file_data); - printer->Print( - "::google::protobuf::DescriptorPool::InternalAddGeneratedFile("); - - // Only write 40 bytes per line. - static const int kBytesPerLine = 40; - for (int i = 0; i < file_data.size(); i += kBytesPerLine) { - printer->Print("\n \"$data$\"", - "data", - EscapeTrigraphs( - CEscape(file_data.substr(i, kBytesPerLine)))); + // Workaround for MSVC: "Error C1091: compiler limit: string exceeds 65535 + // bytes in length". Declare a static array of characters rather than use a + // string literal. + if (file_data.size() > 65535) { + printer->Print( + "static const char descriptor[] = {\n"); + printer->Indent(); + + // Only write 25 bytes per line. + static const int kBytesPerLine = 25; + for (int i = 0; i < file_data.size();) { + for (int j = 0; j < kBytesPerLine && i < file_data.size(); ++i, ++j) { + printer->Print( + "$char$, ", + "char", SimpleItoa(file_data[i])); + } + printer->Print( + "\n"); + } + + printer->Outdent(); + printer->Print( + "};\n"); + + printer->Print( + "::google::protobuf::DescriptorPool::InternalAddGeneratedFile(descriptor, $size$);\n", + "size", SimpleItoa(file_data.size())); + + } else { + + printer->Print( + "::google::protobuf::DescriptorPool::InternalAddGeneratedFile("); + + // Only write 40 bytes per line. + static const int kBytesPerLine = 40; + for (int i = 0; i < file_data.size(); i += kBytesPerLine) { + printer->Print("\n \"$data$\"", + "data", + EscapeTrigraphs( + CEscape(file_data.substr(i, kBytesPerLine)))); + } + printer->Print( + ", $size$);\n", + "size", SimpleItoa(file_data.size())); + } - printer->Print( - ", $size$);\n", - "size", SimpleItoa(file_data.size())); // Call MessageFactory::InternalRegisterGeneratedFile(). printer->Print( diff --git a/src/google/protobuf/compiler/cpp/cpp_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_unittest.cc index b11fb21a..bd1c0fde 100644 --- a/src/google/protobuf/compiler/cpp/cpp_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_unittest.cc @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -130,6 +131,17 @@ TEST(GeneratedDescriptorTest, IdenticalDescriptors) { generated_decsriptor_proto.DebugString()); } +// Test that generated code has proper descriptors: +// Touch a descriptor generated from an enormous message to validate special +// handling for descriptors exceeding the C++ standard's recommended minimum +// limit for string literal size +TEST(GeneratedDescriptorTest, EnormousDescriptor) { + const Descriptor* generated_descriptor = + TestEnormousDescriptor::descriptor(); + + EXPECT_TRUE(generated_descriptor != NULL); +} + #endif // !PROTOBUF_TEST_NO_DESCRIPTORS // =================================================================== -- cgit v1.2.3 From f48dca504443c17c2bf86104754c405b503073cc Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Fri, 12 Jun 2015 15:49:21 -0700 Subject: Make pbconfig.h independent of config.h Change-Id: I31ead985b4ac5b02fb7558d34c1da19fd837b50a --- .gitignore | 1 - src/Makefile.am | 21 +----- src/google/protobuf/stubs/pbconfig.h | 142 +++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 19 deletions(-) create mode 100644 src/google/protobuf/stubs/pbconfig.h (limited to 'src/Makefile.am') diff --git a/.gitignore b/.gitignore index 8ea85af0..52c92dfb 100644 --- a/.gitignore +++ b/.gitignore @@ -27,7 +27,6 @@ src/Makefile /config.h config.log config.status -pbconfig.h libtool protobuf-lite.pc diff --git a/src/Makefile.am b/src/Makefile.am index 6affcbf4..c3e22327 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,24 +41,12 @@ nobase_dist_proto_DATA = google/protobuf/descriptor.proto \ clean-local: rm -f *.loT -public_config = google/protobuf/stubs/pbconfig.h - -CLEANFILES = $(protoc_outputs) $(public_config) unittest_proto_middleman \ +CLEANFILES = $(protoc_outputs) unittest_proto_middleman \ testzip.jar testzip.list testzip.proto testzip.zip MAINTAINERCLEANFILES = \ Makefile.in -# Generate and distribute a minimum config.h file to make hash_map work. -# The autoheader config has too much info, which might conflict with other -# macros applications might include. Thus, we create a stubs/pbconfig.h, that -# only #defines what we really need, and prefix it with GOOGLE_PROTOBUF_ to -# avoid conflicts. -$(public_config): $(top_builddir)/config.h $(top_srcdir)/config.h.include - echo "// Note: Google Protobuf internal only. Do NOT include." > $@ - cat $(top_builddir)/config.h | grep -f $(top_srcdir)/config.h.include | \ - sed 's,#define , #define GOOGLE_PROTOBUF_,' >> $@ - nobase_include_HEADERS = \ google/protobuf/stubs/atomic_sequence_num.h \ google/protobuf/stubs/atomicops.h \ @@ -80,6 +68,7 @@ nobase_include_HEADERS = \ google/protobuf/stubs/fastmem.h \ google/protobuf/stubs/hash.h \ google/protobuf/stubs/once.h \ + google/protobuf/stubs/pbconfig.h \ google/protobuf/stubs/platform_macros.h \ google/protobuf/stubs/shared_ptr.h \ google/protobuf/stubs/singleton.h \ @@ -152,9 +141,6 @@ nobase_include_HEADERS = \ google/protobuf/compiler/ruby/ruby_generator.h \ google/protobuf/compiler/csharp/csharp_generator.h -nobase_nodist_include_HEADERS = \ - $(public_config) - lib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la libprotobuf_lite_la_LIBADD = $(PTHREAD_LIBS) @@ -180,7 +166,6 @@ libprotobuf_lite_la_SOURCES = \ google/protobuf/io/coded_stream_inl.h \ google/protobuf/io/zero_copy_stream.cc \ google/protobuf/io/zero_copy_stream_impl_lite.cc -nodist_libprotobuf_lite_la_SOURCES = $(public_config) libprotobuf_la_LIBADD = $(PTHREAD_LIBS) libprotobuf_la_LDFLAGS = -version-info 10:0:0 -export-dynamic -no-undefined @@ -517,7 +502,7 @@ protoc_outputs = \ google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc \ google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.h -BUILT_SOURCES = $(public_config) $(protoc_outputs) +BUILT_SOURCES = $(protoc_outputs) if USE_EXTERNAL_PROTOC diff --git a/src/google/protobuf/stubs/pbconfig.h b/src/google/protobuf/stubs/pbconfig.h new file mode 100644 index 00000000..0f21c560 --- /dev/null +++ b/src/google/protobuf/stubs/pbconfig.h @@ -0,0 +1,142 @@ +// 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. + +#ifndef GOOGLE_PROTOBUF_STUBS_PBCONFIG_H__ +#define GOOGLE_PROTOBUF_STUBS_PBCONFIG_H__ + +#define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1 +#define GOOGLE_PROTOBUF_HAVE_HASH_SET 1 + +// Use C++11 unordered_{map|set} if available. +#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X) +# define GOOGLE_PROTOBUF_HAS_CXX11_HASH + +// For XCode >= 4.6: the compiler is clang with libc++. +// For earlier XCode version: the compiler is gcc-4.2.1 with libstdc++. +// libc++ provides and friends even in non C++11 mode, +// and it does not provide the tr1 library. Therefore the following macro +// checks against this special case. +// Note that we should not test the __APPLE_CC__ version number or the +// __clang__ macro, since the new compiler can still use -stdlib=libstdc++, in +// which case is not compilable without -std=c++11 +#elif defined(__APPLE_CC__) +# if defined(_LIBCPP_VERSION) +# define GOOGLE_PROTOBUF_HAS_CXX11_HASH +# elif __GNUC__ >= 4 +# define GOOGLE_PROTOBUF_HAS_TR1 +# else +// Not tested for gcc < 4... These setting can compile under 4.2.1 though. +# define GOOGLE_PROTOBUF_HASH_NAMESPACE __gnu_cxx +# define GOOGLE_PROTOBUF_HASH_MAP_H +# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map +# define GOOGLE_PROTOBUF_HASH_SET_H +# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set +# endif + +// Version checks for gcc. +#elif defined(__GNUC__) +// For GCC 4.x+, use tr1::unordered_map/set; otherwise, follow the +// instructions from: +// https://gcc.gnu.org/onlinedocs/libstdc++/manual/backwards.html +# if __GNUC__ >= 4 +# define GOOGLE_PROTOBUF_HAS_TR1 +# elif __GNUC__ >= 3 +# define GOOGLE_PROTOBUF_HASH_MAP_H +# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map +# define GOOGLE_PROTOBUF_HASH_SET_H +# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set +# if __GNUC__ == 3 && __GNUC_MINOR__ == 0 +# define GOOGLE_PROTOBUF_HASH_NAMESPACE std // GCC 3.0 +# else +# define GOOGLE_PROTOBUF_HASH_NAMESPACE __gnu_cxx // GCC 3.1 and later +# endif +# else +# define GOOGLE_PROTOBUF_HASH_NAMESPACE +# define GOOGLE_PROTOBUF_HASH_MAP_H +# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map +# define GOOGLE_PROTOBUF_HASH_SET_H +# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set +# endif + +// Version checks for MSC. +// Apparently Microsoft decided to move hash_map *back* to the std namespace in +// MSVC 2010: +// http://blogs.msdn.com/vcblog/archive/2009/05/25/stl-breaking-changes-in-visual-studio-2010-beta-1.aspx +// And.. they are moved back to stdext in MSVC 2013 (haven't checked 2012). That +// said, use unordered_map for MSVC 2010 and beyond is our safest bet. +#elif defined(_MSC_VER) +# if _MSC_VER >= 1600 // Since Visual Studio 2010 +# define GOOGLE_PROTOBUF_HAS_CXX11_HASH +# define GOOGLE_PROTOBUF_HASH_COMPARE std::hash_compare +# elif _MSC_VER >= 1500 // Since Visual Studio 2008 +# define GOOGLE_PROTOBUF_HAS_TR1 +# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare +# elif _MSC_VER >= 1310 +# define GOOGLE_PROTOBUF_HASH_NAMESPACE stdext +# define GOOGLE_PROTOBUF_HASH_MAP_H +# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map +# define GOOGLE_PROTOBUF_HASH_SET_H +# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set +# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare +# else +# define GOOGLE_PROTOBUF_HASH_NAMESPACE std +# define GOOGLE_PROTOBUF_HASH_MAP_H +# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map +# define GOOGLE_PROTOBUF_HASH_SET_H +# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set +# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare +# endif + +// **ADD NEW COMPILERS SUPPORT HERE.** +// For other compilers, undefine the macro and fallback to use std::map, in +// google/protobuf/stubs/hash.h +#else +# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP +# undef GOOGLE_PROTOBUF_HAVE_HASH_SET +#endif + +#if defined(GOOGLE_PROTOBUF_HAS_CXX11_HASH) +# define GOOGLE_PROTOBUF_HASH_NAMESPACE std +# define GOOGLE_PROTOBUF_HASH_MAP_H +# define GOOGLE_PROTOBUF_HASH_MAP_CLASS unordered_map +# define GOOGLE_PROTOBUF_HASH_SET_H +# define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set +#elif defined(GOOGLE_PROTOBUF_HAS_TR1) +# define GOOGLE_PROTOBUF_HASH_NAMESPACE std::tr1 +# define GOOGLE_PROTOBUF_HASH_MAP_H +# define GOOGLE_PROTOBUF_HASH_MAP_CLASS unordered_map +# define GOOGLE_PROTOBUF_HASH_SET_H +# define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set +#endif + +#undef GOOGLE_PROTOBUF_HAS_CXX11_HASH +#undef GOOGLE_PROTOBUF_HAS_TR1 + +#endif // GOOGLE_PROTOBUF_STUBS_PBCONFIG_H__ -- cgit v1.2.3 From 78d470c7a50d3788bf3f819eba99597aea43674f Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Fri, 12 Jun 2015 15:49:21 -0700 Subject: Make the code independent of config.h Now the Build tool needs to define -DHAVE_ZLIB and -DHAVE-PTHREAD rather than providing a config.h - Make pbconfig.h a manually written file to handle hash conditions according to platform related macros. - Remove #include "config.h" from source code. - Changed the configure.ac and Makefile.am to pass down the macros. - Change cmake to pass down the the macros. Change-Id: I537249d5df8fdeba189706aec436d1ab1104a4dc --- Makefile.am | 3 - cmake/CMakeLists.txt | 14 +-- cmake/config.h.in | 4 - cmake/find_hash_map.cmake | 119 --------------------- cmake/pbconfig.h.in | 9 -- configure.ac | 6 ++ src/Makefile.am | 12 ++- src/google/protobuf/io/gzip_stream.cc | 2 - .../protobuf/io/zero_copy_stream_unittest.cc | 2 - src/google/protobuf/stubs/common.cc | 2 - src/google/protobuf/stubs/common_unittest.cc | 2 - src/google/protobuf/testing/zcgunzip.cc | 2 - src/google/protobuf/testing/zcgzip.cc | 2 - 13 files changed, 23 insertions(+), 156 deletions(-) delete mode 100644 cmake/config.h.in delete mode 100644 cmake/find_hash_map.cmake delete mode 100644 cmake/pbconfig.h.in (limited to 'src/Makefile.am') diff --git a/Makefile.am b/Makefile.am index 0eb80202..8d7bb563 100644 --- a/Makefile.am +++ b/Makefile.am @@ -744,12 +744,9 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \ CONTRIBUTORS.txt \ CHANGES.txt \ cmake/CMakeLists.txt \ - cmake/config.h.in \ - cmake/find_hash_map.cmake \ cmake/libprotobuf.cmake \ cmake/libprotobuf-lite.cmake \ cmake/libprotoc.cmake \ - cmake/pbconfig.h.in \ cmake/protoc.cmake \ cmake/README.md \ cmake/tests.cmake \ diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 727864ba..d36292df 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -8,11 +8,11 @@ if (MSVC) option(ZLIB "Build with zlib support" OFF) endif (MSVC) +add_definitions(-DGOOGLE_PROTOBUF_CMAKE_BUILD) + find_package(Threads REQUIRED) if (CMAKE_USE_PTHREADS_INIT) - set(HAVE_PTHREAD 1) -else (CMAKE_USE_PTHREADS_INIT) - set(HAVE_PTHREAD 0) + add_definitions(-DHAVE_PTHREAD) endif (CMAKE_USE_PTHREADS_INIT) if (MSVC) @@ -36,6 +36,10 @@ else (MSVC) endif (ZLIB_FOUND) endif (MSVC) +if (HAVE_ZLIB) + add_definitions(-DHAVE_ZLIB) +endif (HAVE_ZLIB) + if (MSVC) if (BUILD_SHARED_LIBS) add_definitions(-DPROTOBUF_USE_DLLS) @@ -43,10 +47,6 @@ if (MSVC) add_definitions(/wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305) endif (MSVC) -include(find_hash_map.cmake) - -configure_file(config.h.in config.h) -configure_file(pbconfig.h.in google/protobuf/stubs/pbconfig.h) if (MSVC) string(REPLACE "/" "\\" PROTOBUF_SOURCE_WIN32_PATH ${protobuf_SOURCE_DIR}) string(REPLACE "/" "\\" PROTOBUF_BINARY_WIN32_PATH ${protobuf_BINARY_DIR}) diff --git a/cmake/config.h.in b/cmake/config.h.in deleted file mode 100644 index bca1cbba..00000000 --- a/cmake/config.h.in +++ /dev/null @@ -1,4 +0,0 @@ -#define GOOGLE_PROTOBUF_CMAKE_BUILD - -#define HAVE_PTHREAD ${HAVE_PTHREAD} -#define HAVE_ZLIB ${HAVE_ZLIB} diff --git a/cmake/find_hash_map.cmake b/cmake/find_hash_map.cmake deleted file mode 100644 index 22796fb8..00000000 --- a/cmake/find_hash_map.cmake +++ /dev/null @@ -1,119 +0,0 @@ -include(CheckCXXSourceCompiles) - -function(find_hash_map) - set(HAVE_HASH_MAP 1 PARENT_SCOPE) - set(HAVE_HASH_SET 1 PARENT_SCOPE) - # Search for hash_map in the following order: - # 1. ::std::unordered_map - # 2. ::std::tr1::unordered_map - # 3. ::hash_map - # 4. ::stdext::hash_map - # 5. ::std::hash_map - # 6. ::__gnu_cxx::hash_map - check_cxx_source_compiles(" - #include - int main() { ::std::unordered_map v; return v[0]; } - " HAS_STD_UNORDERED_MAP) - if (HAS_STD_UNORDERED_MAP) - set(HASH_NAMESPACE ::std PARENT_SCOPE) - set(HASH_MAP_H PARENT_SCOPE) - set(HASH_MAP_CLASS unordered_map PARENT_SCOPE) - set(HASH_SET_H PARENT_SCOPE) - set(HASH_SET_CLASS unordered_set PARENT_SCOPE) - return() - endif (HAS_STD_UNORDERED_MAP) - - check_cxx_source_compiles(" - #include - int main() { ::std::tr1::unordered_map v; return v[0]; } - " HAS_STD_TR1_UNORDERED_MAP) - if (HAS_STD_TR1_UNORDERED_MAP) - set(HASH_NAMESPACE ::std::tr1 PARENT_SCOPE) - set(HASH_MAP_H PARENT_SCOPE) - set(HASH_MAP_CLASS unordered_map PARENT_SCOPE) - set(HASH_SET_H PARENT_SCOPE) - set(HASH_SET_CLASS unordered_set PARENT_SCOPE) - return() - endif (HAS_STD_TR1_UNORDERED_MAP) - - check_cxx_source_compiles(" - #include - int main() { ::hash_map v; return v[0]; } - " HAS_HASH_MAP) - if (HAS_HASH_MAP) - set(HASH_NAMESPACE :: PARENT_SCOPE) - set(HASH_MAP_H PARENT_SCOPE) - set(HASH_MAP_CLASS hash_map PARENT_SCOPE) - set(HASH_SET_H PARENT_SCOPE) - set(HASH_SET_CLASS hash_set PARENT_SCOPE) - return() - endif (HAS_HASH_MAP) - - check_cxx_source_compiles(" - #include - int main() { ::stdext::hash_map v; return v[0]; } - " HAS_STDEXT_HASH_MAP) - if (HAS_STDEXT_HASH_MAP) - set(HASH_NAMESPACE ::stdext PARENT_SCOPE) - set(HASH_MAP_H PARENT_SCOPE) - set(HASH_MAP_CLASS hash_map PARENT_SCOPE) - set(HASH_SET_H PARENT_SCOPE) - set(HASH_SET_CLASS hash_set PARENT_SCOPE) - return() - endif (HAS_STDEXT_HASH_MAP) - - check_cxx_source_compiles(" - #include - int main() { ::std::hash_map v; return v[0]; } - " HAS_STD_HASH_MAP) - if (HAS_STD_HASH_MAP) - set(HASH_NAMESPACE ::std PARENT_SCOPE) - set(HASH_MAP_H PARENT_SCOPE) - set(HASH_MAP_CLASS hash_map PARENT_SCOPE) - set(HASH_SET_H PARENT_SCOPE) - set(HASH_SET_CLASS hash_set PARENT_SCOPE) - return() - endif (HAS_STD_HASH_MAP) - - check_cxx_source_compiles(" - #include - int main() { ::__gnu_cxx::hash_map v; return v[0]; } - " HAS_GNU_CXX_HASH_MAP) - if (HAS_GNU_CXX_HASH_MAP) - set(HASH_NAMESPACE ::gnu_cxx PARENT_SCOPE) - set(HASH_MAP_H PARENT_SCOPE) - set(HASH_MAP_CLASS hash_map PARENT_SCOPE) - set(HASH_SET_H PARENT_SCOPE) - set(HASH_SET_CLASS hash_set PARENT_SCOPE) - return() - endif (HAS_GNU_CXX_HASH_MAP) - - set(HAVE_HASH_MAP 0 PARENT_SCOPE) - set(HAVE_HASH_SET 0 PARENT_SCOPE) -endfunction() - -function(find_hash_compare) - if (MSVC) - check_cxx_source_compiles(" - #include ${HASH_MAP_H} - int main() { ::std::hash_compare cp; return cp(0); } - " HAS_STD_HASH_COMPARE) - if (HAS_STD_HASH_COMPARE) - set(HASH_COMPARE ::std::hash_compare PARENT_SCOPE) - return() - endif (HAS_STD_HASH_COMPARE) - - check_cxx_source_compiles(" - #include ${HASH_MAP_H} - int main() { ::stdext::hash_compare cp; return cp(0); } - " HAS_STDEXT_HASH_COMPARE) - if (HAS_STDEXT_HASH_COMPARE) - set(HASH_COMPARE ::stdext::hash_compare PARENT_SCOPE) - return() - endif (HAS_STDEXT_HASH_COMPARE) - endif (MSVC) - set(HASH_COMPARE PARENT_SCOPE) -endfunction() - -find_hash_map() -find_hash_compare() diff --git a/cmake/pbconfig.h.in b/cmake/pbconfig.h.in deleted file mode 100644 index fdc59686..00000000 --- a/cmake/pbconfig.h.in +++ /dev/null @@ -1,9 +0,0 @@ -#define GOOGLE_PROTOBUF_HAVE_HASH_MAP ${HAVE_HASH_MAP} -#define GOOGLE_PROTOBUF_HAVE_HASH_SET ${HAVE_HASH_MAP} - -#define GOOGLE_PROTOBUF_HASH_NAMESPACE ${HASH_NAMESPACE} -#define GOOGLE_PROTOBUF_HASH_MAP_H ${HASH_MAP_H} -#define GOOGLE_PROTOBUF_HASH_MAP_CLASS ${HASH_MAP_CLASS} -#define GOOGLE_PROTOBUF_HASH_SET_H ${HASH_SET_H} -#define GOOGLE_PROTOBUF_HASH_SET_CLASS ${HASH_SET_CLASS} -#define GOOGLE_PROTOBUF_HASH_COMPARE ${HASH_COMPARE} diff --git a/configure.ac b/configure.ac index 8018cc75..b36fa0c0 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,9 @@ AC_INIT([Protocol Buffers],[3.0.0-alpha-4-pre],[protobuf@googlegroups.com],[prot AM_MAINTAINER_MODE([enable]) AC_CONFIG_SRCDIR(src/google/protobuf/message.cc) +# The config file is generated but not used by the source code, since we only +# need very few of them, e.g. HAVE_PTHREAD and HAVE_ZLIB. Those macros are +# passed down in CXXFLAGS manually in src/Makefile.am AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) @@ -146,6 +149,9 @@ AS_IF([test "$with_protoc" != "no"], [ AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"]) ACX_PTHREAD +AM_CONDITIONAL([HAVE_PTHREAD], [test "x$acx_pthread_ok" = "xyes"]) + +# We still keep this for improving pbconfig.h for unsupported platforms. AC_CXX_STL_HASH case "$target_os" in diff --git a/src/Makefile.am b/src/Makefile.am index ac6ec6f4..67cd4c57 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,17 +4,25 @@ if HAVE_ZLIB GZCHECKPROGRAMS = zcgzip zcgunzip GZHEADERS = google/protobuf/io/gzip_stream.h GZTESTS = google/protobuf/io/gzip_stream_unittest.sh +ZLIB_DEF = -DHAVE_ZLIB=1 else GZCHECKPROGRAMS = GZHEADERS = GZTESTS = +ZLIB_DEF = +endif + +if HAVE_PTHREAD +PTHREAD_DEF = -DHAVE_PTHREAD=1 +else +PTHREAD_DEF = endif if GCC # These are good warnings to turn on by default -NO_OPT_CXXFLAGS = $(PTHREAD_CFLAGS) -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare +NO_OPT_CXXFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_DEF) $(ZLIB_DEF) -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare else -NO_OPT_CXXFLAGS = $(PTHREAD_CFLAGS) +NO_OPT_CXXFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_DEF) $(ZLIB_DEF) endif AM_CXXFLAGS = $(NO_OPT_CXXFLAGS) $(PROTOBUF_OPT_FLAG) diff --git a/src/google/protobuf/io/gzip_stream.cc b/src/google/protobuf/io/gzip_stream.cc index c9f4ca7f..dd7c036e 100644 --- a/src/google/protobuf/io/gzip_stream.cc +++ b/src/google/protobuf/io/gzip_stream.cc @@ -33,8 +33,6 @@ // This file contains the implementation of classes GzipInputStream and // GzipOutputStream. -#include "config.h" - #if HAVE_ZLIB #include diff --git a/src/google/protobuf/io/zero_copy_stream_unittest.cc b/src/google/protobuf/io/zero_copy_stream_unittest.cc index dd3d1285..f2e5b629 100644 --- a/src/google/protobuf/io/zero_copy_stream_unittest.cc +++ b/src/google/protobuf/io/zero_copy_stream_unittest.cc @@ -46,8 +46,6 @@ // "parametized tests" so that one set of tests can be used on all the // implementations. -#include "config.h" - #ifdef _MSC_VER #include #else diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc index 54e00ccb..22cc5aa1 100644 --- a/src/google/protobuf/stubs/common.cc +++ b/src/google/protobuf/stubs/common.cc @@ -36,8 +36,6 @@ #include #include -#include "config.h" - #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN // We only need minimal includes #include diff --git a/src/google/protobuf/stubs/common_unittest.cc b/src/google/protobuf/stubs/common_unittest.cc index 5f458e98..f9e2cfd4 100644 --- a/src/google/protobuf/stubs/common_unittest.cc +++ b/src/google/protobuf/stubs/common_unittest.cc @@ -39,8 +39,6 @@ #include #include -#include "config.h" - namespace google { namespace protobuf { namespace { diff --git a/src/google/protobuf/testing/zcgunzip.cc b/src/google/protobuf/testing/zcgunzip.cc index daf74ff1..c9d085c8 100644 --- a/src/google/protobuf/testing/zcgunzip.cc +++ b/src/google/protobuf/testing/zcgunzip.cc @@ -38,8 +38,6 @@ // Reads gzip stream on standard input and writes decompressed data to standard // output. -#include "config.h" - #include #include #include diff --git a/src/google/protobuf/testing/zcgzip.cc b/src/google/protobuf/testing/zcgzip.cc index a4101999..e910f321 100644 --- a/src/google/protobuf/testing/zcgzip.cc +++ b/src/google/protobuf/testing/zcgzip.cc @@ -38,8 +38,6 @@ // Reads data on standard input and writes compressed gzip stream to standard // output. -#include "config.h" - #include #include #include -- cgit v1.2.3