comparison third_party/wrk/BUILD @ 178:94705b5986b3

[ThirdParty] Added WRK and luajit for load testing.
author MrJuneJune <me@mrjunejune.com>
date Thu, 22 Jan 2026 20:10:30 -0800
parents
children
comparison
equal deleted inserted replaced
177:24fe8ff94056 178:94705b5986b3
1 load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
2
3 package(default_visibility = ["//visibility:public"])
4
5 # Generate version.c
6 genrule(
7 name = "version_gen",
8 outs = ["version.c"],
9 cmd = """echo 'const char *VERSION = "4.2.0";' > $@""",
10 )
11
12 # Generate bytecode.c from wrk.lua using luajit
13 genrule(
14 name = "bytecode_gen",
15 srcs = ["src/wrk.lua"],
16 outs = ["bytecode.c"],
17 cmd = """
18 LUAJIT_BIN=$(execpath //third_party/luajit:luajit_bin)
19 LUAJIT_DIR=$${LUAJIT_BIN%/bin/luajit}
20 LUA_PATH="$${LUAJIT_DIR}/share/luajit-2.1/?.lua;;" $${LUAJIT_BIN} -b $< $@
21 """,
22 local = True,
23 tools = ["//third_party/luajit:luajit_bin"],
24 )
25
26 cc_library(
27 name = "wrk_lib",
28 srcs = [
29 "src/ae.c",
30 "src/aprintf.c",
31 "src/http_parser.c",
32 "src/net.c",
33 "src/script.c",
34 "src/ssl.c",
35 "src/stats.c",
36 "src/units.c",
37 "src/zmalloc.c",
38 ":bytecode_gen",
39 ":version_gen",
40 ],
41 hdrs = [
42 "src/ae.h",
43 "src/aprintf.h",
44 "src/atomicvar.h",
45 "src/config.h",
46 "src/http_parser.h",
47 "src/main.h",
48 "src/net.h",
49 "src/script.h",
50 "src/ssl.h",
51 "src/stats.h",
52 "src/units.h",
53 "src/wrk.h",
54 "src/zmalloc.h",
55 ],
56 textual_hdrs = [
57 "src/ae_epoll.c",
58 "src/ae_evport.c",
59 "src/ae_kqueue.c",
60 "src/ae_select.c",
61 ],
62 copts = [
63 "-std=c99",
64 "-Wall",
65 "-O2",
66 "-D_REENTRANT",
67 ] + select({
68 "@platforms//os:linux": [
69 "-D_POSIX_C_SOURCE=200112L",
70 "-D_BSD_SOURCE",
71 "-D_DEFAULT_SOURCE",
72 ],
73 "@platforms//os:freebsd": [
74 "-D_DECLARE_C99_LDBL_MATH",
75 ],
76 "//conditions:default": [],
77 }),
78 includes = ["src"],
79 deps = [
80 "//third_party/luajit:luajit",
81 "@openssl//:crypto",
82 "@openssl//:ssl",
83 ],
84 alwayslink = True,
85 )
86
87 cc_binary(
88 name = "wrk",
89 srcs = ["src/wrk.c"],
90 copts = [
91 "-std=c99",
92 "-Wall",
93 "-O2",
94 "-D_REENTRANT",
95 ] + select({
96 "@platforms//os:linux": [
97 "-D_POSIX_C_SOURCE=200112L",
98 "-D_BSD_SOURCE",
99 "-D_DEFAULT_SOURCE",
100 ],
101 "@platforms//os:freebsd": [
102 "-D_DECLARE_C99_LDBL_MATH",
103 ],
104 "//conditions:default": [],
105 }),
106 includes = ["src"],
107 linkopts = [
108 "-lm",
109 "-lpthread",
110 "-rdynamic",
111 ] + select({
112 "@platforms//os:linux": [
113 "-ldl",
114 ],
115 "//conditions:default": [],
116 }),
117 deps = [":wrk_lib"],
118 )