0
csrc/cmake/third_party/.gitkeep
vendored
Normal file
0
csrc/cmake/third_party/.gitkeep
vendored
Normal file
59
csrc/cmake/third_party/abseil-cpp.cmake
vendored
Normal file
59
csrc/cmake/third_party/abseil-cpp.cmake
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
# ----------------------------------------------------------------------------
|
||||
# This program is free software, you can redistribute it and/or modify it.
|
||||
# Copyright (c) 2025 Huawei Technologies Co., Ltd.
|
||||
# This file is a part of the CANN Open Software.
|
||||
# Licensed under CANN Open Software License Agreement Version 2.0 (the "License").
|
||||
# Please refer to the License for details. You may not use this file except in compliance with the License.
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See LICENSE in the root of the software repository for the full text of the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
include(ExternalProject)
|
||||
set(ABSEIL_VERSION_PKG abseil-cpp-20230802.1.tar.gz)
|
||||
|
||||
unset(abseil-cpp_FOUND CACHE)
|
||||
unset(ABSL_SOURCE_DIR CACHE)
|
||||
|
||||
find_path(ABSL_SOURCE_DIR
|
||||
NAMES absl/log/absl_log.h
|
||||
NO_CMAKE_SYSTEM_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
PATHS ${PROJECT_SOURCE_DIR}/third_party/abseil-cpp)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(abseil-cpp
|
||||
FOUND_VAR
|
||||
abseil-cpp_FOUND
|
||||
REQUIRED_VARS
|
||||
ABSL_SOURCE_DIR)
|
||||
|
||||
set(ABSEIL_SOURCE_DIR ${PROJECT_SOURCE_DIR}/third_party/abseil-cpp)
|
||||
if(abseil-cpp_FOUND)
|
||||
message(STATUS "Found abseil-cpp in ${CANN_3RD_LIB_PATH}/abseil-cpp")
|
||||
else()
|
||||
# 初始化可选参数列表
|
||||
if(EXISTS "${CANN_3RD_LIB_PATH}/abseil-cpp/${ABSEIL_VERSION_PKG}")
|
||||
set(REQ_URL "file://${CANN_3RD_LIB_PATH}/abseil-cpp/${ABSEIL_VERSION_PKG}")
|
||||
message(STATUS "[ThirdPartyLib][abseil-cpp] found in ${REQ_URL}.")
|
||||
elseif(EXISTS "${CANN_3RD_LIB_PATH}/pkg/${ABSEIL_VERSION_PKG}")
|
||||
set(REQ_URL "file://${CANN_3RD_LIB_PATH}/pkg/${ABSEIL_VERSION_PKG}")
|
||||
message(STATUS "[ThirdPartyLib][abseil-cpp] found in ${REQ_URL}.")
|
||||
else()
|
||||
set(REQ_URL "https://gitcode.com/cann-src-third-party/abseil-cpp/releases/download/20230802.1/abseil-cpp-20230802.1.tar.gz")
|
||||
message(STATUS "[ThirdPartyLib][abseil-cpp] ${REQ_URL} not found, need download.")
|
||||
endif()
|
||||
|
||||
ExternalProject_Add(abseil_build_transformer
|
||||
URL ${REQ_URL}
|
||||
DOWNLOAD_DIR ${CANN_3RD_LIB_PATH}/pkg
|
||||
PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_LIST_DIR}/build/modules/patch/protobuf-hide_absl_symbols.patch
|
||||
SOURCE_DIR ${ABSEIL_SOURCE_DIR}
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
EXCLUDE_FROM_ALL TRUE
|
||||
)
|
||||
|
||||
ExternalProject_Get_Property(abseil_build_transformer SOURCE_DIR)
|
||||
set(ABSL_SOURCE_DIR ${SOURCE_DIR})
|
||||
endif()
|
||||
89
csrc/cmake/third_party/ascend_protobuf.cmake
vendored
Normal file
89
csrc/cmake/third_party/ascend_protobuf.cmake
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
# ----------------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2025 Huawei Technologies Co., Ltd.
|
||||
# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
|
||||
# CANN Open Software License Agreement Version 2.0 (the "License").
|
||||
# Please refer to the License for details. You may not use this file except in compliance with the License.
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See LICENSE in the root of the software repository for the full text of the License.
|
||||
# ----------------------------------------------------------------------------------------------------------
|
||||
include(ExternalProject)
|
||||
set(PROTOBUF_VERSION_PKG protobuf-25.1.tar.gz)
|
||||
set(ASCEND_PROTOBUF_DIR ${CANN_3RD_LIB_PATH}/ascend_protobuf)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(ascend_protobuf_build_transformer
|
||||
FOUND_VAR
|
||||
ascend_protobuf_build_transformer_FOUND
|
||||
REQUIRED_VARS
|
||||
ASCEND_PROTOBUF_SHARED_INCLUDE
|
||||
)
|
||||
|
||||
set(ASCEND_PROTOBUF_SOURCE_DIR ${PROJECT_SOURCE_DIR}/third_party/ascend_protobuf)
|
||||
if(ascend_protobuf_build_transformer_FOUND AND NOT FORCE_REBUILD_CANN_3RD)
|
||||
message(STATUS "[ThirdPartyLib][ascend protobuf] ascend_protobuf_shared found, skip compile.")
|
||||
cmake_print_variables(ASCEND_PROTOBUF_SHARED_INCLUDE)
|
||||
cmake_print_variables(ASCEND_PROTOC)
|
||||
set(Protobuf_INCLUDE ${ASCEND_PROTOBUF_SHARED_INCLUDE})
|
||||
set(Protobuf_PATH ${ASCEND_PROTOC})
|
||||
set(Protobuf_PROTOC_EXECUTABLE ${Protobuf_PATH}/protoc)
|
||||
add_library(ascend_protobuf_build_transformer INTERFACE)
|
||||
else()
|
||||
message(STATUS "[ThirdPartyLib][ascend protobuf] ascend protobuf shared not found, finding binary file.")
|
||||
if(EXISTS "${CANN_3RD_LIB_PATH}/protobuf/protobuf-all-25.1.tar.gz")
|
||||
set(REQ_URL "file://${CANN_3RD_LIB_PATH}/protobuf/protobuf-all-25.1.tar.gz")
|
||||
message(STATUS "[ThirdPartyLib][ascend protobuf] found in ${REQ_URL}.")
|
||||
elseif(EXISTS "${CANN_3RD_LIB_PATH}/pkg/${PROTOBUF_VERSION_PKG}")
|
||||
set(REQ_URL "file://${CANN_3RD_LIB_PATH}/pkg/${PROTOBUF_VERSION_PKG}")
|
||||
message(STATUS "[ThirdPartyLib][ascend protobuf] found in ${REQ_URL}.")
|
||||
else()
|
||||
set(REQ_URL "https://gitcode.com/cann-src-third-party/protobuf/releases/download/v25.1/protobuf-25.1.tar.gz")
|
||||
message(STATUS "[ThirdPartyLib][ascend protobuf] ${REQ_URL} not found, need download.")
|
||||
endif()
|
||||
|
||||
set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2 -Dgoogle=ascend_private")
|
||||
set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
|
||||
|
||||
ExternalProject_Add(ascend_protobuf_build_transformer
|
||||
URL ${REQ_URL}
|
||||
DOWNLOAD_DIR ${CANN_3RD_LIB_PATH}/pkg
|
||||
PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_LIST_DIR}/build/modules/patch/protobuf_25.1_change_version.patch
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND}
|
||||
-DCMAKE_MESSAGE_LOG_LEVEL=ERROR
|
||||
-DCMAKE_INSTALL_LIBDIR=lib
|
||||
-Dprotobuf_WITH_ZLIB=OFF
|
||||
-DLIB_PREFIX=ascend_
|
||||
-DCMAKE_SKIP_RPATH=TRUE
|
||||
-Dprotobuf_BUILD_TESTS=OFF
|
||||
-DBUILD_SHARED_LIBS=OFF
|
||||
-DCMAKE_CXX_STANDARD=14
|
||||
-DCMAKE_CXX_FLAGS=${protobuf_CXXFLAGS}
|
||||
-DCMAKE_CXX_LDFLAGS=${protobuf_LDFLAGS}
|
||||
-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}
|
||||
-DCMAKE_INSTALL_PREFIX=${ASCEND_PROTOBUF_DIR}
|
||||
-Dprotobuf_BUILD_PROTOC_BINARIES=ON
|
||||
-Dprotobuf_ABSL_PROVIDER=module
|
||||
-DABSL_ROOT_DIR=${ABSL_SOURCE_DIR}
|
||||
<SOURCE_DIR>
|
||||
SOURCE_DIR ${ASCEND_PROTOBUF_SOURCE_DIR}
|
||||
BUILD_COMMAND ${CMAKE_COMMAND} --build .
|
||||
INSTALL_COMMAND ""
|
||||
EXCLUDE_FROM_ALL TRUE
|
||||
)
|
||||
if(TARGET abseil_build_transformer)
|
||||
add_dependencies(ascend_protobuf_build_transformer abseil_build_transformer)
|
||||
endif()
|
||||
|
||||
ExternalProject_Get_Property(ascend_protobuf_build_transformer SOURCE_DIR)
|
||||
ExternalProject_Get_Property(ascend_protobuf_build_transformer BINARY_DIR)
|
||||
|
||||
set(Protobuf_INCLUDE ${SOURCE_DIR}/src)
|
||||
set(Protobuf_PATH ${BINARY_DIR})
|
||||
set(Protobuf_PROTOC_EXECUTABLE ${Protobuf_PATH}/protoc)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${Protobuf_PROTOC_EXECUTABLE}
|
||||
DEPENDS ascend_protobuf_build_transformer
|
||||
)
|
||||
endif()
|
||||
61
csrc/cmake/third_party/build/modules/patch/protobuf-hide_absl_symbols.patch
vendored
Normal file
61
csrc/cmake/third_party/build/modules/patch/protobuf-hide_absl_symbols.patch
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index eef6626..c054264 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -18,6 +18,9 @@
|
||||
# As of 2022-09-06, CMake 3.10 is the minimum supported version.
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
+# NOTICE: force using static libraries
|
||||
+set(BUILD_SHARED_LIBS OFF)
|
||||
+
|
||||
# Compiler id for Apple Clang is now AppleClang.
|
||||
if (POLICY CMP0025)
|
||||
cmake_policy(SET CMP0025 NEW)
|
||||
@@ -219,6 +222,7 @@ if(ABSL_ENABLE_INSTALL)
|
||||
PATTERN "*.h"
|
||||
PATTERN "copts" EXCLUDE
|
||||
PATTERN "testdata" EXCLUDE
|
||||
+ PATTERN "options.h" EXCLUDE
|
||||
)
|
||||
|
||||
file(READ "absl/base/options.h" ABSL_INTERNAL_OPTIONS_H_CONTENTS)
|
||||
diff --git a/absl/base/options.h b/absl/base/options.h
|
||||
index f308e1b..09617e0 100644
|
||||
--- a/absl/base/options.h
|
||||
+++ b/absl/base/options.h
|
||||
@@ -200,7 +200,7 @@
|
||||
// allowed.
|
||||
|
||||
#define ABSL_OPTION_USE_INLINE_NAMESPACE 1
|
||||
-#define ABSL_OPTION_INLINE_NAMESPACE_NAME lts_20230802
|
||||
+#define ABSL_OPTION_INLINE_NAMESPACE_NAME lts_ascend_private
|
||||
|
||||
// ABSL_OPTION_HARDENED
|
||||
//
|
||||
diff --git a/absl/hash/internal/hash.cc b/absl/hash/internal/hash.cc
|
||||
index 11451e5..75886d3 100644
|
||||
--- a/absl/hash/internal/hash.cc
|
||||
+++ b/absl/hash/internal/hash.cc
|
||||
@@ -44,7 +44,7 @@ uint64_t MixingHashState::CombineLargeContiguousImpl64(
|
||||
std::integral_constant<int, 8>{});
|
||||
}
|
||||
|
||||
-ABSL_CONST_INIT const void* const MixingHashState::kSeed = &kSeed;
|
||||
+ABSL_CONST_INIT const void* const MixingHashState::kSeed = 0;
|
||||
|
||||
// The salt array used by LowLevelHash. This array is NOT the mechanism used to
|
||||
// make absl::Hash non-deterministic between program invocations. See `Seed()`
|
||||
diff --git a/absl/hash/internal/hash.h b/absl/hash/internal/hash.h
|
||||
index ef3f366..7714cdb 100644
|
||||
--- a/absl/hash/internal/hash.h
|
||||
+++ b/absl/hash/internal/hash.h
|
||||
@@ -1159,7 +1159,7 @@ class ABSL_DLL MixingHashState : public HashStateBase<MixingHashState> {
|
||||
#if (!defined(__clang__) || __clang_major__ > 11) && \
|
||||
(!defined(__apple_build_version__) || \
|
||||
__apple_build_version__ >= 19558921) // Xcode 12
|
||||
- return static_cast<uint64_t>(reinterpret_cast<uintptr_t>(&kSeed));
|
||||
+ return static_cast<uint64_t>(reinterpret_cast<uintptr_t>(kSeed));
|
||||
#else
|
||||
// Workaround the absence of
|
||||
// https://github.com/llvm/llvm-project/commit/bc15bf66dcca76cc06fe71fca35b74dc4d521021.
|
||||
357
csrc/cmake/third_party/build/modules/patch/protobuf_25.1_change_version.patch
vendored
Normal file
357
csrc/cmake/third_party/build/modules/patch/protobuf_25.1_change_version.patch
vendored
Normal file
@@ -0,0 +1,357 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 4137ce2..1d9e1ca 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -79,7 +79,7 @@ if (protobuf_BUILD_SHARED_LIBS)
|
||||
endif ()
|
||||
|
||||
# Version metadata
|
||||
-set(protobuf_VERSION_STRING "4.25.1")
|
||||
+set(protobuf_VERSION_STRING "3.13.0")
|
||||
set(protobuf_DESCRIPTION "Protocol Buffers")
|
||||
set(protobuf_CONTACT "protobuf@googlegroups.com")
|
||||
|
||||
@@ -105,7 +105,7 @@ message(STATUS "${protobuf_VERSION_PRERELEASE}")
|
||||
|
||||
# Package version
|
||||
set(protobuf_VERSION
|
||||
- "${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}")
|
||||
+ "${protobuf_VERSION_MAJOR}.${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}")
|
||||
|
||||
if(protobuf_VERSION_PRERELEASE)
|
||||
set(protobuf_VERSION "${protobuf_VERSION}.${protobuf_VERSION_PRERELEASE}")
|
||||
@@ -122,30 +122,6 @@ if(protobuf_VERBOSE)
|
||||
message(STATUS "]")
|
||||
endif()
|
||||
|
||||
-file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map
|
||||
-"{
|
||||
- global:
|
||||
- main;
|
||||
- local:
|
||||
- *;
|
||||
-};")
|
||||
-# CheckLinkerFlag module available in CMake >=3.18.
|
||||
-if(${CMAKE_VERSION} VERSION_GREATER 3.18 OR ${CMAKE_VERSION} VERSION_EQUAL 3.18)
|
||||
- include(CheckLinkerFlag)
|
||||
- check_linker_flag(CXX -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map protobuf_HAVE_LD_VERSION_SCRIPT)
|
||||
-else()
|
||||
- include(CheckCXXSourceCompiles)
|
||||
- set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
||||
- set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map)
|
||||
- check_cxx_source_compiles("
|
||||
- int main() {
|
||||
- return 0;
|
||||
- }
|
||||
- " protobuf_HAVE_LD_VERSION_SCRIPT)
|
||||
- set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
|
||||
-endif()
|
||||
-file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map)
|
||||
-
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
# We can install dependencies from submodules if we're running
|
||||
diff --git a/src/google/protobuf/arenastring.cc b/src/google/protobuf/arenastring.cc
|
||||
index bf9d0bb..0e4f450 100644
|
||||
--- a/src/google/protobuf/arenastring.cc
|
||||
+++ b/src/google/protobuf/arenastring.cc
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "absl/log/absl_check.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
+#include "absl/strings/escaping.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
#include "google/protobuf/io/coded_stream.h"
|
||||
#include "google/protobuf/message_lite.h"
|
||||
@@ -116,7 +117,7 @@ void ArenaStringPtr::Set(absl::string_view value, Arena* arena) {
|
||||
old->assign("garbagedata");
|
||||
}
|
||||
#else // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
- UnsafeMutablePointer()->assign(value.data(), value.length());
|
||||
+ UnsafeMutablePointer()->assign(std::string(value.data(), value.length()));
|
||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
}
|
||||
}
|
||||
@@ -263,6 +264,30 @@ void ArenaStringPtr::ClearToDefault(const LazyString& default_value,
|
||||
}
|
||||
}
|
||||
|
||||
+void ArenaStringPtr::Set(EmptyDefault, const std::string& value, Arena* arena) {
|
||||
+ Set(value, arena);
|
||||
+}
|
||||
+
|
||||
+void ArenaStringPtr::Set(EmptyDefault, absl::string_view value, Arena* arena) {
|
||||
+ Set(value, arena);
|
||||
+}
|
||||
+
|
||||
+void ArenaStringPtr::Set(EmptyDefault, std::string&& value, Arena* arena) {
|
||||
+ Set(value, arena);
|
||||
+}
|
||||
+
|
||||
+void ArenaStringPtr::Set(EmptyDefault, const char* s, Arena* arena) {
|
||||
+ Set(s, arena);
|
||||
+}
|
||||
+
|
||||
+void ArenaStringPtr::Set(EmptyDefault, const char* s, size_t n, Arena* arena) {
|
||||
+ Set(s, n, arena);
|
||||
+}
|
||||
+
|
||||
+void ArenaStringPtr::Set(EmptyDefault, const void* p, size_t n, Arena* arena) {
|
||||
+ Set(absl::string_view{static_cast<const char*>(p), n}, arena);
|
||||
+}
|
||||
+
|
||||
const char* EpsCopyInputStream::ReadArenaString(const char* ptr,
|
||||
ArenaStringPtr* s,
|
||||
Arena* arena) {
|
||||
@@ -277,8 +302,11 @@ const char* EpsCopyInputStream::ReadArenaString(const char* ptr,
|
||||
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
||||
return ptr;
|
||||
}
|
||||
-
|
||||
} // namespace internal
|
||||
+
|
||||
+std::string CEscape(const std::string &src) {
|
||||
+ return absl::CEscape(absl::string_view(src));
|
||||
+}
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h
|
||||
index dea2aec..ffe2343 100644
|
||||
--- a/src/google/protobuf/arenastring.h
|
||||
+++ b/src/google/protobuf/arenastring.h
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "google/protobuf/arena.h"
|
||||
#include "google/protobuf/explicitly_constructed.h"
|
||||
#include "google/protobuf/port.h"
|
||||
+#include "absl/strings/string_view.h"
|
||||
+#include "absl/strings/escaping.h"
|
||||
|
||||
// must be last:
|
||||
#include "google/protobuf/port_def.inc"
|
||||
@@ -298,7 +300,15 @@ struct PROTOBUF_EXPORT ArenaStringPtr {
|
||||
void Set(const std::string& value, Arena* arena);
|
||||
void Set(const char* s, Arena* arena);
|
||||
void Set(const char* s, size_t n, Arena* arena);
|
||||
-
|
||||
+ // Compatibility with undefined symbol modifications in opp_kernel packages compiled based on protobuf 3.14
|
||||
+ struct EmptyDefault {};
|
||||
+ void Set(EmptyDefault, const std::string& value, Arena* arena);
|
||||
+ void Set(EmptyDefault, absl::string_view value, Arena* arena);
|
||||
+ void Set(EmptyDefault, std::string&& value, Arena* arena);
|
||||
+ void Set(EmptyDefault, const char* s, Arena* arena);
|
||||
+ void Set(EmptyDefault, const char* s, size_t n, Arena* arena);
|
||||
+ void Set(EmptyDefault, const void* p, size_t n, Arena* arena);
|
||||
+
|
||||
void SetBytes(absl::string_view value, Arena* arena);
|
||||
void SetBytes(std::string&& value, Arena* arena);
|
||||
template <typename... OverloadDisambiguator>
|
||||
@@ -528,9 +538,9 @@ inline std::string* ArenaStringPtr::UnsafeMutablePointer() {
|
||||
ABSL_DCHECK(tagged_ptr_.Get() != nullptr);
|
||||
return tagged_ptr_.Get();
|
||||
}
|
||||
-
|
||||
-
|
||||
} // namespace internal
|
||||
+
|
||||
+PROTOBUF_EXPORT std::string CEscape(const std::string& src);
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
diff --git a/src/google/protobuf/compiler/cpp/field_generators/string_field.cc b/src/google/protobuf/compiler/cpp/field_generators/string_field.cc
|
||||
index 748a8d6..1834c39 100644
|
||||
--- a/src/google/protobuf/compiler/cpp/field_generators/string_field.cc
|
||||
+++ b/src/google/protobuf/compiler/cpp/field_generators/string_field.cc
|
||||
@@ -347,7 +347,7 @@ void SingularString::ReleaseImpl(io::Printer* p) const {
|
||||
p->Emit(R"cc(
|
||||
auto* released = $field_$.Release();
|
||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
- $field_$.Set("", $set_args$);
|
||||
+ $field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, "", $set_args$);
|
||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
return released;
|
||||
)cc");
|
||||
@@ -393,7 +393,7 @@ void SingularString::SetAllocatedImpl(io::Printer* p) const {
|
||||
p->Emit(R"cc(
|
||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
if ($field_$.IsDefault()) {
|
||||
- $field_$.Set("", $set_args$);
|
||||
+ $field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, "", $set_args$);
|
||||
}
|
||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
)cc");
|
||||
@@ -442,7 +442,7 @@ void SingularString::GenerateInlineAccessorDefinitions(io::Printer* p) const {
|
||||
$TsanDetectConcurrentMutation$;
|
||||
$PrepareSplitMessageForWrite$;
|
||||
$update_hasbit$;
|
||||
- $field_$.$Set$(static_cast<Arg_&&>(arg), args..., $set_args$);
|
||||
+ $field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, static_cast<Arg_&&>(arg), args..., $set_args$);
|
||||
$annotate_set$;
|
||||
// @@protoc_insertion_point(field_set:$pkg.Msg.field$)
|
||||
}
|
||||
@@ -463,7 +463,7 @@ void SingularString::GenerateInlineAccessorDefinitions(io::Printer* p) const {
|
||||
$update_hasbit$;
|
||||
//~ Don't use $Set$ here; we always want the std::string variant
|
||||
//~ regardless of whether this is a `bytes` field.
|
||||
- $field_$.Set(value, $set_args$);
|
||||
+ $field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, value, $set_args$);
|
||||
}
|
||||
inline std::string* $Msg$::_internal_mutable_$name$() {
|
||||
$TsanDetectConcurrentMutation$;
|
||||
@@ -599,7 +599,7 @@ void SingularString::GenerateConstructorCode(io::Printer* p) const {
|
||||
if (IsString(field_, *opts_) && EmptyDefault()) {
|
||||
p->Emit(R"cc(
|
||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
- $field_$.Set("", GetArena());
|
||||
+ $field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, "", GetArena());
|
||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
)cc");
|
||||
}
|
||||
@@ -636,7 +636,7 @@ void SingularString::GenerateCopyConstructorCode(io::Printer* p) const {
|
||||
}}},
|
||||
R"cc(
|
||||
if ($hazzer$) {
|
||||
- _this->$field_$.Set(from._internal_$name$(), $set_args$);
|
||||
+ _this->$field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, from._internal_$name$(), $set_args$);
|
||||
}
|
||||
)cc");
|
||||
}
|
||||
diff --git a/src/google/protobuf/compiler/cpp/helpers.cc b/src/google/protobuf/compiler/cpp/helpers.cc
|
||||
index 2c8d275..d0abac8 100644
|
||||
--- a/src/google/protobuf/compiler/cpp/helpers.cc
|
||||
+++ b/src/google/protobuf/compiler/cpp/helpers.cc
|
||||
@@ -1706,8 +1706,7 @@ bool IsFileDescriptorProto(const FileDescriptor* file, const Options& options) {
|
||||
}
|
||||
|
||||
bool ShouldGenerateClass(const Descriptor* descriptor, const Options& options) {
|
||||
- return !IsMapEntryMessage(descriptor) ||
|
||||
- HasDescriptorMethods(descriptor->file(), options);
|
||||
+ return true;
|
||||
}
|
||||
|
||||
} // namespace cpp
|
||||
diff --git a/src/google/protobuf/compiler/cpp/helpers.h b/src/google/protobuf/compiler/cpp/helpers.h
|
||||
index 9b74835..a1b6f58 100644
|
||||
--- a/src/google/protobuf/compiler/cpp/helpers.h
|
||||
+++ b/src/google/protobuf/compiler/cpp/helpers.h
|
||||
@@ -1002,7 +1002,7 @@ inline bool ShouldGenerateExternSpecializations(const Options& options) {
|
||||
// Some compilers can't handle that much input in a single translation unit.
|
||||
// These specializations are just a link size optimization and do not affect
|
||||
// correctness or performance, so it is ok to omit them.
|
||||
- return !options.opensource_runtime;
|
||||
+ return true;
|
||||
}
|
||||
|
||||
struct OneOfRangeImpl {
|
||||
diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc
|
||||
index af5c0b2..254e77c 100644
|
||||
--- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc
|
||||
+++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc
|
||||
@@ -254,7 +254,7 @@ std::string GetFieldConstantName(const FieldDescriptor* field) {
|
||||
|
||||
std::string GetPropertyName(const FieldDescriptor* descriptor) {
|
||||
// Names of members declared or overridden in the message.
|
||||
- static const auto& reserved_member_names = *new absl::flat_hash_set<absl::string_view>({
|
||||
+ static const auto& reserved_member_names = *new std::set<absl::string_view>({
|
||||
"Types",
|
||||
"Descriptor",
|
||||
"Equals",
|
||||
diff --git a/src/google/protobuf/compiler/java/names.cc b/src/google/protobuf/compiler/java/names.cc
|
||||
index d934973..caa3c47 100644
|
||||
--- a/src/google/protobuf/compiler/java/names.cc
|
||||
+++ b/src/google/protobuf/compiler/java/names.cc
|
||||
@@ -37,7 +37,7 @@ const char* DefaultPackage(Options options) {
|
||||
|
||||
bool IsReservedName(absl::string_view name) {
|
||||
static const auto& kReservedNames =
|
||||
- *new absl::flat_hash_set<absl::string_view>({
|
||||
+ *new std::set<absl::string_view>({
|
||||
"abstract", "assert", "boolean", "break", "byte",
|
||||
"case", "catch", "char", "class", "const",
|
||||
"continue", "default", "do", "double", "else",
|
||||
@@ -49,7 +49,7 @@ bool IsReservedName(absl::string_view name) {
|
||||
"switch", "synchronized", "this", "throw", "throws",
|
||||
"transient", "try", "void", "volatile", "while",
|
||||
});
|
||||
- return kReservedNames.contains(name);
|
||||
+ return kReservedNames.count(name) != 0U;
|
||||
}
|
||||
|
||||
bool IsForbidden(absl::string_view field_name) {
|
||||
@@ -59,7 +59,7 @@ bool IsForbidden(absl::string_view field_name) {
|
||||
// Keep this list in sync with specialFieldNames in
|
||||
// java/core/src/main/java/com/google/protobuf/DescriptorMessageInfoFactory.java
|
||||
static const auto& kForbiddenNames =
|
||||
- *new absl::flat_hash_set<absl::string_view>({
|
||||
+ *new std::set<absl::string_view>({
|
||||
// java.lang.Object:
|
||||
"Class",
|
||||
// com.google.protobuf.MessageLiteOrBuilder:
|
||||
@@ -75,7 +75,7 @@ bool IsForbidden(absl::string_view field_name) {
|
||||
// obsolete. kept for backwards compatibility of generated code
|
||||
"CachedSize",
|
||||
});
|
||||
- return kForbiddenNames.contains(UnderscoresToCamelCase(field_name, true));
|
||||
+ return kForbiddenNames.count(UnderscoresToCamelCase(field_name, true)) != 0U;
|
||||
}
|
||||
|
||||
std::string FieldName(const FieldDescriptor* field) {
|
||||
diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h
|
||||
index f45a1c8..e2191b7 100644
|
||||
--- a/src/google/protobuf/extension_set.h
|
||||
+++ b/src/google/protobuf/extension_set.h
|
||||
@@ -166,7 +166,7 @@ class PROTOBUF_EXPORT GeneratedExtensionFinder {
|
||||
// off to the ExtensionSet for parsing. Etc.
|
||||
class PROTOBUF_EXPORT ExtensionSet {
|
||||
public:
|
||||
- constexpr ExtensionSet() : ExtensionSet(nullptr) {}
|
||||
+ constexpr ExtensionSet();
|
||||
ExtensionSet(const ExtensionSet& rhs) = delete;
|
||||
|
||||
// Arena enabled constructors: for internal use only.
|
||||
@@ -912,6 +912,9 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
static void DeleteFlatMap(const KeyValue* flat, uint16_t flat_capacity);
|
||||
};
|
||||
|
||||
+constexpr ExtensionSet::ExtensionSet()
|
||||
+ : arena_(nullptr), flat_capacity_(0), flat_size_(0), map_{nullptr} {}
|
||||
+
|
||||
constexpr ExtensionSet::ExtensionSet(Arena* arena)
|
||||
: arena_(arena), flat_capacity_(0), flat_size_(0), map_{nullptr} {}
|
||||
|
||||
diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h
|
||||
index de8bd19..60bc923 100644
|
||||
--- a/src/google/protobuf/message_lite.h
|
||||
+++ b/src/google/protobuf/message_lite.h
|
||||
@@ -505,12 +505,10 @@ class PROTOBUF_EXPORT MessageLite {
|
||||
return Arena::CreateMaybeMessage<T>(arena);
|
||||
}
|
||||
|
||||
-#ifdef PROTOBUF_EXPLICIT_CONSTRUCTORS
|
||||
template <typename T>
|
||||
static T* CreateMaybeMessage(Arena* arena, const T& from) {
|
||||
return Arena::CreateMaybeMessage<T>(arena, from);
|
||||
}
|
||||
-#endif // PROTOBUF_EXPLICIT_CONSTRUCTORS
|
||||
|
||||
inline explicit MessageLite(Arena* arena) : _internal_metadata_(arena) {}
|
||||
|
||||
diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc
|
||||
index 25abc30..f17d861 100644
|
||||
--- a/src/google/protobuf/port_def.inc
|
||||
+++ b/src/google/protobuf/port_def.inc
|
||||
@@ -572,14 +572,6 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3),
|
||||
#error PROTOBUF_FORCE_COPY_DEFAULT_STRING was previously defined
|
||||
#endif
|
||||
|
||||
-// Set (and leave set) PROTOBUF_EXPLICIT_CONSTRUCTORS
|
||||
-// This flag changes the internal implementation class and its uses from using
|
||||
-// aggregate initialization to using explicit constructor based initialization.
|
||||
-// TODO: remove this flag and make the code permanent.
|
||||
-#ifndef PROTOBUF_EXPLICIT_CONSTRUCTORS
|
||||
-#define PROTOBUF_EXPLICIT_CONSTRUCTORS
|
||||
-#endif
|
||||
-
|
||||
#ifdef PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION
|
||||
#error PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION was previously defined
|
||||
#endif
|
||||
115
csrc/cmake/third_party/gtest.cmake
vendored
Normal file
115
csrc/cmake/third_party/gtest.cmake
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
# -----------------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2025 Huawei Technologies Co., Ltd.
|
||||
# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
|
||||
# CANN Open Software License Agreement Version 2.0 (the "License").
|
||||
# Please refer to the License for details. You may not use this file except in compliance with the License.
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See LICENSE in the root of the software repository for the full text of the License.
|
||||
# -----------------------------------------------------------------------------------------------------------
|
||||
|
||||
include_guard(GLOBAL)
|
||||
|
||||
unset(gtest_FOUND CACHE)
|
||||
unset(GTEST_INCLUDE CACHE)
|
||||
unset(GTEST_STATIC_LIBRARY CACHE)
|
||||
unset(GTEST_MAIN_STATIC_LIBRARY CACHE)
|
||||
unset(GMOCK_STATIC_LIBRARY CACHE)
|
||||
unset(GMOCK_MAIN_STATIC_LIBRARY CACHE)
|
||||
|
||||
set(GTEST_INSTALL_PATH ${CANN_3RD_LIB_PATH}/gtest)
|
||||
message("GTEST_INSTALL_PATH=${GTEST_INSTALL_PATH}")
|
||||
find_path(GTEST_INCLUDE
|
||||
NAMES gtest/gtest.h
|
||||
NO_CMAKE_SYSTEM_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
PATHS ${GTEST_INSTALL_PATH}/include)
|
||||
find_library(GTEST_STATIC_LIBRARY
|
||||
NAMES libgtest.a
|
||||
PATH_SUFFIXES lib lib64
|
||||
NO_CMAKE_SYSTEM_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
PATHS ${GTEST_INSTALL_PATH})
|
||||
find_library(GTEST_MAIN_STATIC_LIBRARY
|
||||
NAMES libgtest_main.a
|
||||
PATH_SUFFIXES lib lib64
|
||||
NO_CMAKE_SYSTEM_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
PATHS ${GTEST_INSTALL_PATH})
|
||||
find_library(GMOCK_STATIC_LIBRARY
|
||||
NAMES libgmock.a
|
||||
PATH_SUFFIXES lib lib64
|
||||
NO_CMAKE_SYSTEM_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
PATHS ${GTEST_INSTALL_PATH})
|
||||
find_library(GMOCK_MAIN_STATIC_LIBRARY
|
||||
NAMES libgmock_main.a
|
||||
PATH_SUFFIXES lib lib64
|
||||
NO_CMAKE_SYSTEM_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
PATHS ${GTEST_INSTALL_PATH})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(gtest
|
||||
FOUND_VAR
|
||||
gtest_FOUND
|
||||
REQUIRED_VARS
|
||||
GTEST_INCLUDE
|
||||
GTEST_STATIC_LIBRARY
|
||||
GTEST_MAIN_STATIC_LIBRARY
|
||||
GMOCK_STATIC_LIBRARY
|
||||
GMOCK_MAIN_STATIC_LIBRARY
|
||||
)
|
||||
message("gtest found:${gtest_FOUND}")
|
||||
|
||||
if(gtest_FOUND AND NOT FORCE_REBUILD_CANN_3RD)
|
||||
message("gtest found in ${GTEST_INSTALL_PATH}, and not force rebuild cann third_party")
|
||||
else()
|
||||
set(REQ_URL "https://gitcode.com/cann-src-third-party/googletest/releases/download/v1.14.0/googletest-1.14.0.tar.gz")
|
||||
set (gtest_CXXFLAGS "-D_GLIBCXX_USE_CXX11_ABI=0 -O2 -D_FORTIFY_SOURCE=2 -fPIC -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack")
|
||||
set (gtest_CFLAGS "-D_GLIBCXX_USE_CXX11_ABI=0 -O2 -D_FORTIFY_SOURCE=2 -fPIC -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack")
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(third_party_gtest
|
||||
URL ${REQ_URL}
|
||||
TLS_VERIFY OFF
|
||||
DOWNLOAD_DIR ${CANN_3RD_PKG_PATH}
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND}
|
||||
-DCMAKE_CXX_FLAGS=${gtest_CXXFLAGS}
|
||||
-DCMAKE_C_FLAGS=${gtest_CFLAGS}
|
||||
-DCMAKE_INSTALL_PREFIX=${GTEST_INSTALL_PATH}
|
||||
-DCMAKE_INSTALL_LIBDIR=lib
|
||||
-DBUILD_SHARED_LIBS=OFF
|
||||
<SOURCE_DIR>
|
||||
BUILD_COMMAND $(MAKE)
|
||||
INSTALL_COMMAND $(MAKE) install
|
||||
EXCLUDE_FROM_ALL TRUE
|
||||
)
|
||||
endif()
|
||||
|
||||
set(GTEST_INCLUDE ${GTEST_INSTALL_PATH}/include)
|
||||
|
||||
add_library(gtest STATIC IMPORTED)
|
||||
add_dependencies(gtest third_party_gtest)
|
||||
|
||||
add_library(gmock STATIC IMPORTED)
|
||||
add_dependencies(gmock third_party_gtest)
|
||||
|
||||
add_library(gtest_main STATIC IMPORTED)
|
||||
add_dependencies(gtest_main third_party_gtest)
|
||||
|
||||
if (NOT EXISTS ${GTEST_INSTALL_PATH}/include)
|
||||
file(MAKE_DIRECTORY "${GTEST_INSTALL_PATH}/include")
|
||||
endif ()
|
||||
|
||||
set_target_properties(gtest PROPERTIES
|
||||
IMPORTED_LOCATION ${GTEST_INSTALL_PATH}/lib/libgtest.a
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${GTEST_INSTALL_PATH}/include)
|
||||
|
||||
set_target_properties(gmock PROPERTIES
|
||||
IMPORTED_LOCATION ${GTEST_INSTALL_PATH}/lib/libgmock.a
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${GTEST_INSTALL_PATH}/include)
|
||||
|
||||
set_target_properties(gtest_main PROPERTIES
|
||||
IMPORTED_LOCATION ${GTEST_INSTALL_PATH}/lib/libgtest_main.a
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${GTEST_INSTALL_PATH}/include)
|
||||
69
csrc/cmake/third_party/json.cmake
vendored
Normal file
69
csrc/cmake/third_party/json.cmake
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
# -----------------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2025 Huawei Technologies Co., Ltd.
|
||||
# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
|
||||
# CANN Open Software License Agreement Version 2.0 (the "License").
|
||||
# Please refer to the License for details. You may not use this file except in compliance with the License.
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See LICENSE in the root of the software repository for the full text of the License.
|
||||
# -----------------------------------------------------------------------------------------------------------
|
||||
|
||||
include_guard(GLOBAL)
|
||||
|
||||
if(json_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
unset(json_FOUND CACHE)
|
||||
unset(JSON_INCLUDE CACHE)
|
||||
|
||||
if(NOT CANN_3RD_PKG_PATH)
|
||||
set(CANN_3RD_PKG_PATH ${PROJECT_SOURCE_DIR}/third_party/pkg)
|
||||
endif()
|
||||
|
||||
set(JSON_DOWNLOAD_PATH ${CANN_3RD_LIB_PATH}/pkg)
|
||||
set(JSON_INSTALL_PATH ${CANN_3RD_LIB_PATH}/json)
|
||||
|
||||
find_path(JSON_INCLUDE
|
||||
NAMES nlohmann/json.hpp
|
||||
NO_CMAKE_SYSTEM_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
PATHS ${JSON_INSTALL_PATH}/include)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(json
|
||||
FOUND_VAR
|
||||
json_FOUND
|
||||
REQUIRED_VARS
|
||||
JSON_INCLUDE
|
||||
)
|
||||
|
||||
if(json_FOUND AND NOT FORCE_REBUILD_CANN_3RD)
|
||||
message("json found in ${JSON_INSTALL_PATH}, and not force rebuild cann third_party")
|
||||
set(JSON_INCLUDE_DIR ${JSON_INSTALL_PATH}/include)
|
||||
add_library(json INTERFACE IMPORTED)
|
||||
else()
|
||||
set(REQ_URL "https://gitcode.com/cann-src-third-party/json/releases/download/v3.11.3/include.zip")
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(third_party_json
|
||||
URL ${REQ_URL}
|
||||
TLS_VERIFY OFF
|
||||
DOWNLOAD_DIR ${JSON_DOWNLOAD_PATH}
|
||||
DOWNLOAD_NO_EXTRACT TRUE
|
||||
SOURCE_DIR ${JSON_INSTALL_PATH}
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND
|
||||
${CMAKE_COMMAND} -E make_directory ${JSON_INSTALL_PATH} &&
|
||||
${CMAKE_COMMAND} -E chdir ${JSON_INSTALL_PATH} ${CMAKE_COMMAND} -E tar xf "${JSON_DOWNLOAD_PATH}/include.zip" --format=zip
|
||||
UPDATE_COMMAND ""
|
||||
)
|
||||
|
||||
ExternalProject_Get_Property(third_party_json SOURCE_DIR)
|
||||
ExternalProject_Get_Property(third_party_json BINARY_DIR)
|
||||
set(JSON_INCLUDE_DIR ${SOURCE_DIR}/include)
|
||||
add_library(json INTERFACE)
|
||||
target_include_directories(json INTERFACE ${JSON_INCLUDE_DIR})
|
||||
add_dependencies(json third_party_json)
|
||||
endif()
|
||||
35
csrc/cmake/third_party/makeself-fetch.cmake
vendored
Normal file
35
csrc/cmake/third_party/makeself-fetch.cmake
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
# -----------------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2025 Huawei Technologies Co., Ltd.
|
||||
# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
|
||||
# CANN Open Software License Agreement Version 2.0 (the "License").
|
||||
# Please refer to the License for details. You may not use this file except in compliance with the License.
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See LICENSE in the root of the software repository for the full text of the License.
|
||||
# -----------------------------------------------------------------------------------------------------------
|
||||
|
||||
set(MAKESELF_NAME "makeself")
|
||||
set(MAKESELF_PATH ${CANN_3RD_LIB_PATH}/makeself)
|
||||
|
||||
# 默认配置的makeself还是不存在则下载
|
||||
if (NOT EXISTS "${MAKESELF_PATH}/makeself-header.sh" OR NOT EXISTS "${MAKESELF_PATH}/makeself.sh")
|
||||
set(MAKESELF_URL "https://gitcode.com/cann-src-third-party/makeself/releases/download/release-2.5.0-patch1.0/makeself-release-2.5.0-patch1.tar.gz")
|
||||
message(STATUS "Downloading ${MAKESELF_NAME} from ${MAKESELF_URL}")
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
${MAKESELF_NAME}
|
||||
URL ${MAKESELF_URL}
|
||||
URL_HASH SHA256=bfa730a5763cdb267904a130e02b2e48e464986909c0733ff1c96495f620369a
|
||||
SOURCE_DIR "${MAKESELF_PATH}" # 直接解压到此目录
|
||||
)
|
||||
FetchContent_MakeAvailable(${MAKESELF_NAME})
|
||||
execute_process(
|
||||
COMMAND chmod 700 "${CMAKE_BINARY_DIR}/makeself/makeself.sh"
|
||||
COMMAND chmod 700 "${CMAKE_BINARY_DIR}/makeself/makeself-header.sh"
|
||||
-E env
|
||||
CMAKE_TLS_VERIFY=0
|
||||
RESULT_VARIABLE CHMOD_RESULT
|
||||
ERROR_VARIABLE CHMOD_ERROR
|
||||
)
|
||||
endif()
|
||||
43
csrc/cmake/third_party/protobuf.cmake
vendored
Normal file
43
csrc/cmake/third_party/protobuf.cmake
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# -----------------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2025 Huawei Technologies Co., Ltd.
|
||||
# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
|
||||
# CANN Open Software License Agreement Version 2.0 (the "License").
|
||||
# Please refer to the License for details. You may not use this file except in compliance with the License.
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See LICENSE in the root of the software repository for the full text of the License.
|
||||
# -----------------------------------------------------------------------------------------------------------
|
||||
set(_protobuf_url "")
|
||||
if(CANN_PKG_SERVER)
|
||||
set(_protobuf_url "${CANN_PKG_SERVER}/libs/protobuf/v25.1.tar.gz")
|
||||
endif()
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(external_protobuf
|
||||
URL ${_protobuf_url}
|
||||
https://gitcode.com/cann-src-third-party/protobuf/releases/download/v25.1/protobuf-25.1.tar.gz
|
||||
DOWNLOAD_DIR download/protobuf
|
||||
PREFIX third_party
|
||||
SOURCE_SUBDIR cmake
|
||||
CMAKE_CACHE_ARGS
|
||||
-DProtobuf_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
|
||||
-Dprotobuf_BUILD_TESTS:BOOL=OFF
|
||||
-Dprotobuf_BUILD_EXAMPLES:BOOL=OFF
|
||||
-Dprotobuf_BUILD_SHARED_LIBS:BOOL=OFF
|
||||
-DProtobuf_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
ExternalProject_Get_Property(external_protobuf SOURCE_DIR)
|
||||
ExternalProject_Get_Property(external_protobuf BINARY_DIR)
|
||||
|
||||
set(Protobuf_INCLUDE ${SOURCE_DIR}/src)
|
||||
set(Protobuf_PATH ${BINARY_DIR})
|
||||
set(Protobuf_PROTOC_EXECUTABLE ${Protobuf_PATH}/protoc)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${Protobuf_PROTOC_EXECUTABLE}
|
||||
DEPENDS external_protobuf
|
||||
)
|
||||
add_custom_target(
|
||||
protoc ALL DEPENDS ${Protobuf_PROTOC_EXECUTABLE}
|
||||
)
|
||||
108
csrc/cmake/third_party/secure_c.cmake
vendored
Normal file
108
csrc/cmake/third_party/secure_c.cmake
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
# -----------------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2025 Huawei Technologies Co., Ltd.
|
||||
# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
|
||||
# CANN Open Software License Agreement Version 2.0 (the "License").
|
||||
# Please refer to the License for details. You may not use this file except in compliance with the License.
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See LICENSE in the root of the software repository for the full text of the License.
|
||||
# -----------------------------------------------------------------------------------------------------------
|
||||
set(_secure_c_url "")
|
||||
if(CANN_PKG_SERVER)
|
||||
set(_secure_c_url "${CANN_PKG_SERVER}/libs/securec/v1.1.10.tar.gz")
|
||||
endif()
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(secure_c
|
||||
URL ${_secure_c_url}
|
||||
https://gitee.com/openeuler/libboundscheck/repository/archive/v1.1.16.tar.gz
|
||||
URL_MD5 ae4865cec1bfb52f7dca03f5c05ac98a
|
||||
DOWNLOAD_DIR download/secure_c
|
||||
PREFIX third_party
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
ExternalProject_Get_Property(secure_c SOURCE_DIR)
|
||||
ExternalProject_Get_Property(secure_c BINARY_DIR)
|
||||
|
||||
set(SEC_C_SRCS
|
||||
${SOURCE_DIR}/src/fscanf_s.c
|
||||
${SOURCE_DIR}/src/fwscanf_s.c
|
||||
${SOURCE_DIR}/src/gets_s.c
|
||||
${SOURCE_DIR}/src/input.inl
|
||||
${SOURCE_DIR}/src/memcpy_s.c
|
||||
${SOURCE_DIR}/src/memmove_s.c
|
||||
${SOURCE_DIR}/src/memset_s.c
|
||||
${SOURCE_DIR}/src/output.inl
|
||||
${SOURCE_DIR}/src/scanf_s.c
|
||||
${SOURCE_DIR}/src/secinput.h
|
||||
${SOURCE_DIR}/src/securecutil.c
|
||||
${SOURCE_DIR}/src/securecutil.h
|
||||
${SOURCE_DIR}/src/secureinput_a.c
|
||||
${SOURCE_DIR}/src/secureinput_w.c
|
||||
${SOURCE_DIR}/src/secureprintoutput_a.c
|
||||
${SOURCE_DIR}/src/secureprintoutput.h
|
||||
${SOURCE_DIR}/src/secureprintoutput_w.c
|
||||
${SOURCE_DIR}/src/snprintf_s.c
|
||||
${SOURCE_DIR}/src/sprintf_s.c
|
||||
${SOURCE_DIR}/src/sscanf_s.c
|
||||
${SOURCE_DIR}/src/strcat_s.c
|
||||
${SOURCE_DIR}/src/strcpy_s.c
|
||||
${SOURCE_DIR}/src/strncat_s.c
|
||||
${SOURCE_DIR}/src/strncpy_s.c
|
||||
${SOURCE_DIR}/src/strtok_s.c
|
||||
${SOURCE_DIR}/src/swprintf_s.c
|
||||
${SOURCE_DIR}/src/swscanf_s.c
|
||||
${SOURCE_DIR}/src/vfscanf_s.c
|
||||
${SOURCE_DIR}/src/vfwscanf_s.c
|
||||
${SOURCE_DIR}/src/vscanf_s.c
|
||||
${SOURCE_DIR}/src/vsnprintf_s.c
|
||||
${SOURCE_DIR}/src/vsprintf_s.c
|
||||
${SOURCE_DIR}/src/vsscanf_s.c
|
||||
${SOURCE_DIR}/src/vswprintf_s.c
|
||||
${SOURCE_DIR}/src/vswscanf_s.c
|
||||
${SOURCE_DIR}/src/vwscanf_s.c
|
||||
${SOURCE_DIR}/src/wcscat_s.c
|
||||
${SOURCE_DIR}/src/wcscpy_s.c
|
||||
${SOURCE_DIR}/src/wcsncat_s.c
|
||||
${SOURCE_DIR}/src/wcsncpy_s.c
|
||||
${SOURCE_DIR}/src/wcstok_s.c
|
||||
${SOURCE_DIR}/src/wmemcpy_s.c
|
||||
${SOURCE_DIR}/src/wmemmove_s.c
|
||||
${SOURCE_DIR}/src/wscanf_s.c
|
||||
)
|
||||
|
||||
add_library(c_sec SHARED ${SEC_C_SRCS})
|
||||
|
||||
add_dependencies(c_sec secure_c)
|
||||
|
||||
set_source_files_properties(
|
||||
${SEC_C_SRCS}
|
||||
PROPERTIES
|
||||
GENERATED TRUE
|
||||
)
|
||||
|
||||
target_include_directories(c_sec
|
||||
PUBLIC
|
||||
"${SOURCE_DIR}/include"
|
||||
)
|
||||
|
||||
set(C_SEC_INCLUDE ${SOURCE_DIR}/include)
|
||||
|
||||
target_compile_options(c_sec
|
||||
PRIVATE
|
||||
-fstack-protector-strong -fPIC -Wall -D_FORTIFY_SOURCE=2 -O2
|
||||
)
|
||||
|
||||
set_target_properties(c_sec
|
||||
PROPERTIES
|
||||
LINKER_LANGUAGE C
|
||||
LIBRARY_OUTPUT_DIRECTORY ${BINARY_DIR}
|
||||
)
|
||||
|
||||
cann_install(
|
||||
TARGET c_sec
|
||||
FILES $<TARGET_FILE:c_sec>
|
||||
DESTINATION "${CANN_ROOT}/lib"
|
||||
)
|
||||
Reference in New Issue
Block a user