forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBUILD.redis
80 lines (72 loc) · 1.83 KB
/
BUILD.redis
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
load("@rules_foreign_cc//foreign_cc:defs.bzl", "make")
exports_files(
[
"redis-server.exe",
"redis-cli.exe",
],
visibility = ["//visibility:public"],
)
filegroup(
name = "all_srcs",
srcs = glob(
include = ["**"],
exclude = ["*.bazel"],
),
)
make(
name = "redis",
args = [
"BUILD_TLS=yes",
"-s",
],
copts = [
"-DLUA_USE_MKSTEMP",
"-Wno-pragmas",
"-Wno-empty-body",
"-fPIC",
],
visibility = ["//visibility:public"],
lib_source = ":all_srcs",
deps = [
"@openssl//:openssl",
],
out_binaries = [
"redis-server",
"redis-cli"
]
)
genrule_cmd = select({
"@platforms//os:osx": """
unset CC LDFLAGS CXX CXXFLAGS
tmpdir="redis.tmp"
p=$(location Makefile)
cp -p -L -R -- "$${p%/*}" "$${tmpdir}"
chmod +x "$${tmpdir}"/deps/jemalloc/configure
parallel="$$(getconf _NPROCESSORS_ONLN || echo 1)"
make -s -C "$${tmpdir}" -j"$${parallel}" V=0 CFLAGS="$${CFLAGS-} -DLUA_USE_MKSTEMP -Wno-pragmas -Wno-empty-body"
mv "$${tmpdir}"/src/redis-server $(location redis-server)
chmod +x $(location redis-server)
mv "$${tmpdir}"/src/redis-cli $(location redis-cli)
chmod +x $(location redis-cli)
rm -r -f -- "$${tmpdir}"
""",
"//conditions:default": """
cp $(RULEDIR)/redis/bin/redis-server $(location redis-server)
cp $(RULEDIR)/redis/bin/redis-cli $(location redis-cli)
"""
})
genrule_srcs = select({
"@platforms//os:osx": glob(["**"]),
"//conditions:default": [":redis"],
})
genrule(
name = "bin",
srcs = genrule_srcs,
outs = [
"redis-server",
"redis-cli",
],
cmd = genrule_cmd,
visibility = ["//visibility:public"],
tags = ["local"],
)