diff --git a/BUILD.gn b/BUILD.gn index bfce7c5a1acbc0dacf592ea0779fdfdb011097b6..6ec59ca6e3a3e4519ba6beef764412f919182d84 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -250,7 +250,7 @@ ohos_shared_library("protobuf") { "src/google/protobuf/wire_format_lite.cc", "src/google/protobuf/wrappers.pb.cc", "third_party/utf8_range/utf8_validity.cc", - "third_party/utf8_range/utf8_range.c", + "third_party/utf8_range/utf8_range.c" ] include_dirs = [ "src/google/protobuf/**/*.h", @@ -267,6 +267,7 @@ ohos_shared_library("protobuf") { "-D HAVE_PTHREAD", "-Wno-deprecated-declarations", ] + external_deps = [ "abseil-cpp:absl_base_static" ] public_configs = [ ":protobuf_config" ] install_enable = true diff --git a/bundle.json b/bundle.json index 26c1d18a0a985dc2b41547a15e60feec42d431ae..3056a87a22b1b4507ef2289272f8001c5c18bd6e 100644 --- a/bundle.json +++ b/bundle.json @@ -30,27 +30,55 @@ "sub_component": [], "inner_kits": [ { + "header": { + "header_base": "//third_party/protobuf/src/google/protobuf", + "header_files": [] + }, "name": "//third_party/protobuf:protobuf" }, { + "header": { + "header_base": "//third_party/protobuf/src/google/protobuf", + "header_files": [] + }, "name": "//third_party/protobuf:protobuf_lite" }, { + "header": { + "header_base": "//third_party/protobuf/src/google/protobuf", + "header_files": [] + }, "name": "//third_party/protobuf:protobuf_lite_static" }, { + "header": { + "header_base": "//third_party/protobuf/src/google/protobuf", + "header_files": [] + }, "name": "//third_party/protobuf:protobuf_static" }, { + "header": { + "header_base": "//third_party/protobuf/src/google/protobuf", + "header_files": [] + }, "name": "//third_party/protobuf:protobuf" }, { "name": "//third_party/protobuf:protoc" }, { + "header": { + "header_base": "//third_party/protobuf/src/google/protobuf", + "header_files": [] + }, "name": "//third_party/protobuf:protoc_lib" }, { + "header": { + "header_base": "//third_party/protobuf/src/google/protobuf/compiler", + "header_files": [] + }, "name": "//third_party/protobuf:protoc_static_lib" } ], diff --git a/cmake/abseil-cpp.cmake b/cmake/abseil-cpp.cmake index 1b64affa50cafa4081176eb6442d55b5390a9246..2b732599a95f580d00f5b6c6eb12c6889274bd53 100644 --- a/cmake/abseil-cpp.cmake +++ b/cmake/abseil-cpp.cmake @@ -15,7 +15,13 @@ if(TARGET absl::strings) # (https://github.com/protocolbuffers/protobuf/issues/10435) elseif(protobuf_ABSL_PROVIDER STREQUAL "module") if(NOT ABSL_ROOT_DIR) - set(ABSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp) + if (NOT EXISTS "{protobuf_SOURCE_DIR}/../../out/abseil-cpp/CMakeLists.txt") + execute_process(COMMAND ${protobuf_SOURCE_DIR}/../abseil-cpp/install_no_lock.sh ${protobuf_SOURCE_DIR}/../../out/ ${protobuf_SOURCE_DIR}/../abseil-cpp + WORKING_DIRECTORY ${protobuf_SOURCE_DIR}/../abseil-cpp + RESULT_VARIABLE result) + endif() + set(ABSL_ROOT_DIR ${protobuf_SOURCE_DIR}/../../out/abseil-cpp) + set(EXPORT_ABSL_ROOT_DIR "out/abseil-cpp" CACHE PATH "absl_root_dir") endif() if(EXISTS "${ABSL_ROOT_DIR}/CMakeLists.txt") if(protobuf_INSTALL) diff --git a/libprotobuf.map b/libprotobuf.map index e6abeca6777ec4f3b78097878ae7a77f20fbc251..80982e850fd7a0cad7d0cd2812506056d64e1b78 100644 --- a/libprotobuf.map +++ b/libprotobuf.map @@ -268,6 +268,11 @@ "google::protobuf::FileDescriptorProto::InternalSwap(google::protobuf::FileDescriptorProto*)"; "google::protobuf::Arena::Allocate(unsigned long)"; "google::protobuf::_GeneratedCodeInfo_default_instance_"; + "google::protobuf::GeneratedCodeInfo::MergeFrom(google::protobuf::GeneratedCodeInfo const&)"; + "scc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto"; + "google::protobuf::internal::ArenaStringPtr::Destroy(google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)"; + "google::protobuf::internal::kGlobalEmptyTable"; + "google::protobuf::internal::ArenaStringPtr::Set(std::__h::basic_string, std::__h::allocator> const*, std::__h::basic_string, std::__h::allocator> const&, google::protobuf::Arena*)"; "google::protobuf::io::Printer::PrintImpl(std::basic_string_view>, absl::lts_20230802::Span, std::allocator> const>, google::protobuf::io::Printer::PrintOptions)"; "google::protobuf::io::StringOutputStream::Next(void**, int*)"; "google::protobuf::io::StringOutputStream::BackUp(int)"; @@ -402,12 +407,24 @@ "google::protobuf::Message::MaybeComputeUnknownFieldsSize(unsigned int, google::protobuf::internal::CachedSize*) const"; "google::protobuf::internal::TcParser::GenericFallback(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long long)"; "google::protobuf::internal::TcParser::FastV32P2(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long long)"; + "absl::lts_20230802::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::__h::basic_string_view>)"; + "absl::lts_20230802::log_internal::LogMessageFatal::~LogMessageFatal()"; + "absl::lts_20230802::Mutex::~Mutex()"; + "absl::lts_20230802::Cord::Append(absl::lts_20230802::Cord&&)"; + "absl::lts_20230802::Cord::DestroyCordSlow()"; + "absl::lts_20230802::cord_internal::InitializeCordRepExternal(std::__h::basic_string_view>, absl::lts_20230802::cord_internal::CordRepExternal*)"; + "absl::lts_20230802::cord_internal::cordz_should_profile_slow()"; + "absl::lts_20230802::cord_internal::CordzInfo::TrackCord(absl::lts_20230802::cord_internal::InlineData&, absl::lts_20230802::cord_internal::CordzUpdateTracker::MethodIdentifier)"; + "absl::lts_20230802::Cord::Subcord(unsigned int, unsigned int) const"; + "absl::lts_20230802::Mutex::Lock()"; + "absl::lts_20230802::Mutex::Unlock()"; "__emutls_v._ZN6google8protobuf8internal15ThreadSafeArena13thread_cache_E"; "google::protobuf::internal::TcParser::FastEr0S1(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long long)"; "google::protobuf::internal::TcParser::FastSS1(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long long)"; "google::protobuf::internal::TcParser::FastSR1(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long long)"; "__emutls_v._ZN4absl12lts_2023080213cord_internal17cordz_next_sampleE"; "google::protobuf::TextFormat::ParseFromString(std::__h::basic_string_view>, google::protobuf::Message*)"; + "void absl::lts_20230802::log_internal::LogMessage::CopyToEncodedBuffer<(absl::lts_20230802::log_internal::LogMessage::StringType)0>(std::__h::basic_string_view>)"; "google::protobuf::internal::protobuf_assumption_failed(char const*, char const*, int)"; "google::protobuf::internal::TcParser::GenericFallbackLite(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)"; "google::protobuf::internal::TcParser::FastBS1(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)"; @@ -430,6 +447,7 @@ "google::protobuf::internal::TcParser::FastUR1(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)"; "std::__h::basic_string, std::__h::allocator>* absl::lts_20230802::log_internal::MakeCheckOpString(long, long, char const*)"; "google::protobuf::internal::TcParser::FastV32P1(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)"; + "absl::lts_20230802::Cord::Subcord(unsigned long, unsigned long) const"; "google::protobuf::internal::TcParser::FastV32P2(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)"; "google::protobuf::internal::TcParser::FastV32P1(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)"; "google::protobuf::internal::TcParser::FastUS2(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)"; diff --git a/src/file_lists.cmake b/src/file_lists.cmake index 104a296d1110503de102832a275281ff846f4f59..9e7b689a9c9712e04c0950f77af5ee99a3f5f630 100644 --- a/src/file_lists.cmake +++ b/src/file_lists.cmake @@ -119,7 +119,6 @@ set(libprotobuf_hdrs ${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_lite.h ${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_visitor.h ${protobuf_SOURCE_DIR}/src/google/protobuf/dynamic_message.h - ${protobuf_SOURCE_DIR}/src/google/protobuf/endian.h ${protobuf_SOURCE_DIR}/src/google/protobuf/explicitly_constructed.h ${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set.h ${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set_inl.h @@ -245,7 +244,6 @@ set(libprotobuf_lite_hdrs ${protobuf_SOURCE_DIR}/src/google/protobuf/arenastring.h ${protobuf_SOURCE_DIR}/src/google/protobuf/arenaz_sampler.h ${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_lite.h - ${protobuf_SOURCE_DIR}/src/google/protobuf/endian.h ${protobuf_SOURCE_DIR}/src/google/protobuf/explicitly_constructed.h ${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set.h ${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set_inl.h diff --git a/src/google/protobuf/endian.h b/src/google/protobuf/endian_pb.h similarity index 100% rename from src/google/protobuf/endian.h rename to src/google/protobuf/endian_pb.h diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h index dc03435b22664b6bd56baa5f96ea22f7102ee28c..a0cab49253c7d43a36e087dd655050e450d38616 100644 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -110,7 +110,7 @@ #include "absl/numeric/bits.h" #include "absl/strings/cord.h" #include "absl/strings/string_view.h" -#include "google/protobuf/endian.h" +#include "google/protobuf/endian_pb.h" // Must be included last. #include "google/protobuf/port_def.inc" diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h index 22ed8212dfa6ddac9c0d97cc19a5df0dd62285a7..8d30655e8183722acf0f9c315cb3dc70b23e394e 100644 --- a/src/google/protobuf/parse_context.h +++ b/src/google/protobuf/parse_context.h @@ -23,7 +23,7 @@ #include "absl/types/optional.h" #include "google/protobuf/arena.h" #include "google/protobuf/arenastring.h" -#include "google/protobuf/endian.h" +#include "google/protobuf/endian_pb.h" #include "google/protobuf/inlined_string_field.h" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/zero_copy_stream.h" diff --git a/src/google/protobuf/wire_format_lite.cc b/src/google/protobuf/wire_format_lite.cc index 0e564293664e5ff03fdf40941c4e0d72024ef421..3ed31bb9f3de3d8deea0b91d20da1bf5ede34881 100644 --- a/src/google/protobuf/wire_format_lite.cc +++ b/src/google/protobuf/wire_format_lite.cc @@ -610,8 +610,13 @@ void PrintUTF8ErrorLog(absl::string_view message_name, ABSL_LOG(ERROR) << error_message; } +#if defined (__MINGW64__) || defined(__MINGW32__) bool WireFormatLite::VerifyUtf8String(const char* data, int size, Operation op, - std::string_view field_name) { + const std::string_view field_name) { +#else +bool WireFormatLite::VerifyUtf8String(const char* data, int size, Operation op, + const absl::string_view field_name) { +#endif if (!utf8_range::IsStructurallyValid({data, static_cast(size)})) { const char* operation_str = nullptr; switch (op) { @@ -623,7 +628,11 @@ bool WireFormatLite::VerifyUtf8String(const char* data, int size, Operation op, break; // no default case: have the compiler warn if a case is not covered. } +#if defined (__MINGW64__) || defined(__MINGW32__) PrintUTF8ErrorLog("", absl::string_view{field_name.data(), field_name.size()}, operation_str, false); +#else + PrintUTF8ErrorLog("", field_name, operation_str, false); +#endif return false; } return true; diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h index 9f8a119d549f46c1bf5625b7783e80090486964b..96b223d84003e86f031431b0424ce9cf02cb52ac 100644 --- a/src/google/protobuf/wire_format_lite.h +++ b/src/google/protobuf/wire_format_lite.h @@ -317,8 +317,14 @@ class PROTOBUF_EXPORT WireFormatLite { }; // Returns true if the data is valid UTF-8. +#if defined (__MINGW64__) || defined(__MINGW32__) static bool VerifyUtf8String(const char* data, int size, Operation op, std::string_view field_name); +#else + static bool VerifyUtf8String(const char* data, int size, Operation op, + absl::string_view field_name); +#endif + template static inline bool ReadGroup(int field_number, io::CodedInputStream* input, diff --git a/third_party/utf8_range/CMakeLists.txt b/third_party/utf8_range/CMakeLists.txt index 4276b972908fb1b12c26a56816e6b45dae9e17e0..8d7a6e15c6c09af4738f697361faedba82603ba2 100644 --- a/third_party/utf8_range/CMakeLists.txt +++ b/third_party/utf8_range/CMakeLists.txt @@ -11,13 +11,13 @@ option (utf8_range_ENABLE_INSTALL "Configure installation" ON) ## # Create the lightweight C library -add_library (utf8_range +add_library (utf8_range STATIC utf8_range.c ) ## # A heavier-weight C++ wrapper that supports Abseil. -add_library (utf8_validity utf8_validity.cc utf8_range.c) +add_library (utf8_validity STATIC utf8_validity.cc utf8_range.c) # Load Abseil dependency. if (NOT TARGET absl::strings)