-
Notifications
You must be signed in to change notification settings - Fork 1
/
BUILD.bazel
116 lines (92 loc) · 3.1 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
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
# to see all the commands, add "CMAKE_VERBOSE_MAKEFILE": "ON"
# or use generate_args = ["-GNinja", "--trace-expand"] and build_args = ["--verbose"]
# source: https://github.com/bazelbuild/rules_foreign_cc/issues/863
# TODO
# configuration: source of packages either download github, local checkout (can modify source), or rpms (present in standard paths)
# smart setting of CCACHE_BASEDIR is needed
# lib64
# switch to ninja
# https://docs.bazel.build/versions/master/configurable-attributes.html
# https://github.com/bazelbuild/bazel/issues/8171
# https://github.com/bazelbuild/bazel/issues/3902
# (the select only evaluates inside rules)
load("@bazel_skylib//lib:dicts.bzl", "dicts")
cmake_compiler_launcher = {
"CMAKE_C_COMPILER_LAUNCHER": "ccache",
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
}
proton_cache_entries = {
"CMAKE_CXX_COMPILER": "g++",
"BUILD_BINDINGS": "cpp",
"BUILD_EXAMPLES": "OFF",
"BUILD_TESTING": "OFF",
# these are optional by default, CMake would skip them if not found
"SASL_IMPL": "cyrus",
"SSL_IMPL": "openssl",
"PROACTOR": "epoll",
# normalize expectations (cmake rule expects ubuntu)
#"LIB_INSTALL_DIR": "lib",
#"LIB_SUFFIX": "",
}
cmake(
name = "qpid-proton",
generate_crosstool_file = False,
cache_entries = select({
":ccache_enabled": dicts.add(proton_cache_entries, cmake_compiler_launcher),
"//conditions:default": proton_cache_entries,
}),
lib_source = "@qpid-proton//:all",
out_lib_dir = "lib64",
build_args = ["-j8"],
out_shared_libs = ["libqpid-proton-core.so", "libqpid-proton.so", "libqpid-proton-cpp.so"],
)
filegroup(name = "sources", srcs = glob(["CMakeLists.txt", "src/**", "dist/**", "*.cmake"]), visibility = ["//visibility:public"])
cmake(
name = "cli-cpp",
generate_crosstool_file = False,
cache_entries = {
"CMAKE_CXX_COMPILER": "g++",
# https://github.com/bazelbuild/rules_foreign_cc/pull/970#issuecomment-1282134709
"EXT_BUILD_DEPS": "$EXT_BUILD_DEPS",
"EXT_BUILD_ROOT": "$EXT_BUILD_ROOT",
"Proton_DIR": "$EXT_BUILD_DEPS/qpid-proton/lib64/cmake/Proton",
"ProtonCpp_DIR": "$EXT_BUILD_DEPS/qpid-proton/lib64/cmake/ProtonCpp",
"CMAKE_VERBOSE_MAKEFILE": "ON",
"CMAKE_BUILD_WITH_INSTALL_RPATH": "TRUE",
"CMAKE_INSTALL_RPATH_USE_LINK_PATH": "TRUE",
},
lib_source = "sources",
build_args = ["-j8"],
out_binaries = ["aac3_receiver"],
deps = select({
":deps_upstream": [":qpid-proton"],
":deps_rpms": [],
}),
)
# This file uses the above definitions to define two custom build settings.
load("//:build_settings.bzl", "bool_flag", "string_flag")
string_flag(
name = "deps",
build_setting_default = "upstream",
)
config_setting(
name = "deps_upstream",
flag_values = {
"//:deps": "upstream"
}
)
config_setting(
name = "deps_rpms",
flag_values = {
"//:deps": "rpms"
}
)
bool_flag(
name = "enable_ccache",
build_setting_default = False,
)
config_setting(
name = "ccache_enabled",
flag_values = {"//:enable_ccache": "True"},
)