Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

Commit fec4327

Browse files
mdouaihyyurishkuro
authored andcommitted
Upgrade to OpenTracing 1.5.0; Support build on Windows (#115)
* Fix Build Under Windows ( #112) * Move to OpenTracing 1.5.0 that builds under Windows * Change link of OpenTracing to dynamic. With Static linking of OpenTracing, we end up with multi definition of OT Symbols. This is not acceptable especially for the OT Global Tracer * Fix OS specificities ** Networking API ** Windows headers * Fix some tests with random behavior that failed on Windows * Fix some MSVC specific compilation * Add appveyor build file. * Update Hunter version. Signed-off-by: FR-MUREX-COM\mchaikhadouaihy <[email protected]> * Enable compilation against Windows 8.1 SDK The definition of `inet_ntop` for older Windows SDK versions, such as 8.1, does not declare the `pAddr` argument as `const`. Because of this we need to cast away the constness first. Despite the argument not being declared as const the function should not be touching it, hence this should be safe. Signed-off-by: Fredrik Appelros <[email protected]> * Fix nlohmann_json dependency The `package_deps` list is used to iterate over all dependencies in the package config file and run `find_package` on each of them. This should be using the package name (`nlohmann_json`) and not the target name (`nlohmann_json::nlohmann_json`). Signed-off-by: Fredrik Appelros <[email protected]> * Avoid redefinition of NOMINMAX Only define `NOMINMAX` if it has not already been defined to avoid redefinition warnings. Signed-off-by: Fredrik Appelros <[email protected]> * Add Appveyor badge and debug builds. Signed-off-by: FR-MUREX-COM\mchaikhadouaihy <[email protected]> * Add TODO with the related issues for Tracer.testTracer test. Signed-off-by: FR-MUREX-COM\mchaikhadouaihy <[email protected]>
1 parent a472fba commit fec4327

Some content is hidden

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

63 files changed

+799
-114
lines changed

.appveyor.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: '{build}'
2+
3+
image: Visual Studio 2017
4+
5+
init:
6+
- cmd: git config --global core.autocrlf true
7+
8+
platform:
9+
- x64
10+
11+
configuration:
12+
- Debug
13+
14+
before_build:
15+
- cmake -H. -Bbuild -A%PLATFORM% -DBUILD_TESTING=ON
16+
17+
build:
18+
project: build\jaegertracing.sln
19+
parallel: true
20+
verbosity: normal
21+
22+
test_script:
23+
- ps: |
24+
cd build
25+
ctest -V -C $env:configuration --timeout 600 --output-on-failure

CMakeLists.txt

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ set(HUNTER_CONFIGURATION_TYPES "Release;Debug" CACHE STRING
1111

1212
include(CMakeDependentOption)
1313
include(HunterGate)
14+
15+
option(HUNTER_BUILD_SHARED_LIBS "Build Shared Library" ON)
16+
1417
HunterGate(
15-
URL "https://github.com/ruslo/hunter/archive/v0.23.5.tar.gz"
16-
SHA1 "2c5c6fc1cf609d0856695d60f147594daf4e6b3e"
18+
URL "https://github.com/ruslo/hunter/archive/v0.23.201.tar.gz"
19+
SHA1 "29f10683f10c7b35e1f599d71542af0c2daa6a01"
1720
)
1821

1922
project(jaegertracing VERSION 0.5.0)
@@ -32,6 +35,14 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
3235
list(APPEND cxx_flags -Wno-unused-private-field)
3336
endif()
3437

38+
if(MSVC)
39+
add_definitions(-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING)
40+
41+
# https://studiofreya.com/2018/01/06/visual-studio-2017-with-cpp17-and-boost/
42+
add_definitions(-DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE)
43+
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
44+
endif()
45+
3546
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
3647

3748
if(HUNTER_ENABLED)
@@ -56,16 +67,24 @@ else()
5667
endif()
5768
list(APPEND package_deps thrift)
5869

70+
5971
hunter_add_package(opentracing-cpp)
6072
# Not `${hunter_config}` because OpenTracing provides its own
6173
# OpenTracingConfig.cmake file
6274
find_package(OpenTracing CONFIG REQUIRED)
63-
list(APPEND LIBS OpenTracing::opentracing-static)
75+
# Under Windows, link dynamically with OpenTracing
76+
if (WIN32)
77+
list(APPEND LIBS OpenTracing::opentracing)
78+
set(OPENTRACING_LIB OpenTracing::opentracing)
79+
else()
80+
list(APPEND LIBS OpenTracing::opentracing-static)
81+
set(OPENTRACING_LIB OpenTracing::opentracing-static)
82+
endif()
6483
list(APPEND package_deps OpenTracing)
6584

6685
hunter_add_package(nlohmann_json)
6786
find_package(nlohmann_json CONFIG REQUIRED)
68-
list(APPEND LIBS nlohmann_json)
87+
list(APPEND LIBS nlohmann_json::nlohmann_json)
6988
list(APPEND package_deps nlohmann_json)
7089

7190
option(JAEGERTRACING_BUILD_EXAMPLES "Build examples" ON)
@@ -193,7 +212,8 @@ set(SRC
193212
src/jaegertracing/utils/HexParsing.cpp
194213
src/jaegertracing/utils/RateLimiter.cpp
195214
src/jaegertracing/utils/UDPClient.cpp
196-
src/jaegertracing/utils/YAML.cpp)
215+
src/jaegertracing/utils/YAML.cpp
216+
src/jaegertracing/ThriftMethods.cpp)
197217

198218
if(JAEGERTRACING_BUILD_CROSSDOCK)
199219
list(APPEND SRC
@@ -210,12 +230,31 @@ function(add_lib_deps lib)
210230
target_compile_options(${lib} PUBLIC ${cxx_flags})
211231
endfunction()
212232

233+
function(update_path_for_test atest)
234+
if(WIN32)
235+
# If dependent library is a DLL we have to add location of DLL to PATH
236+
set(new_path "")
237+
238+
foreach(LIB OpenTracing::opentracing yaml-cpp::yaml-cpp GTest::main)
239+
list(APPEND new_path $<TARGET_FILE_DIR:${LIB}>)
240+
endforeach()
241+
list(APPEND new_path $ENV{PATH})
242+
string(REPLACE ";" "\\;" new_path "${new_path}")
243+
244+
set_tests_properties(${atest} PROPERTIES ENVIRONMENT "PATH=${new_path}")
245+
endif()
246+
endfunction()
247+
213248
option(JAEGERTRACING_PLUGIN "Build dynamic plugin" OFF)
214249
cmake_dependent_option(BUILD_SHARED_LIBS "Build shared libraries" ON
215250
"NOT JAEGERTRACING_PLUGIN" OFF)
216251

217252
if(BUILD_SHARED_LIBS)
218253
add_library(jaegertracing SHARED ${SRC})
254+
if (WIN32)
255+
target_compile_definitions(jaegertracing PUBLIC YAML_CPP_DLL)
256+
target_link_libraries(jaegertracing PUBLIC Iphlpapi Ws2_32)
257+
endif()
219258
add_lib_deps(jaegertracing)
220259
set_target_properties(jaegertracing PROPERTIES
221260
VERSION ${PROJECT_VERSION}
@@ -224,6 +263,7 @@ if(BUILD_SHARED_LIBS)
224263
list(APPEND JAEGERTRACING_LIBS jaegertracing)
225264
endif()
226265

266+
227267
if(JAEGERTRACING_PLUGIN)
228268
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/export.map
229269
"{ global: OpenTracingMakeTracerFactory; local: *; };")
@@ -236,9 +276,16 @@ if(JAEGERTRACING_PLUGIN)
236276
endif()
237277

238278
add_library(jaegertracing-static STATIC ${SRC})
239-
set_target_properties(jaegertracing-static PROPERTIES
240-
OUTPUT_NAME jaegertracing)
279+
if (NOT WIN32)
280+
#on windows, the shared library generate also a .lib file
281+
set_target_properties(jaegertracing-static PROPERTIES OUTPUT_NAME jaegertracing)
282+
endif()
283+
241284
add_lib_deps(jaegertracing-static)
285+
if (WIN32)
286+
target_link_libraries(jaegertracing-static PUBLIC Iphlpapi Ws2_32)
287+
endif()
288+
242289
if(NOT JAEGERTRACING_LIB)
243290
set(JAEGERTRACING_LIB jaegertracing-static)
244291
endif()
@@ -290,19 +337,23 @@ if(BUILD_TESTING)
290337
src/jaegertracing/utils/RateLimiterTest.cpp
291338
src/jaegertracing/utils/UDPClientTest.cpp)
292339
target_link_libraries(
293-
UnitTest PRIVATE testutils GTest::main)
340+
UnitTest PRIVATE testutils GTest::main ${JAEGERTRACING_LIB})
294341
add_test(NAME UnitTest COMMAND UnitTest)
295342

343+
update_path_for_test(UnitTest)
344+
296345
if(TARGET jaegertracing)
297346
add_executable(DynamicallyLoadTracerTest
298347
src/jaegertracing/DynamicallyLoadTracerTest.cpp)
348+
299349
target_include_directories(DynamicallyLoadTracerTest PUBLIC
300350
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
301351
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src>)
302352
target_link_libraries(
303-
DynamicallyLoadTracerTest OpenTracing::opentracing-static GTest::main)
353+
DynamicallyLoadTracerTest ${OPENTRACING_LIB} GTest::main)
304354
add_test(NAME DynamicallyLoadTracerTest
305355
COMMAND DynamicallyLoadTracerTest $<TARGET_FILE:jaegertracing>)
356+
update_path_for_test(DynamicallyLoadTracerTest)
306357
if(JAEGERTRACING_COVERAGE)
307358
setup_target_for_coverage(NAME UnitTestCoverage
308359
EXECUTABLE UnitTest
@@ -311,6 +362,8 @@ if(BUILD_TESTING)
311362
endif()
312363
endif()
313364

365+
366+
314367
if(JAEGERTRACING_BUILD_CROSSDOCK)
315368
set(CROSSDOCK_SRC crossdock/Server.cpp)
316369
add_executable(crossdock ${CROSSDOCK_SRC})

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov] [![OpenTracing 1.0 Enabled][ot-img]][ot-url]
1+
[![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov] [![Appveyor Build][appveyor]][appveyor] [![OpenTracing 1.0 Enabled][ot-img]][ot-url]
22

33
# jaeger-client-cpp
44
C++ OpenTracing binding for [Jaeger](https://www.jaegertracing.io/)
@@ -81,6 +81,7 @@ sampler:
8181

8282
[ci-img]: https://travis-ci.org/jaegertracing/jaeger-client-cpp.svg?branch=master
8383
[ci]: https://travis-ci.org/jaegertracing/jaeger-client-cpp
84+
[appveyor]: https://ci.appveyor.com/api/projects/status/bu992qd3y9bpwe7u?svg=true
8485
[cov-img]: https://codecov.io/gh/jaegertracing/jaeger-client-cpp/branch/master/graph/badge.svg
8586
[cov]: https://codecov.io/gh/jaegertracing/jaeger-client-cpp
8687
[ot-img]: https://img.shields.io/badge/OpenTracing--1.0-enabled-blue.svg

cmake/toolchain.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
22
set(CMAKE_CXX_STANDARD 11)
33
set(CMAKE_CXX_EXTENSIONS OFF)
44
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
5+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

src/jaegertracing/Compilers.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2019 Uber Technologies, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef JAEGERTRACING_COMPILERS_H
18+
#define JAEGERTRACING_COMPILERS_H
19+
20+
#ifdef _MSC_VER
21+
22+
#pragma warning(push)
23+
#pragma warning(disable : 4251)
24+
#pragma warning(disable : 4275)
25+
26+
// Define NOMINMAX to inhibit definition of Macros min(a,b) and max(a,b) in
27+
// windows.h
28+
#ifndef NOMINMAX
29+
#define NOMINMAX
30+
#endif
31+
32+
#endif // _MSC_VER
33+
34+
#endif // JAEGERTRACING_COMPILERS_H

src/jaegertracing/Config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef JAEGERTRACING_CONFIG_H
1818
#define JAEGERTRACING_CONFIG_H
1919

20+
#include "jaegertracing/Compilers.h"
2021
#include "jaegertracing/Constants.h"
2122
#include "jaegertracing/baggage/RestrictionsConfig.h"
2223
#include "jaegertracing/propagation/HeadersConfig.h"

src/jaegertracing/DynamicLoad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ static int makeTracerFactory(const char* opentracingVersion,
5050
return 0;
5151
}
5252

53-
OPENTRACING_DECLARE_IMPL_FACTORY(makeTracerFactory)
53+
OPENTRACING_DECLARE_IMPL_FACTORY(makeTracerFactory)

src/jaegertracing/LogRecord.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef JAEGERTRACING_LOGRECORD_H
1818
#define JAEGERTRACING_LOGRECORD_H
1919

20+
#include "jaegertracing/Compilers.h"
2021
#include "jaegertracing/Tag.h"
2122
#include "jaegertracing/thrift-gen/jaeger_types.h"
2223
#include <algorithm>

src/jaegertracing/Logging.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <memory>
2121
#include <string>
2222

23+
#include "jaegertracing/Compilers.h"
24+
2325
namespace jaegertracing {
2426
namespace logging {
2527

src/jaegertracing/Reference.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include <opentracing/propagation.h>
2424

25+
#include "jaegertracing/Compilers.h"
2526
#include "jaegertracing/SpanContext.h"
2627
#include "jaegertracing/thrift-gen/jaeger_types.h"
2728

0 commit comments

Comments
 (0)