-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathBUILD.bazel
119 lines (107 loc) · 2.19 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
config_setting(
name = "macos",
values = {"cpu": "darwin"},
visibility = ["//visibility:private"],
)
config_setting(
name = "opt",
values = {"compilation_mode": "opt"},
visibility = ["//visibility:private"],
)
COPTS = [
"-std=c++17",
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wdeprecated",
"-Werror",
] + select({
"//:opt": [
"-Ofast",
"-flto",
],
"//conditions:default": [],
})
LINKOPTS = select({
"//:opt": [
"-O3",
"-flto",
],
"//conditions:default": [],
})
filegroup(
name = "cmake_rules",
srcs = [
"CMakeLists.txt",
] + glob([
"cmake/**/*",
]),
)
cmake(
name = "buildinfo",
cache_entries = {
"BUILDINFO_ONLY": "ON",
},
lib_source = "//:cmake_rules",
out_headers_only = True,
)
filegroup(
name = "included_headers",
srcs = glob(
["include/**/*.h"],
exclude = ["include/buildinfo.h"],
),
)
filegroup(
name = "exported_headers",
srcs = glob(["include/torrent/**/*.h"]),
)
cc_library(
name = "torrent",
srcs = glob(["src/**/*.cc"]) + ["//:included_headers"],
hdrs = ["//:exported_headers"],
copts = COPTS + ["-DEXPORT_LIBTORRENT_SYMBOLS=1"],
includes = ["include"],
linkopts = LINKOPTS + [
"-lpthread",
],
visibility = ["//visibility:public"],
deps = [
"//:buildinfo",
"@boringssl//:crypto",
"@zlib",
],
)
cc_library(
name = "test_common",
srcs = ["test/main.cc"] + glob([
"test/helpers/*.cc",
]),
copts = COPTS,
includes = ["include"],
linkopts = LINKOPTS,
deps = [
"//:torrent",
"@com_google_googletest//:gtest",
],
)
[cc_test(
name = "%s" % t.split("/")[-1][:-3],
srcs = [
t,
"//:included_headers",
],
copts = COPTS,
includes = ["include"],
linkopts = LINKOPTS,
tags = ["libtorrent_test"],
deps = ["//:test_common"],
) for t in glob([
"test/**/test_*.cc",
])]
test_suite(
name = "libtorrent_test",
tags = ["libtorrent_test"],
)