Skip to content

Commit ef69235

Browse files
committed
Merge pull request opencv#8966 from alalek:protobuf_sources
2 parents 09db01a + 1c4c58d commit ef69235

File tree

209 files changed

+127814
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+127814
-0
lines changed

3rdparty/protobuf/CMakeLists.txt

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
project(libprotobuf)
2+
3+
include(CheckIncludeFiles)
4+
5+
if(NOT MSVC)
6+
check_include_files("pthread.h" HAVE_PTHREAD)
7+
if(HAVE_PTHREAD)
8+
add_definitions(-DHAVE_PTHREAD=1)
9+
endif()
10+
endif()
11+
12+
if(MSVC)
13+
add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 )
14+
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146
15+
/wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610
16+
/wd4702 /wd4456 /wd4457 /wd4065 /wd4310 /wd4661 /wd4506
17+
)
18+
else()
19+
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow
20+
-Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo
21+
-Wundef -Wtautological-undefined-compare -Wignored-qualifiers -Wextra
22+
-Wunused-function -Wunused-const-variable -Wshorten-64-to-32
23+
)
24+
endif()
25+
if(CV_ICC)
26+
ocv_warnings_disable(CMAKE_CXX_FLAGS
27+
-wd265 -wd858 -wd873 -wd2196
28+
)
29+
endif()
30+
31+
# Easier to support different versions of protobufs
32+
function(append_if_exist OUTPUT_LIST)
33+
set(${OUTPUT_LIST})
34+
foreach(fil ${ARGN})
35+
if(EXISTS ${fil})
36+
list(APPEND ${OUTPUT_LIST} "${fil}")
37+
else()
38+
message(WARNING "file missing: ${fil}")
39+
endif()
40+
endforeach()
41+
set(${OUTPUT_LIST} ${${OUTPUT_LIST}} PARENT_SCOPE)
42+
endfunction()
43+
44+
set(PROTOBUF_ROOT "${CMAKE_CURRENT_LIST_DIR}")
45+
46+
if(MSVC)
47+
set(ATOMICOPS_INTERNALS ${PROTOBUF_ROOT}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc)
48+
else()
49+
set(ATOMICOPS_INTERNALS ${PROTOBUF_ROOT}/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc)
50+
endif()
51+
52+
53+
append_if_exist(Protobuf_SRCS
54+
# libprotobuf-lite
55+
${PROTOBUF_ROOT}/src/google/protobuf/arena.cc
56+
${PROTOBUF_ROOT}/src/google/protobuf/arenastring.cc
57+
${PROTOBUF_ROOT}/src/google/protobuf/extension_set.cc
58+
${PROTOBUF_ROOT}/src/google/protobuf/generated_message_util.cc
59+
${PROTOBUF_ROOT}/src/google/protobuf/io/coded_stream.cc
60+
${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream.cc
61+
${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
62+
${PROTOBUF_ROOT}/src/google/protobuf/message_lite.cc
63+
${PROTOBUF_ROOT}/src/google/protobuf/repeated_field.cc
64+
${ATOMICOPS_INTERNALS}
65+
${PROTOBUF_ROOT}/src/google/protobuf/stubs/bytestream.cc
66+
${PROTOBUF_ROOT}/src/google/protobuf/stubs/common.cc
67+
${PROTOBUF_ROOT}/src/google/protobuf/stubs/int128.cc
68+
${PROTOBUF_ROOT}/src/google/protobuf/stubs/once.cc
69+
${PROTOBUF_ROOT}/src/google/protobuf/stubs/status.cc
70+
${PROTOBUF_ROOT}/src/google/protobuf/stubs/statusor.cc
71+
${PROTOBUF_ROOT}/src/google/protobuf/stubs/stringpiece.cc
72+
${PROTOBUF_ROOT}/src/google/protobuf/stubs/stringprintf.cc
73+
${PROTOBUF_ROOT}/src/google/protobuf/stubs/structurally_valid.cc
74+
${PROTOBUF_ROOT}/src/google/protobuf/stubs/strutil.cc
75+
${PROTOBUF_ROOT}/src/google/protobuf/stubs/time.cc
76+
${PROTOBUF_ROOT}/src/google/protobuf/wire_format_lite.cc
77+
# libprotobuf
78+
${PROTOBUF_ROOT}/src/google/protobuf/any.cc
79+
${PROTOBUF_ROOT}/src/google/protobuf/any.pb.cc
80+
${PROTOBUF_ROOT}/src/google/protobuf/api.pb.cc
81+
# ${PROTOBUF_ROOT}/src/google/protobuf/compiler/importer.cc
82+
# ${PROTOBUF_ROOT}/src/google/protobuf/compiler/parser.cc
83+
${PROTOBUF_ROOT}/src/google/protobuf/descriptor.cc
84+
${PROTOBUF_ROOT}/src/google/protobuf/descriptor.pb.cc
85+
${PROTOBUF_ROOT}/src/google/protobuf/descriptor_database.cc
86+
${PROTOBUF_ROOT}/src/google/protobuf/duration.pb.cc
87+
${PROTOBUF_ROOT}/src/google/protobuf/dynamic_message.cc
88+
${PROTOBUF_ROOT}/src/google/protobuf/empty.pb.cc
89+
${PROTOBUF_ROOT}/src/google/protobuf/extension_set_heavy.cc
90+
${PROTOBUF_ROOT}/src/google/protobuf/field_mask.pb.cc
91+
${PROTOBUF_ROOT}/src/google/protobuf/generated_message_reflection.cc
92+
${PROTOBUF_ROOT}/src/google/protobuf/io/gzip_stream.cc
93+
${PROTOBUF_ROOT}/src/google/protobuf/io/printer.cc
94+
${PROTOBUF_ROOT}/src/google/protobuf/io/strtod.cc
95+
${PROTOBUF_ROOT}/src/google/protobuf/io/tokenizer.cc
96+
${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream_impl.cc
97+
${PROTOBUF_ROOT}/src/google/protobuf/map_field.cc
98+
${PROTOBUF_ROOT}/src/google/protobuf/message.cc
99+
${PROTOBUF_ROOT}/src/google/protobuf/reflection_ops.cc
100+
${PROTOBUF_ROOT}/src/google/protobuf/service.cc
101+
${PROTOBUF_ROOT}/src/google/protobuf/source_context.pb.cc
102+
${PROTOBUF_ROOT}/src/google/protobuf/struct.pb.cc
103+
${PROTOBUF_ROOT}/src/google/protobuf/stubs/mathlimits.cc
104+
${PROTOBUF_ROOT}/src/google/protobuf/stubs/substitute.cc
105+
${PROTOBUF_ROOT}/src/google/protobuf/text_format.cc
106+
${PROTOBUF_ROOT}/src/google/protobuf/timestamp.pb.cc
107+
${PROTOBUF_ROOT}/src/google/protobuf/type.pb.cc
108+
${PROTOBUF_ROOT}/src/google/protobuf/unknown_field_set.cc
109+
${PROTOBUF_ROOT}/src/google/protobuf/util/field_comparator.cc
110+
${PROTOBUF_ROOT}/src/google/protobuf/util/field_mask_util.cc
111+
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/datapiece.cc
112+
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/default_value_objectwriter.cc
113+
# ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/error_listener.cc
114+
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/field_mask_utility.cc
115+
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/json_escaping.cc
116+
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/json_objectwriter.cc
117+
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/json_stream_parser.cc
118+
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/object_writer.cc
119+
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/proto_writer.cc
120+
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/protostream_objectsource.cc
121+
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/protostream_objectwriter.cc
122+
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/type_info.cc
123+
# ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/type_info_test_helper.cc
124+
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/utility.cc
125+
${PROTOBUF_ROOT}/src/google/protobuf/util/json_util.cc
126+
${PROTOBUF_ROOT}/src/google/protobuf/util/message_differencer.cc
127+
${PROTOBUF_ROOT}/src/google/protobuf/util/time_util.cc
128+
${PROTOBUF_ROOT}/src/google/protobuf/util/type_resolver_util.cc
129+
${PROTOBUF_ROOT}/src/google/protobuf/wire_format.cc
130+
${PROTOBUF_ROOT}/src/google/protobuf/wrappers.pb.cc
131+
)
132+
133+
if(CMAKE_VERSION VERSION_LESS 2.8.9 AND UNIX)
134+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
135+
endif()
136+
137+
add_library(libprotobuf STATIC ${Protobuf_SRCS})
138+
ocv_include_directories(${PROTOBUF_ROOT}/src)
139+
140+
set_target_properties(libprotobuf
141+
PROPERTIES
142+
FOLDER "3rdparty"
143+
POSITION_INDEPENDENT_CODE 1 # CMake 2.8.9+
144+
OUTPUT_NAME libprotobuf
145+
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
146+
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
147+
)
148+
149+
if(NOT BUILD_SHARED_LIBS)
150+
ocv_install_target(libprotobuf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
151+
endif()

3rdparty/protobuf/LICENSE

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
This license applies to all parts of Protocol Buffers except the following:
2+
3+
- Atomicops support for generic gcc, located in
4+
src/google/protobuf/stubs/atomicops_internals_generic_gcc.h.
5+
This file is copyrighted by Red Hat Inc.
6+
7+
- Atomicops support for AIX/POWER, located in
8+
src/google/protobuf/stubs/atomicops_internals_power.h.
9+
This file is copyrighted by Bloomberg Finance LP.
10+
11+
Copyright 2014, Google Inc. All rights reserved.
12+
13+
Redistribution and use in source and binary forms, with or without
14+
modification, are permitted provided that the following conditions are
15+
met:
16+
17+
* Redistributions of source code must retain the above copyright
18+
notice, this list of conditions and the following disclaimer.
19+
* Redistributions in binary form must reproduce the above
20+
copyright notice, this list of conditions and the following disclaimer
21+
in the documentation and/or other materials provided with the
22+
distribution.
23+
* Neither the name of Google Inc. nor the names of its
24+
contributors may be used to endorse or promote products derived from
25+
this software without specific prior written permission.
26+
27+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38+
39+
Code generated by the Protocol Buffer compiler is owned by the owner
40+
of the input file used when generating it. This code is not
41+
standalone and requires a support library to be linked with it. This
42+
support library is itself covered by the above license.

3rdparty/protobuf/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Project: Protocol Buffers - Google's data interchange format
2+
Source code: https://github.com/google/protobuf
3+
Version: 3.1.0
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// Protocol Buffers - Google's data interchange format
2+
// Copyright 2008 Google Inc. All rights reserved.
3+
// https://developers.google.com/protocol-buffers/
4+
//
5+
// Redistribution and use in source and binary forms, with or without
6+
// modification, are permitted provided that the following conditions are
7+
// met:
8+
//
9+
// * Redistributions of source code must retain the above copyright
10+
// notice, this list of conditions and the following disclaimer.
11+
// * Redistributions in binary form must reproduce the above
12+
// copyright notice, this list of conditions and the following disclaimer
13+
// in the documentation and/or other materials provided with the
14+
// distribution.
15+
// * Neither the name of Google Inc. nor the names of its
16+
// contributors may be used to endorse or promote products derived from
17+
// this software without specific prior written permission.
18+
//
19+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
#include <google/protobuf/any.h>
32+
33+
namespace google {
34+
namespace protobuf {
35+
namespace internal {
36+
37+
namespace {
38+
string GetTypeUrl(const Descriptor* message,
39+
const string& type_url_prefix) {
40+
if (!type_url_prefix.empty() &&
41+
type_url_prefix[type_url_prefix.size() - 1] == '/') {
42+
return type_url_prefix + message->full_name();
43+
} else {
44+
return type_url_prefix + "/" + message->full_name();
45+
}
46+
}
47+
} // namespace
48+
49+
const char kAnyFullTypeName[] = "google.protobuf.Any";
50+
const char kTypeGoogleApisComPrefix[] = "type.googleapis.com/";
51+
const char kTypeGoogleProdComPrefix[] = "type.googleprod.com/";
52+
53+
AnyMetadata::AnyMetadata(UrlType* type_url, ValueType* value)
54+
: type_url_(type_url), value_(value) {
55+
}
56+
57+
void AnyMetadata::PackFrom(const Message& message) {
58+
PackFrom(message, kTypeGoogleApisComPrefix);
59+
}
60+
61+
void AnyMetadata::PackFrom(const Message& message,
62+
const string& type_url_prefix) {
63+
type_url_->SetNoArena(&::google::protobuf::internal::GetEmptyString(),
64+
GetTypeUrl(message.GetDescriptor(), type_url_prefix));
65+
message.SerializeToString(value_->MutableNoArena(
66+
&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
67+
}
68+
69+
bool AnyMetadata::UnpackTo(Message* message) const {
70+
if (!InternalIs(message->GetDescriptor())) {
71+
return false;
72+
}
73+
return message->ParseFromString(
74+
value_->GetNoArena(&::google::protobuf::internal::GetEmptyString()));
75+
}
76+
77+
bool AnyMetadata::InternalIs(const Descriptor* descriptor) const {
78+
const string type_url = type_url_->GetNoArena(
79+
&::google::protobuf::internal::GetEmptyString());
80+
string full_name;
81+
if (!ParseAnyTypeUrl(type_url, &full_name)) {
82+
return false;
83+
}
84+
return full_name == descriptor->full_name();
85+
}
86+
87+
bool ParseAnyTypeUrl(const string& type_url, string* full_type_name) {
88+
size_t pos = type_url.find_last_of("/");
89+
if (pos == string::npos || pos + 1 == type_url.size()) {
90+
return false;
91+
}
92+
*full_type_name = type_url.substr(pos + 1);
93+
return true;
94+
}
95+
96+
97+
bool GetAnyFieldDescriptors(const Message& message,
98+
const FieldDescriptor** type_url_field,
99+
const FieldDescriptor** value_field) {
100+
const Descriptor* descriptor = message.GetDescriptor();
101+
if (descriptor->full_name() != kAnyFullTypeName) {
102+
return false;
103+
}
104+
*type_url_field = descriptor->FindFieldByNumber(1);
105+
*value_field = descriptor->FindFieldByNumber(2);
106+
return (*type_url_field != NULL &&
107+
(*type_url_field)->type() == FieldDescriptor::TYPE_STRING &&
108+
*value_field != NULL &&
109+
(*value_field)->type() == FieldDescriptor::TYPE_BYTES);
110+
}
111+
112+
} // namespace internal
113+
} // namespace protobuf
114+
} // namespace google

0 commit comments

Comments
 (0)