Skip to content

Commit 11a219c

Browse files
authored
Jaeger bazel windows (#1227)
1 parent c10bc36 commit 11a219c

7 files changed

Lines changed: 205 additions & 67 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,9 @@ jobs:
341341
with:
342342
submodules: 'recursive'
343343
- name: setup
344-
run: ./ci/install_windows_bazelisk.ps1
344+
run: |
345+
./ci/setup_thrift.ps1
346+
./ci/install_windows_bazelisk.ps1
345347
- name: run tests
346348
run: ./ci/do_ci.ps1 bazel.build
347349

WORKSPACE

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ load("//bazel:repository.bzl", "opentelemetry_cpp_deps")
1919

2020
opentelemetry_cpp_deps()
2121

22+
# Load prometheus C++ dependencies.
23+
load("@com_github_jupp0r_prometheus_cpp//bazel:repositories.bzl", "prometheus_cpp_repositories")
24+
25+
prometheus_cpp_repositories()
26+
27+
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
28+
29+
bazel_skylib_workspace()
30+
2231
# Load gRPC dependencies after load.
2332
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
2433

@@ -34,37 +43,6 @@ load("@upb//bazel:workspace_deps.bzl", "upb_deps")
3443

3544
upb_deps()
3645

37-
# Load prometheus C++ dependencies.
38-
load("@com_github_jupp0r_prometheus_cpp//bazel:repositories.bzl", "prometheus_cpp_repositories")
39-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
40-
41-
http_archive(
42-
name = "rules_foreign_cc",
43-
sha256 = "69023642d5781c68911beda769f91fcbc8ca48711db935a75da7f6536b65047f",
44-
strip_prefix = "rules_foreign_cc-0.6.0",
45-
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.6.0.tar.gz",
46-
)
47-
4846
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
4947

5048
rules_foreign_cc_dependencies()
51-
52-
_ALL_CONTENT = """\
53-
filegroup(
54-
name = "all_srcs",
55-
srcs = glob(["**"]),
56-
visibility = ["//visibility:public"],
57-
)
58-
"""
59-
60-
http_archive(
61-
name = "thrift",
62-
build_file_content = _ALL_CONTENT,
63-
sha256 = "5ae1c4d16452a22eaf9d802ba7489907147c2b316ff38c9758918552fae5132c",
64-
strip_prefix = "thrift-0.14.1",
65-
urls = [
66-
"https://github.com/apache/thrift/archive/refs/tags/v0.14.1.tar.gz",
67-
],
68-
)
69-
70-
prometheus_cpp_repositories()

bazel/repository.bzl

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
22
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
3+
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
4+
5+
_ALL_CONTENT = """\
6+
filegroup(
7+
name = "all_srcs",
8+
srcs = glob(["**"]),
9+
visibility = ["//visibility:public"],
10+
)
11+
"""
312

413
def opentelemetry_cpp_deps():
514
"""Loads dependencies need to compile the opentelemetry-cpp library."""
@@ -103,3 +112,57 @@ def opentelemetry_cpp_deps():
103112
strip_prefix = "curl-7.73.0",
104113
urls = ["https://curl.haxx.se/download/curl-7.73.0.tar.gz"],
105114
)
115+
116+
# libthrift (optional)
117+
maybe(
118+
http_archive,
119+
name = "com_github_thrift",
120+
build_file_content = _ALL_CONTENT,
121+
sha256 = "5ae1c4d16452a22eaf9d802ba7489907147c2b316ff38c9758918552fae5132c",
122+
strip_prefix = "thrift-0.14.1",
123+
urls = [
124+
"https://github.com/apache/thrift/archive/refs/tags/v0.14.1.tar.gz",
125+
],
126+
)
127+
128+
# rules foreign cc
129+
maybe(
130+
http_archive,
131+
name = "rules_foreign_cc",
132+
sha256 = "69023642d5781c68911beda769f91fcbc8ca48711db935a75da7f6536b65047f",
133+
strip_prefix = "rules_foreign_cc-0.6.0",
134+
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.6.0.tar.gz",
135+
)
136+
137+
# bazel skylib
138+
maybe(
139+
http_archive,
140+
name = "bazel_skylib",
141+
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
142+
urls = [
143+
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
144+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
145+
],
146+
)
147+
148+
# boost headers from vcpkg
149+
maybe(
150+
native.new_local_repository,
151+
name = "boost_all_hdrs",
152+
build_file_content = """
153+
package(default_visibility = ["//visibility:public"])
154+
cc_library(
155+
name = "boost_all_hdrs",
156+
hdrs = glob(
157+
["include/**/*.h*"],
158+
),
159+
strip_include_prefix = "include",
160+
copts = [
161+
"-isystem include",
162+
"-fexceptions",
163+
],
164+
visibility = ["//visibility:public"],
165+
)
166+
""",
167+
path = "vcpkg/installed/x64-windows/",
168+
)

ci/do_ci.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ $action = $args[0]
55

66
$SRC_DIR=(Get-Item -Path ".\").FullName
77

8-
$BAZEL_OPTIONS="--copt=-DENABLE_METRICS_PREVIEW --copt=-DENABLE_LOGS_PREVIEW --build_tag_filters=-jaeger"
8+
$BAZEL_OPTIONS="--copt=-DENABLE_METRICS_PREVIEW --copt=-DENABLE_LOGS_PREVIEW"
99
$BAZEL_TEST_OPTIONS="$BAZEL_OPTIONS --test_output=errors"
1010

1111
if (!(test-path build)) {
@@ -22,7 +22,7 @@ $VCPKG_DIR="$SRC_DIR\vcpkg"
2222

2323
switch ($action) {
2424
"bazel.build" {
25-
bazel build --copt=-DENABLE_TEST $BAZEL_OPTIONS -- //...
25+
bazel build --copt=-DENABLE_TEST $BAZEL_OPTIONS --action_env=VCPKG_DIR=$VCPKG_DIR -- //...
2626
$exit = $LASTEXITCODE
2727
if ($exit -ne 0) {
2828
exit $exit

ci/do_ci.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ elif [[ "$1" == "bazel.benchmark" ]]; then
206206
run_benchmarks
207207
exit 0
208208
elif [[ "$1" == "bazel.macos.test" ]]; then
209-
bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_MACOS_OPTIONS //...
210-
bazel $BAZEL_STARTUP_OPTIONS test $BAZEL_MACOS_TEST_OPTIONS //...
209+
bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_MACOS_OPTIONS -- //... -//exporters/jaeger/...
210+
bazel $BAZEL_STARTUP_OPTIONS test $BAZEL_MACOS_TEST_OPTIONS -- //... -//exporters/jaeger/...
211211
exit 0
212212
elif [[ "$1" == "bazel.legacy.test" ]]; then
213213
# we uses C++ future and async() function to test the Prometheus Exporter functionality,
@@ -218,8 +218,8 @@ elif [[ "$1" == "bazel.legacy.test" ]]; then
218218
elif [[ "$1" == "bazel.noexcept" ]]; then
219219
# there are some exceptions and error handling code from the Prometheus and Jaeger Clients
220220
# that make this test always fail. ignore Prometheus and Jaeger exporters in the noexcept here.
221-
bazel $BAZEL_STARTUP_OPTIONS build --copt=-fno-exceptions $BAZEL_OPTIONS -- //... -//exporters/prometheus/... -//exporters/jaeger/...
222-
bazel $BAZEL_STARTUP_OPTIONS test --copt=-fno-exceptions $BAZEL_TEST_OPTIONS -- //... -//exporters/prometheus/... -//exporters/jaeger/...
221+
bazel $BAZEL_STARTUP_OPTIONS build --copt=-fno-exceptions --build_tag_filters=-jaeger $BAZEL_OPTIONS -- //... -//exporters/prometheus/... -//exporters/jaeger/...
222+
bazel $BAZEL_STARTUP_OPTIONS test --copt=-fno-exceptions --build_tag_filters=-jaeger $BAZEL_TEST_OPTIONS -- //... -//exporters/prometheus/... -//exporters/jaeger/...
223223
exit 0
224224
elif [[ "$1" == "bazel.asan" ]]; then
225225
bazel $BAZEL_STARTUP_OPTIONS test --config=asan $BAZEL_TEST_OPTIONS //...

ci/setup_thrift.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
$ErrorActionPreference = "Stop"
2+
trap { $host.SetShouldExit(1) }
3+
4+
# TODO: consider moving this to .gitmodules
5+
git clone --depth=1 -b 2020.04 https://github.com/Microsoft/vcpkg.git
6+
Push-Location -Path vcpkg
7+
$VCPKG_DIR=(Get-Item -Path ".\").FullName
8+
setx VCPKG_DIR (Get-Item -Path ".\").FullName
9+
./bootstrap-vcpkg.bat
10+
11+
# boost needed for thrift
12+
./vcpkg install boost-predef[core]:x64-windows boost-locale[core]:x64-windows boost-numeric-conversion[core]:x64-windows boost-scope-exit[core]:x64-windows openssl:x64-windows
13+
14+
Pop-Location

exporters/jaeger/BUILD

Lines changed: 110 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,113 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
3+
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake", "configure_make", "configure_make_variant")
4+
5+
constraint_setting(
6+
name = "incompatible_setting",
7+
)
8+
9+
constraint_value(
10+
name = "incompatible",
11+
constraint_setting = ":incompatible_setting",
12+
)
13+
14+
config_setting(
15+
name = "windows",
16+
constraint_values = [
17+
"@bazel_tools//platforms:windows",
18+
],
19+
tags = ["jaeger"],
20+
visibility = ["//visibility:private"],
21+
)
22+
23+
THRIFT_CACHE_ENTRIES = {
24+
"CMAKE_BUILD_TYPE": "Release",
25+
"BUILD_COMPILER": "OFF",
26+
"BUILD_CPP": "ON",
27+
"BUILD_LIBRARIES": "ON",
28+
"BUILD_NODEJS": "OFF",
29+
"BUILD_PYTHON": "OFF",
30+
"BUILD_JAVASCRIPT": "OFF",
31+
"BUILD_C_GLIB": "OFF",
32+
"BUILD_JAVA": "OFF",
33+
"BUILD_TESTING": "OFF",
34+
"BUILD_TUTORIALS": "OFF",
35+
"WITH_HASKELL": "OFF",
36+
}
37+
38+
THRIFT_CACHE_ENTRIES_WIN = {
39+
"CMAKE_BUILD_TYPE": "Release",
40+
"BUILD_COMPILER": "OFF",
41+
"BUILD_CPP": "ON",
42+
"BUILD_LIBRARIES": "ON",
43+
"BUILD_NODEJS": "OFF",
44+
"BUILD_PYTHON": "OFF",
45+
"BUILD_JAVASCRIPT": "OFF",
46+
"BUILD_C_GLIB": "OFF",
47+
"BUILD_JAVA": "OFF",
48+
"BUILD_TESTING": "OFF",
49+
"BUILD_TUTORIALS": "OFF",
50+
"WITH_HASKELL": "OFF",
51+
"WITH_STDTHREADS": "ON",
52+
"WITH_BOOSTTHREADS": "OFF",
53+
"WITH_BOOST_FUNCTIONAL": "OFF",
54+
"WITH_BOOST_SMART_PTR": "OFF",
55+
"BUILD_SHARED_LIBS": "OFF",
56+
"CMAKE_TOOLCHAIN_FILE": "$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake",
57+
}
458

559
cmake(
660
name = "thrift",
7-
cache_entries = {
8-
"CMAKE_BUILD_TYPE": "Release",
9-
"BUILD_COMPILER": "OFF",
10-
"BUILD_CPP": "ON",
11-
"BUILD_LIBRARIES": "ON",
12-
"BUILD_NODEJS": "OFF",
13-
"BUILD_PYTHON": "OFF",
14-
"BUILD_JAVASCRIPT": "OFF",
15-
"BUILD_C_GLIB": "OFF",
16-
"BUILD_JAVA": "OFF",
17-
"BUILD_TESTING": "OFF",
18-
"BUILD_TUTORIALS": "OFF",
19-
"WITH_HASKELL": "OFF",
20-
"CMAKE_CXX_FLAGS": "-fexceptions",
21-
},
22-
lib_source = "@thrift//:all_srcs",
23-
out_static_libs = [
24-
"libthrift.a",
25-
"libthriftnb.a",
26-
"libthriftz.a",
61+
cache_entries = select({
62+
"@bazel_tools//platforms:osx": THRIFT_CACHE_ENTRIES,
63+
"@bazel_tools//platforms:linux": THRIFT_CACHE_ENTRIES,
64+
"@bazel_tools//platforms:windows": THRIFT_CACHE_ENTRIES_WIN,
65+
}),
66+
copts = [
67+
"-Ilibs/exporters/jaeger/openssl/include",
68+
"-fexceptions",
2769
],
70+
generate_args = select({
71+
"@bazel_tools//platforms:osx": [],
72+
"@bazel_tools//platforms:linux": [],
73+
"@bazel_tools//platforms:windows": [
74+
"-G \"NMake Makefiles\"",
75+
],
76+
}),
77+
install = True,
78+
lib_source = "@com_github_thrift//:all_srcs",
79+
out_lib_dir = select({
80+
"@bazel_tools//platforms:osx": "lib",
81+
"@bazel_tools//platforms:linux": "lib",
82+
"@bazel_tools//platforms:windows": "bin",
83+
}),
84+
out_static_libs = select({
85+
"@bazel_tools//platforms:osx": [
86+
"libthrift.a",
87+
"libthriftz.a",
88+
],
89+
"@bazel_tools//platforms:linux": [
90+
"libthrift.a",
91+
"libthriftz.a",
92+
],
93+
"@bazel_tools//platforms:windows": [
94+
"thriftmd.lib",
95+
],
96+
}),
2897
tags = ["jaeger"],
29-
target_compatible_with = [
30-
"@platforms//os:linux",
31-
],
98+
visibility = ["//visibility:private"],
99+
deps = [],
32100
)
33101

102+
THRIFT_GEN_DEPS = [
103+
":thrift",
104+
"//ext/src/http/client/curl:http_client_curl",
105+
]
106+
107+
THRIFT_GEN_DEPS_WIN = THRIFT_GEN_DEPS + [
108+
"@boost_all_hdrs//:boost_all_hdrs",
109+
]
110+
34111
cc_library(
35112
name = "jaeger_thrift_gencpp",
36113
srcs = [
@@ -50,13 +127,16 @@ cc_library(
50127
"thrift-gen/zipkincore_constants.h",
51128
"thrift-gen/zipkincore_types.h",
52129
],
53-
copts = ["-fexceptions"],
130+
copts = [
131+
"-fexceptions",
132+
],
54133
strip_include_prefix = "thrift-gen",
55134
tags = ["jaeger"],
56-
deps = [
57-
":thrift",
58-
"//ext/src/http/client/curl:http_client_curl",
59-
],
135+
deps = select({
136+
"@bazel_tools//platforms:osx": THRIFT_GEN_DEPS,
137+
"@bazel_tools//platforms:linux": THRIFT_GEN_DEPS,
138+
"@bazel_tools//platforms:windows": THRIFT_GEN_DEPS_WIN,
139+
}),
60140
)
61141

62142
cc_library(
@@ -106,6 +186,7 @@ cc_library(
106186
cc_test(
107187
name = "jaeger_recordable_test",
108188
srcs = ["test/jaeger_recordable_test.cc"],
189+
copts = ["-fexceptions"],
109190
tags = [
110191
"jaeger",
111192
"test",

0 commit comments

Comments
 (0)