Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit 2582da7

Browse files
author
Yu Wei Wu
committed
feat(bazel): Import hiredis dependency through bazel
Import shared library is available in bazle, while it's still have lots of restrictions. As of now we use git submodule and makefile to compile dependencies. This may cause unwanted update from git submodule and env errors. Introduce bazel rules to compile can make sure these being take care of.
1 parent 399f91e commit 2582da7

File tree

7 files changed

+46
-18
lines changed

7 files changed

+46
-18
lines changed

WORKSPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository")
2+
load("//third_party:third_party.bzl", "third_party_deps")
23

34
git_repository(
45
name = "rules_iota",
@@ -29,4 +30,6 @@ load("@io_bazel_rules_docker//cc:image.bzl", _cc_image_repos = "repositories")
2930

3031
iota_deps()
3132

33+
third_party_deps()
34+
3235
_cc_image_repos()

tests/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ cc_binary(
4848
],
4949
)
5050

51-
cc_binary(
51+
cc_test(
5252
name = "test_cache",
5353
srcs = [
5454
"test_cache.c",

third_party/BUILD

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,3 @@ cc_import(
88
],
99
shared_library = "dcurl/build/libdcurl.so",
1010
)
11-
12-
cc_import(
13-
name = "hiredis",
14-
hdrs = [
15-
"hiredis/async.h",
16-
"hiredis/dict.h",
17-
"hiredis/fmacros.h",
18-
"hiredis/hiredis.h",
19-
"hiredis/net.h",
20-
"hiredis/read.h",
21-
"hiredis/sds.h",
22-
"hiredis/sdsalloc.h",
23-
],
24-
static_library = "hiredis/libhiredis.a",
25-
)

third_party/BUILD.hiredis

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
cc_library(
2+
name = "hiredis",
3+
srcs = [
4+
"dict.h",
5+
"fmacros.h",
6+
"hiredis.h",
7+
"net.h",
8+
"read.h",
9+
"sdsalloc.h",
10+
"sds.h",
11+
"dict.c",
12+
"hiredis.c",
13+
"net.c",
14+
"read.c",
15+
"sds.c",
16+
],
17+
hdrs = [
18+
"hiredis.h",
19+
"net.h",
20+
],
21+
include_prefix = "hiredis",
22+
copts = [
23+
"-Wno-unused-function"
24+
],
25+
visibility = ["//visibility:public"],
26+
)

third_party/third_party.bzl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2+
3+
def load_hiredis():
4+
http_archive(
5+
name = "hiredis",
6+
url = "https://github.com/redis/hiredis/archive/v0.14.0.tar.gz",
7+
strip_prefix = "hiredis-0.14.0",
8+
sha256 =
9+
"042f965e182b80693015839a9d0278ae73fae5d5d09d8bf6d0e6a39a8c4393bd",
10+
build_file = "//third_party:BUILD.hiredis",
11+
)
12+
13+
def third_party_deps():
14+
load_hiredis()

utils/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ cc_library(
66
hdrs = ["cache.h"],
77
deps = [
88
"//accelerator:ta_errors",
9-
"//third_party:hiredis",
109
"@entangled//cclient/types",
10+
"@hiredis",
1111
],
1212
)
1313

utils/backend_redis.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
#include <hiredis/hiredis.h>
12
#include "cache.h"
2-
#include "third_party/hiredis/hiredis.h"
33

44
/* private data used by cache_t */
55
typedef struct {

0 commit comments

Comments
 (0)