Skip to content

Commit a17576f

Browse files
committed
Use "foreign_cc" rules to build libev.
This should be more portable than trying to write our own genrule to do it, which was breaking on Homebrew. Also, fix the foreign_cc rules so that they work on BSD.
1 parent 7d95cb2 commit a17576f

File tree

6 files changed

+42
-85
lines changed

6 files changed

+42
-85
lines changed

WORKSPACE

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ load(
88
"new_git_repository",
99
)
1010

11+
git_repository(
12+
name = "rules_foreign_cc",
13+
commit = "38358597f9380e9098eb5642169ad23c169df98e",
14+
remote = "https://github.com/gbrail/rules_foreign_cc.git",
15+
shallow_since = "1586453104 -0700"
16+
)
17+
load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")
18+
19+
rules_foreign_cc_dependencies([])
20+
21+
# Group the sources of the library so that make rule have access to it
22+
all_content = """filegroup(name = "all", srcs = glob(["**"]), visibility = ["//visibility:public"])"""
23+
1124
http_archive(
1225
name = "gtest",
1326
sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb",
@@ -17,10 +30,10 @@ http_archive(
1730

1831
http_archive(
1932
name = "libev",
20-
build_file = "@//:libev.build",
21-
sha256 = "2d5526fc8da4f072dd5c73e18fbb1666f5ef8ed78b73bba12e195cfdd810344e",
22-
strip_prefix = "libev-4.27",
23-
urls = ["http://dist.schmorp.de/libev/Attic/libev-4.27.tar.gz"],
33+
sha256 = "507eb7b8d1015fbec5b935f34ebed15bf346bed04a11ab82b8eee848c4205aea",
34+
strip_prefix = "libev-4.33",
35+
build_file_content = all_content,
36+
urls = ["http://dist.schmorp.de/libev/Attic/libev-4.33.tar.gz"],
2437
)
2538

2639
http_archive(

apib/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ cc_library(
7979
deps = [
8080
":common",
8181
"//third_party:base64",
82+
"//third_party/libev",
8283
"@absl//absl/strings:str_format",
8384
"@boringssl//:crypto",
8485
"@boringssl//:ssl",
8586
"@httpparser",
86-
"@libev",
8787
],
8888
)
8989

@@ -97,8 +97,8 @@ cc_library(
9797
],
9898
deps = [
9999
":common",
100+
"//third_party/libev",
100101
"@absl//absl/strings",
101-
"@libev",
102102
],
103103
linkopts = [
104104
"-lpthread",

libev.build

Lines changed: 0 additions & 39 deletions
This file was deleted.

libevent.build

Lines changed: 0 additions & 39 deletions
This file was deleted.

test/BUILD

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ cc_library(
44
hdrs = ["test_server.h"],
55
deps = [
66
"//apib:common",
7+
"//third_party/libev",
78
"@boringssl//:ssl",
89
"@httpparser",
9-
"@libev",
1010
],
1111
)
1212

@@ -112,6 +112,7 @@ cc_test(
112112
"//apib:io",
113113
"@gtest",
114114
],
115+
linkstatic = True,
115116
)
116117

117118
cc_test(
@@ -123,6 +124,7 @@ cc_test(
123124
"//apib:io",
124125
"@gtest",
125126
],
127+
linkstatic = True,
126128
)
127129

128130
cc_test(

third_party/libev/BUILD

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
load("@rules_foreign_cc//tools/build_defs:configure.bzl", "configure_make")
4+
5+
configure_make(
6+
name = "libev",
7+
lib_source = "@libev//:all",
8+
configure_options = [
9+
"--disable-dependency-tracking",
10+
"--enable-static",
11+
"--disable-shared",
12+
],
13+
# Without this for some reason Bazel tries to send
14+
# ar commands to libtool!
15+
configure_env_vars = {
16+
"AR": "",
17+
},
18+
# Bazel likes to use the shared libraries for tests
19+
static_libraries = ["libev.a"],
20+
)

0 commit comments

Comments
 (0)