forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBUILD.bazel
201 lines (194 loc) · 7.11 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# Load the components that lets us use cmake/make in third party deps.
load("@rules_foreign_cc//foreign_cc:cmake.bzl", "cmake")
load("@rules_foreign_cc//foreign_cc:configure.bzl", "configure_make")
# Define the build target for libjemalloc.
configure_make(
name = "libjemalloc",
autoconf = True,
configure_in_place = True,
configure_options = [
"--enable-prof",
] + select({
"@io_bazel_rules_go//go/platform:windows": ["--host=x86_64-w64-mingw32"],
"@io_bazel_rules_go//go/platform:darwin": ["--host=x86_64-apple-darwin19"],
"@io_bazel_rules_go//go/platform:linux_arm64": ["--host=aarch64-unknown-linux-gnu"],
"//conditions:default": [],
}),
env = select({
"//build/toolchains:dev": {"AR": ""},
"//conditions:default": {},
}),
lib_source = "@jemalloc//:all",
out_static_libs = select({
"@io_bazel_rules_go//go/platform:windows": ["jemalloc.lib"],
"//conditions:default": ["libjemalloc.a"],
}),
targets = [
"build_lib_static",
"install_lib",
"install_include",
],
visibility = ["//visibility:public"],
)
# Define the build target for libproj.
cmake(
name = "libproj",
cache_entries = select({
# TODO(ricky): The repetition here is dumb, but I don't know a cleaner
# way to do it?
# https://github.com/bazelbuild/bazel/issues/12457 would help.
"@io_bazel_rules_go//go/platform:windows": {
"BUILD_LIBPROJ_SHARED": "OFF",
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_SYSTEM_NAME": "Generic",
},
"@io_bazel_rules_go//go/platform:darwin": {
"BUILD_LIBPROJ_SHARED": "OFF",
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_SYSTEM_NAME": "Generic",
},
"//conditions:default": {
"BUILD_LIBPROJ_SHARED": "OFF",
"CMAKE_BUILD_TYPE": "Release",
},
}),
generate_args = ["-GUnix Makefiles"],
lib_source = "@proj//:all",
out_static_libs = ["libproj.a"],
visibility = ["//visibility:public"],
)
# Define the targets for libgeos.
cmake(
name = "libgeos",
cache_entries = select({
"@io_bazel_rules_go//go/platform:windows": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_C_FLAGS": "-fPIC",
"CMAKE_CXX_FLAGS": "-fPIC",
"CMAKE_SYSTEM_NAME": "Windows",
},
"@io_bazel_rules_go//go/platform:darwin": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_C_FLAGS": "-fPIC",
"CMAKE_CXX_FLAGS": "-fPIC",
"CMAKE_SYSTEM_NAME": "Darwin",
},
"//conditions:default": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_C_FLAGS": "-fPIC",
"CMAKE_CXX_FLAGS": "-fPIC",
},
}),
data = select({
"//build/toolchains:is_cross_macos": [
"@toolchain_cross_x86_64-apple-darwin19//:bin/x86_64-apple-darwin19-install_name_tool",
"@toolchain_cross_x86_64-apple-darwin19//:bin/x86_64-apple-darwin19-otool",
],
"//conditions:default": [],
}),
env = select({
"//build/toolchains:is_cross_macos": {
"CMAKE_INSTALL_NAME_TOOL": "$(execpath @toolchain_cross_x86_64-apple-darwin19//:bin/x86_64-apple-darwin19-install_name_tool)",
"OTOOL": "$(execpath @toolchain_cross_x86_64-apple-darwin19//:bin/x86_64-apple-darwin19-otool)",
},
"//conditions:default": {},
}),
generate_args = ["-GUnix Makefiles"],
lib_source = "@geos//:all",
out_lib_dir = select({
"@io_bazel_rules_go//go/platform:windows": "bin",
"//conditions:default": "lib",
}),
out_shared_libs = select({
"@io_bazel_rules_go//go/platform:darwin": [
"libgeos_c.dylib",
"libgeos.dylib",
],
"@io_bazel_rules_go//go/platform:windows": [
"libgeos_c.dll",
"libgeos.dll",
],
"//conditions:default": [
"libgeos_c.so",
"libgeos.so",
],
}),
postfix_script = "mkdir -p libgeos/lib\n" + select({
"//build/toolchains:is_cross_macos": (
"cp -L lib/libgeos.3.8.1.dylib $INSTALLDIR/lib/libgeos.dylib\n" +
"PREFIX=$($OTOOL -D $INSTALLDIR/lib/libgeos_c.dylib | tail -n1 | rev | cut -d/ -f2- | rev)\n" +
"$CMAKE_INSTALL_NAME_TOOL -id @rpath/libgeos.3.8.1.dylib $INSTALLDIR/lib/libgeos.dylib\n" +
"$CMAKE_INSTALL_NAME_TOOL -id @rpath/libgeos_c.1.dylib $INSTALLDIR/lib/libgeos_c.dylib\n" +
"$CMAKE_INSTALL_NAME_TOOL -change $PREFIX/libgeos.3.8.1.dylib @rpath/libgeos.3.8.1.dylib $INSTALLDIR/lib/libgeos_c.dylib\n"
),
"@io_bazel_rules_go//go/platform:darwin": "cp -L lib/libgeos.3.8.1.dylib $INSTALLDIR/lib/libgeos.dylib",
"@io_bazel_rules_go//go/platform:windows": "",
"//build/toolchains:is_cross_linux": (
"cp -L lib/libgeos.so.3.8.1 $INSTALLDIR/lib/libgeos.so\n" +
"patchelf --set-rpath /usr/local/lib/cockroach/ $INSTALLDIR/lib/libgeos_c.so\n" +
"patchelf --set-soname libgeos.so $INSTALLDIR/lib/libgeos.so\n" +
"patchelf --replace-needed libgeos.so.3.8.1 libgeos.so $INSTALLDIR/lib/libgeos_c.so\n"
),
"//conditions:default": "cp -L lib/libgeos.so.3.8.1 $INSTALLDIR/lib/libgeos.so",
}),
targets = ["geos_c"],
visibility = ["//visibility:public"],
)
# Define the build target for kerberos.
configure_make(
name = "libkrb5",
autoreconf = True,
autoreconf_directory = "src",
autoreconf_options = [
"-Wno-obsolete",
],
configure_command = "src/configure",
configure_in_place = True,
configure_options = [
"--enable-static",
"--disable-shared",
],
# We specify -fcommon to get around duplicate definition errors in recent gcc.
copts = ["-fcommon"],
data = [":autom4te"],
env = {
"AUTOM4TE": "$(execpath :autom4te)",
},
lib_source = "@krb5//:all",
out_static_libs = [
"libgssapi_krb5.a",
"libkrb5.a",
"libkrb5support.a",
"libk5crypto.a",
"libcom_err.a",
],
postfix_script = ("""mkdir -p libkrb5/lib
cp lib/libcom_err.a libkrb5/lib
cp lib/libgssapi_krb5.a libkrb5/lib
cp lib/libkrb5.a libkrb5/lib
cp lib/libkrb5support.a libkrb5/lib
cp lib/libk5crypto.a libkrb5/lib
mkdir -p libkrb5/include/gssapi
cp include/gssapi/gssapi.h libkrb5/include/gssapi"""),
visibility = ["//visibility:public"],
)
# This is extremely stupid and unnecessary, but in certain cases to depend on
# the output of a `cmake` target, we need to launder through a filegroup:
# https://github.com/bazelbuild/rules_foreign_cc/issues/619#issuecomment-844473637
# This is apparently a bug. In the meantime, people can depend on the :*_files
# targets rather than :libgeos where it matters.
filegroup(
name = "libgeos_files",
srcs = [":libgeos"],
visibility = ["//visibility:public"],
)
filegroup(
name = "libproj_files",
srcs = [":libproj"],
visibility = ["//visibility:public"],
)
filegroup(
name = "libedit_files",
srcs = ["@com_github_knz_go_libedit//unix:edit"],
visibility = ["//visibility:public"],
)