| @@ -19,13 +19,30 @@ endif () | |||
| option(ENABLE_OPEN_SRC "Enable graphengine compile in opensource." FALSE) | |||
| if (DEFINED ENV{ASCEND_CUSTOM_PATH}) | |||
| set(ASCEND_OPENSDK_DIR $ENV{ASCEND_CUSTOM_PATH}/opensdk/opensdk) | |||
| set(CMAKE_PREFIX_PATH | |||
| ${ASCEND_OPENSDK_DIR}/cmake | |||
| ${ASCEND_OPENSDK_DIR}/c_sec | |||
| ${ASCEND_OPENSDK_DIR}/json | |||
| ${ASCEND_OPENSDK_DIR}/openssl | |||
| ${ASCEND_OPENSDK_DIR}/zlib | |||
| ${ASCEND_OPENSDK_DIR}/protoc | |||
| ${ASCEND_OPENSDK_DIR}/grpc | |||
| ${ASCEND_OPENSDK_DIR}/protobuf_static | |||
| ${ASCEND_OPENSDK_DIR}/ascend_protobuf | |||
| ${ASCEND_OPENSDK_DIR}/ascend_protobuf_static | |||
| ${ASCEND_OPENSDK_DIR}/gtest) | |||
| set(CMAKE_MODULE_PATH ${ASCEND_OPENSDK_DIR}/cmake/modules) | |||
| endif() | |||
| if (ENABLE_OPEN_SRC) | |||
| set(HI_PYTHON python3) | |||
| include(cmake/external_libs/protobuf_shared.cmake) | |||
| include(cmake/external_libs/protoc.cmake) | |||
| include(cmake/external_libs/securec.cmake) | |||
| include(cmake/external_libs/json.cmake) | |||
| include(cmake/function.cmake) | |||
| #find_package(ascend_protobuf_shared MODULE) | |||
| #find_package(protoc MODULE) | |||
| #find_package(securec MODULE) | |||
| #find_package(json MODULE) | |||
| include(cmake/FindModule.cmake) | |||
| include(cmake/intf_pub_linux.cmake) | |||
| @@ -43,8 +60,8 @@ if (ENABLE_OPEN_SRC) | |||
| message(FATAL_ERROR "Running on a unsupported architecture: ${SYSTEM_TYPE}, build terminated") | |||
| endif() | |||
| set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH}) | |||
| find_module(slog libalog.so ${GE_LIB_PATH}) | |||
| find_module(static_mmpa libmmpa.a ${GE_LIB_PATH}) | |||
| find_package(slog REQUIRED CONFIG) | |||
| find_package(mmpa REQUIRED CONFIG) | |||
| elseif(ENABLE_GE_COV OR ENABLE_GE_UT) | |||
| message(STATUS "Runing on llt mode, no need to depend other component") | |||
| elseif(ENABLE_PARSER_UT OR ENABLE_PARSER_COV OR ENABLE_PARSER_ST) | |||
| @@ -58,8 +75,8 @@ if (ENABLE_OPEN_SRC) | |||
| endif() | |||
| set(ASCEND_COMPILER_DIR ${ASCEND_DIR}/compiler/lib64) | |||
| find_module(slog libalog.so ${ASCEND_COMPILER_DIR}) | |||
| find_module(static_mmpa libmmpa.a ${ASCEND_COMPILER_DIR}) | |||
| find_package(slog REQUIRED CONFIG) | |||
| find_package(mmpa REQUIRED CONFIG) | |||
| endif() | |||
| if (NOT DEFINED METADEF_DIR) | |||
| @@ -140,7 +157,7 @@ target_include_directories(parser_graph_library_proto_obj PRIVATE | |||
| target_compile_definitions(parser_graph_library_proto_obj PRIVATE | |||
| google=ascend_private | |||
| ) | |||
| target_link_libraries(parser_graph_library_proto_obj PRIVATE ascend_protobuf $<BUILD_INTERFACE:intf_pub>) | |||
| target_link_libraries(parser_graph_library_proto_obj PRIVATE ascend_protobuf intf_pub) | |||
| target_compile_options(parser_graph_library_proto_obj PRIVATE | |||
| $<$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>:-O2 -fPIC -Wextra -Wfloat-equal> | |||
| $<$<OR:$<STREQUAL:${PRODUCT_SIDE},host>,$<STREQUAL:${ENABLE_OPEN_SRC},True>>:-fexceptions> | |||
| @@ -161,7 +178,7 @@ target_include_directories(parser_tensorflow_protos_obj PRIVATE | |||
| target_compile_definitions(parser_tensorflow_protos_obj PRIVATE | |||
| google=ascend_private | |||
| ) | |||
| target_link_libraries(parser_tensorflow_protos_obj PRIVATE ascend_protobuf $<BUILD_INTERFACE:intf_pub>) | |||
| target_link_libraries(parser_tensorflow_protos_obj PRIVATE ascend_protobuf intf_pub) | |||
| target_compile_options(parser_tensorflow_protos_obj PRIVATE | |||
| $<$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>:-O2 -fPIC -Wextra -Wfloat-equal> | |||
| $<$<OR:$<STREQUAL:${PRODUCT_SIDE},host>,$<STREQUAL:${ENABLE_OPEN_SRC},True>>:-fexceptions> | |||
| @@ -182,7 +199,7 @@ target_include_directories(parser_onnx_protos_obj PRIVATE | |||
| target_compile_definitions(parser_onnx_protos_obj PRIVATE | |||
| google=ascend_private | |||
| ) | |||
| target_link_libraries(parser_onnx_protos_obj PRIVATE ascend_protobuf $<BUILD_INTERFACE:intf_pub>) | |||
| target_link_libraries(parser_onnx_protos_obj PRIVATE ascend_protobuf intf_pub) | |||
| target_compile_options(parser_onnx_protos_obj PRIVATE | |||
| $<$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>:-O2 -fPIC -Wextra -Wfloat-equal> | |||
| $<$<OR:$<STREQUAL:${PRODUCT_SIDE},host>,$<STREQUAL:${ENABLE_OPEN_SRC},True>>:-fexceptions> | |||
| @@ -140,7 +140,11 @@ build_parser() | |||
| CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GITEE=ON" | |||
| fi | |||
| CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_OPEN_SRC=True -DCMAKE_INSTALL_PREFIX=${OUTPUT_PATH}" | |||
| CMAKE_ARGS="${CMAKE_ARGS} -D ENABLE_OPEN_SRC=True \ | |||
| -D CMAKE_INSTALL_PREFIX=${OUTPUT_PATH} \ | |||
| -D ASCEND_OPENSDK_DIR=${ASCEND_CUSTOM_PATH}/opensdk/opensdk \ | |||
| -D protoc_ROOT=${ASCEND_OPENSDK_DIR}/protoc \ | |||
| -D ascend_protobuf_shared_ROOT=${ASCEND_OPENSDK_DIR}/ascend_protobuf" | |||
| echo "${CMAKE_ARGS}" | |||
| cmake ${CMAKE_ARGS} .. | |||
| if [ 0 -ne $? ] | |||
| @@ -38,56 +38,6 @@ set(PROTOC_PKG_DIR ${CMAKE_INSTALL_PREFIX}/protoc) | |||
| set(protoc_EXECUTABLE ${PROTOC_PKG_DIR}/${CMAKE_INSTALL_BINDIR}/protoc) | |||
| function(protobuf_generate comp c_var h_var) | |||
| if(NOT ARGN) | |||
| message(SEND_ERROR "Error: protobuf_generate() called without any proto files") | |||
| return() | |||
| endif() | |||
| set(${c_var}) | |||
| set(${h_var}) | |||
| set(_add_target FALSE) | |||
| foreach(file ${ARGN}) | |||
| if("${file}" STREQUAL "TARGET") | |||
| set(_add_target TRUE) | |||
| continue() | |||
| endif() | |||
| get_filename_component(abs_file ${file} ABSOLUTE) | |||
| get_filename_component(file_name ${file} NAME_WE) | |||
| get_filename_component(file_dir ${abs_file} PATH) | |||
| get_filename_component(parent_subdir ${file_dir} NAME) | |||
| if("${parent_subdir}" STREQUAL "proto") | |||
| set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto) | |||
| else() | |||
| set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto/${parent_subdir}) | |||
| endif() | |||
| list(APPEND ${c_var} "${proto_output_path}/${file_name}.pb.cc") | |||
| list(APPEND ${h_var} "${proto_output_path}/${file_name}.pb.h") | |||
| add_custom_command( | |||
| OUTPUT "${proto_output_path}/${file_name}.pb.cc" "${proto_output_path}/${file_name}.pb.h" | |||
| WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | |||
| COMMAND ${CMAKE_COMMAND} -E make_directory "${proto_output_path}" | |||
| COMMAND ${CMAKE_COMMAND} -E echo "generate proto cpp_out ${comp} by ${abs_file}" | |||
| COMMAND ${protoc_EXECUTABLE} -I${file_dir} --cpp_out=${proto_output_path} ${abs_file} | |||
| DEPENDS protoc_build ${abs_file} | |||
| COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM ) | |||
| endforeach() | |||
| if(_add_target) | |||
| add_custom_target( | |||
| ${comp} DEPENDS ${${c_var}} ${${h_var}} | |||
| ) | |||
| endif() | |||
| set_source_files_properties(${${c_var}} ${${h_var}} PROPERTIES GENERATED TRUE) | |||
| set(${c_var} ${${c_var}} PARENT_SCOPE) | |||
| set(${h_var} ${${h_var}} PARENT_SCOPE) | |||
| endfunction() | |||
| function(protobuf_generate_py comp py_var) | |||
| if(NOT ARGN) | |||
| message(SEND_ERROR "Error: protobuf_generate_py() called without any proto files") | |||
| @@ -0,0 +1,49 @@ | |||
| function(protobuf_generate comp c_var h_var) | |||
| if(NOT ARGN) | |||
| message(SEND_ERROR "Error: protobuf_generate() called without any proto files") | |||
| return() | |||
| endif() | |||
| set(${c_var}) | |||
| set(${h_var}) | |||
| set(_add_target FALSE) | |||
| foreach(file ${ARGN}) | |||
| if("${file}" STREQUAL "TARGET") | |||
| set(_add_target TRUE) | |||
| continue() | |||
| endif() | |||
| get_filename_component(abs_file ${file} ABSOLUTE) | |||
| get_filename_component(file_name ${file} NAME_WE) | |||
| get_filename_component(file_dir ${abs_file} PATH) | |||
| get_filename_component(parent_subdir ${file_dir} NAME) | |||
| if("${parent_subdir}" STREQUAL "proto") | |||
| set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto) | |||
| else() | |||
| set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto/${parent_subdir}) | |||
| endif() | |||
| list(APPEND ${c_var} "${proto_output_path}/${file_name}.pb.cc") | |||
| list(APPEND ${h_var} "${proto_output_path}/${file_name}.pb.h") | |||
| add_custom_command( | |||
| OUTPUT "${proto_output_path}/${file_name}.pb.cc" "${proto_output_path}/${file_name}.pb.h" | |||
| WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | |||
| COMMAND ${CMAKE_COMMAND} -E make_directory "${proto_output_path}" | |||
| COMMAND ${CMAKE_COMMAND} -E echo "generate proto cpp_out ${comp} by ${abs_file}" | |||
| COMMAND ${protoc_EXECUTABLE} -I${file_dir} --cpp_out=${proto_output_path} ${abs_file} | |||
| DEPENDS protoc_build ${abs_file} | |||
| COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM ) | |||
| endforeach() | |||
| if(_add_target) | |||
| add_custom_target( | |||
| ${comp} DEPENDS ${${c_var}} ${${h_var}} | |||
| ) | |||
| endif() | |||
| set_source_files_properties(${${c_var}} ${${h_var}} PROPERTIES GENERATED TRUE) | |||
| set(${c_var} ${${c_var}} PARENT_SCOPE) | |||
| set(${h_var} ${${h_var}} PARENT_SCOPE) | |||
| endfunction() | |||
| @@ -1 +1 @@ | |||
| Subproject commit 599fbd9d7f9509b7673af90e186817b5a75ad547 | |||
| Subproject commit ed43bd5a956c70e85e6f9d0a8f2277691a5ce4a2 | |||