Optimize download&compilation of opentracing (#3276)

* opentracing runable

Signed-off-by: yangxuan <xuan.yang@zilliz.com>

* optimize opentracing

Signed-off-by: yangxuan <xuan.yang@zilliz.com>

* rm opentracing from Thirdpartypackages.cmake

Signed-off-by: yangxuan <xuan.yang@zilliz.com>

* rm dup links

Signed-off-by: yangxuan <xuan.yang@zilliz.com>

* fit unittest cann't compile bug

Signed-off-by: yangxuan <xuan.yang@zilliz.com>

* fix format

Signed-off-by: yangxuan <xuan.yang@zilliz.com>

Co-authored-by: yangxuan <xuan.yang@zilliz.com>
pull/3294/head
XuanYang-cn 2020-08-17 15:23:54 +08:00 committed by GitHub
parent ddd4c42b09
commit 317ec86d31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 79 additions and 69 deletions

View File

@ -16,7 +16,6 @@ set(MILVUS_THIRDPARTY_DEPENDENCIES
SQLite SQLite
libunwind libunwind
gperftools gperftools
Opentracing
fiu fiu
AWS AWS
oatpp) oatpp)
@ -41,8 +40,6 @@ macro(build_dependency DEPENDENCY_NAME)
build_libunwind() build_libunwind()
elseif ("${DEPENDENCY_NAME}" STREQUAL "gperftools") elseif ("${DEPENDENCY_NAME}" STREQUAL "gperftools")
build_gperftools() build_gperftools()
elseif ("${DEPENDENCY_NAME}" STREQUAL "Opentracing")
build_opentracing()
elseif ("${DEPENDENCY_NAME}" STREQUAL "fiu") elseif ("${DEPENDENCY_NAME}" STREQUAL "fiu")
build_fiu() build_fiu()
elseif ("${DEPENDENCY_NAME}" STREQUAL "oatpp") elseif ("${DEPENDENCY_NAME}" STREQUAL "oatpp")
@ -253,13 +250,6 @@ else ()
"https://github.com/gperftools/gperftools/releases/download/gperftools-${GPERFTOOLS_VERSION}/gperftools-${GPERFTOOLS_VERSION}.tar.gz") "https://github.com/gperftools/gperftools/releases/download/gperftools-${GPERFTOOLS_VERSION}/gperftools-${GPERFTOOLS_VERSION}.tar.gz")
endif () endif ()
if (DEFINED ENV{MILVUS_OPENTRACING_URL})
set(OPENTRACING_SOURCE_URL "$ENV{MILVUS_OPENTRACING_URL}")
else ()
set(OPENTRACING_SOURCE_URL "https://github.com/opentracing/opentracing-cpp/archive/${OPENTRACING_VERSION}.tar.gz"
"https://gitee.com/quicksilver/opentracing-cpp/repository/archive/${OPENTRACING_VERSION}.zip")
endif ()
if (DEFINED ENV{MILVUS_FIU_URL}) if (DEFINED ENV{MILVUS_FIU_URL})
set(FIU_SOURCE_URL "$ENV{MILVUS_FIU_URL}") set(FIU_SOURCE_URL "$ENV{MILVUS_FIU_URL}")
else () else ()
@ -564,58 +554,6 @@ if (MILVUS_WITH_GPERFTOOLS)
link_directories(SYSTEM ${GPERFTOOLS_PREFIX}/lib) link_directories(SYSTEM ${GPERFTOOLS_PREFIX}/lib)
endif () endif ()
# ----------------------------------------------------------------------
# opentracing
macro(build_opentracing)
message(STATUS "Building OPENTRACING-${OPENTRACING_VERSION} from source")
set(OPENTRACING_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/opentracing_ep-prefix/src/opentracing_ep")
set(OPENTRACING_STATIC_LIB "${OPENTRACING_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}opentracing${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(OPENTRACING_MOCK_TRACER_STATIC_LIB "${OPENTRACING_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}opentracing_mocktracer${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(OPENTRACING_INCLUDE_DIR "${OPENTRACING_PREFIX}/include")
set(OPENTRACING_CMAKE_ARGS
${EP_COMMON_CMAKE_ARGS}
"-DCMAKE_INSTALL_PREFIX=${OPENTRACING_PREFIX}"
-DBUILD_SHARED_LIBS=OFF)
ExternalProject_Add(opentracing_ep
URL
${OPENTRACING_SOURCE_URL}
${EP_LOG_OPTIONS}
URL_MD5
"e598ba4b81ae8e1ceed8cd8bbf86f2fd"
CMAKE_ARGS
${OPENTRACING_CMAKE_ARGS}
BUILD_COMMAND
${MAKE}
${MAKE_BUILD_ARGS}
BUILD_BYPRODUCTS
${OPENTRACING_STATIC_LIB}
${OPENTRACING_MOCK_TRACER_STATIC_LIB}
)
file(MAKE_DIRECTORY "${OPENTRACING_INCLUDE_DIR}")
add_library(opentracing STATIC IMPORTED)
set_target_properties(opentracing
PROPERTIES IMPORTED_LOCATION "${OPENTRACING_STATIC_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${OPENTRACING_INCLUDE_DIR}")
add_library(opentracing_mocktracer STATIC IMPORTED)
set_target_properties(opentracing_mocktracer
PROPERTIES IMPORTED_LOCATION "${OPENTRACING_MOCK_TRACER_STATIC_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${OPENTRACING_INCLUDE_DIR}")
add_dependencies(opentracing opentracing_ep)
add_dependencies(opentracing_mocktracer opentracing_ep)
endmacro()
if (MILVUS_WITH_OPENTRACING)
resolve_dependency(Opentracing)
get_target_property(OPENTRACING_INCLUDE_DIR opentracing INTERFACE_INCLUDE_DIRECTORIES)
include_directories(SYSTEM ${OPENTRACING_INCLUDE_DIR})
endif ()
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# fiu # fiu
macro(build_fiu) macro(build_fiu)

View File

@ -48,11 +48,11 @@ add_subdirectory( storage )
add_subdirectory( cache ) add_subdirectory( cache )
add_subdirectory( codecs ) add_subdirectory( codecs )
add_subdirectory( segment ) add_subdirectory( segment )
add_subdirectory( tracing )
add_subdirectory( utils ) add_subdirectory( utils )
add_subdirectory( metrics ) add_subdirectory( metrics )
add_subdirectory( config ) add_subdirectory( config )
add_subdirectory( tracing )
add_subdirectory( query ) add_subdirectory( query )
add_subdirectory( db ) # target milvus_engine add_subdirectory( db ) # target milvus_engine
add_subdirectory( log ) add_subdirectory( log )
@ -62,7 +62,6 @@ set(link_lib
milvus_engine milvus_engine
config config
metrics metrics
tracing
log log
oatpp oatpp
query query

View File

@ -145,6 +145,7 @@ target_link_libraries( milvus_engine
cache cache
storage storage
codecs codecs
tracing
${THIRD_PARTY_LIBS} ${THIRD_PARTY_LIBS}
${ENGINE_LIBS} ${ENGINE_LIBS}
) )

View File

@ -15,11 +15,11 @@ aux_source_directory( ${MILVUS_ENGINE_SRC}/tracing TRACING_FILES )
add_library( tracing STATIC ${TRACING_FILES} ) add_library( tracing STATIC ${TRACING_FILES} )
set( TRACING_LIB opentracing set( TRACING_LIB opentracing::opentracing
opentracing_mocktracer opentracing::mocktracer
pthread pthread
z z
dl dl
) )
target_link_libraries( tracing ${TRACING_LIB} ) target_link_libraries( tracing PUBLIC ${TRACING_LIB} )

View File

@ -46,3 +46,8 @@ endif ()
if ( MILVUS_WITH_YAMLCPP ) if ( MILVUS_WITH_YAMLCPP )
add_subdirectory( yaml-cpp ) add_subdirectory( yaml-cpp )
endif() endif()
# ****************************** Thirdparty opentracing ***************************************
if ( MILVUS_WITH_OPENTRACING )
add_subdirectory( opentracing )
endif()

View File

@ -0,0 +1,67 @@
#-------------------------------------------------------------------------------
# Copyright (C) 2019-2020 Zilliz. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under the License.
#-------------------------------------------------------------------------------
if ( DEFINED ENV{MILVUS_OPENTRACING_URL} )
set(OPENTRACING_SOURCE_URL "$ENV{MILVUS_OPENTRACING_URL}")
else ()
set(OPENTRACING_SOURCE_URL
"https://github.com/opentracing/opentracing-cpp/archive/${OPENTRACING_VERSION}.tar.gz" )
endif ()
message(STATUS "Building OPENTRACING-${OPENTRACING_VERSION} from source")
FetchContent_Declare(
opentracing
URL ${OPENTRACING_SOURCE_URL}
URL_MD5 "e598ba4b81ae8e1ceed8cd8bbf86f2fd"
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/opentracing-src
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/opentracing-build
)
set( BUILD_SHARED_LIBS CACHE BOOL OFF FORCE)
set( ENABLE_LINTING CACHE BOOL OFF FORCE)
set( BUILD_TESTING CACHE BOOL OFF FORCE )
FetchContent_GetProperties( opentracing )
if ( NOT opentracing_POPULATED )
FetchContent_Populate( opentracing )
# Adding the following targets:
# opentracing-static
# opentracing_mocktracer-static
add_subdirectory( ${opentracing_SOURCE_DIR}
${opentracing_BINARY_DIR}
EXCLUDE_FROM_ALL )
# Opentracing-cpp CMakeLists.txt file didn't give a
# correct interface directories
target_include_directories( opentracing-static
INTERFACE $<BUILD_INTERFACE:${opentracing_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${opentracing_BINARY_DIR}/include>
$<BUILD_INTERFACE:${opentracing_SOURCE_DIR}/3rd_party/include> )
target_include_directories( opentracing_mocktracer-static
INTERFACE $<BUILD_INTERFACE:${opentracing_SOURCE_DIR}/mocktracer/include> )
# Adding the following ALIAS Targets:
# opentracing::opentracing
# opentracing::mocktracer
if ( NOT TARGET opentracing::opentracing )
add_library( opentracing::opentracing ALIAS opentracing-static )
endif()
if ( NOT TARGET opentracing::mocktracer )
add_library( opentracing::mocktracer ALIAS opentracing_mocktracer-static )
endif()
endif()
get_property( var DIRECTORY "${opentracing_SOURCE_DIR}" PROPERTY COMPILE_OPTIONS )
message( STATUS "opentracing compile options: ${var}" )

View File

@ -54,8 +54,8 @@ set( UNITTEST_LIBS sqlite
libstdc++fs.a libstdc++fs.a
pthread pthread
gfortran gfortran
opentracing opentracing::opentracing
opentracing_mocktracer opentracing::mocktracer
fiu fiu
dl dl
z z