| Tim Windelschmidt | 8fd51cd | 2025-06-29 02:20:17 +0200 | [diff] [blame^] | 1 | load("@bazel_skylib//rules:expand_template.bzl", "expand_template") |
| 2 | load("@bazel_skylib//rules:write_file.bzl", "write_file") |
| Tim Windelschmidt | 156248b | 2025-01-10 00:27:45 +0100 | [diff] [blame] | 3 | load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") |
| Serge Bazanski | 8ff4b7c | 2021-08-17 19:21:18 +0200 | [diff] [blame] | 4 | |
| Tim Windelschmidt | 8fd51cd | 2025-06-29 02:20:17 +0200 | [diff] [blame^] | 5 | write_file( |
| 6 | name = "config.h_template", |
| 7 | out = "config.h.in", |
| 8 | content = ["""\ |
| 9 | #define LINUX |
| 10 | #define DEBUG 0 |
| 11 | #define USE_PTHREAD_ASYNCDNS |
| 12 | |
| 13 | #define CHRONY_VERSION "%CHRONY_VERSION%" |
| 14 | #define CHRONYD_FEATURES "NTP RTC SCFILTER ASYNCDNS" |
| 15 | #define FEAT_NTP |
| 16 | #define FEAT_RTC |
| 17 | #define FEAT_SCFILTER |
| 18 | #define FEAT_ASYNCDNS |
| 19 | #define FEAT_PRIVDROP |
| 20 | #define CAP_IS_SUPPORTED |
| 21 | |
| 22 | #define DEFAULT_COMMAND_SOCKET "/todo/chronyd.sock" |
| 23 | #define DEFAULT_CONF_FILE "/todo/chrony.conf" |
| 24 | #define DEFAULT_HWCLOCK_FILE "" |
| 25 | #define DEFAULT_PID_FILE "/todo/chronyd.pid" |
| 26 | #define DEFAULT_RTC_DEVICE "/dev/rtc" |
| 27 | #define DEFAULT_USER "root" |
| 28 | |
| 29 | #define MAIL_PROGRAM "/todo/sendmail" |
| 30 | """], |
| 31 | ) |
| 32 | |
| 33 | expand_template( |
| 34 | name = "config.h_expanded", |
| 35 | template = ":config.h.in", |
| 36 | out = "config.h", |
| Serge Bazanski | 8ff4b7c | 2021-08-17 19:21:18 +0200 | [diff] [blame] | 37 | substitutions = { |
| Tim Windelschmidt | e1420ab | 2024-08-27 01:53:16 +0200 | [diff] [blame] | 38 | # ONCHANGE(//build/bazel:third_party.MODULE.bazel): version needs to be kept in sync |
| Serge Bazanski | 8ff4b7c | 2021-08-17 19:21:18 +0200 | [diff] [blame] | 39 | "%CHRONY_VERSION%": "4.1-monogon", |
| Lorenz Brun | 68dcee1 | 2021-08-31 13:12:07 +0200 | [diff] [blame] | 40 | }, |
| Serge Bazanski | 8ff4b7c | 2021-08-17 19:21:18 +0200 | [diff] [blame] | 41 | ) |
| 42 | |
| 43 | # Headers which couldn't be decoupled into sub-libraries. |
| 44 | cc_library( |
| 45 | name = "common_hdrs", |
| 46 | srcs = [ |
| Tim Windelschmidt | 8fd51cd | 2025-06-29 02:20:17 +0200 | [diff] [blame^] | 47 | ":config.h_expanded", |
| Serge Bazanski | 8ff4b7c | 2021-08-17 19:21:18 +0200 | [diff] [blame] | 48 | |
| 49 | # Headers corresponding to .c files in :common. |
| 50 | "addrfilt.h", |
| 51 | "array.h", |
| 52 | "clientlog.h", |
| 53 | "cmdparse.h", |
| 54 | "conf.h", |
| 55 | "keys.h", |
| 56 | "local.h", |
| 57 | "logging.h", |
| 58 | "memory.h", |
| 59 | "nameserv.h", |
| 60 | "reference.h", |
| 61 | "regress.h", |
| 62 | "samplefilt.h", |
| 63 | "sched.h", |
| 64 | "smooth.h", |
| 65 | "socket.h", |
| 66 | "sources.h", |
| 67 | "sourcestats.h", |
| 68 | "util.h", |
| 69 | |
| 70 | # Corresponding to .c files in :ntp. |
| 71 | "ntp_core.h", |
| 72 | "ntp_sources.h", |
| 73 | "nts_ke.h", |
| 74 | |
| 75 | # Other headers. |
| 76 | "addressing.h", |
| 77 | "candm.h", |
| 78 | "cmdmon.h", |
| 79 | "cmac.h", |
| 80 | "hash.h", |
| 81 | "localp.h", |
| 82 | "manual.h", |
| 83 | "ntp.h", |
| 84 | "privops.h", |
| 85 | "refclock.h", |
| 86 | "reports.h", |
| 87 | "siv.h", |
| 88 | "srcparams.h", |
| 89 | "sysincl.h", |
| 90 | ], |
| 91 | ) |
| 92 | |
| 93 | # Sources which couldn't be decoupled into sub-libraries. |
| 94 | cc_library( |
| 95 | name = "common", |
| 96 | srcs = [ |
| 97 | "addrfilt.c", |
| 98 | "array.c", |
| 99 | "clientlog.c", |
| 100 | "cmdparse.c", |
| 101 | "conf.c", |
| 102 | "keys.c", |
| 103 | "local.c", |
| 104 | "logging.c", |
| 105 | "memory.c", |
| 106 | "reference.c", |
| 107 | "regress.c", |
| 108 | "samplefilt.c", |
| 109 | "sched.c", |
| 110 | "smooth.c", |
| 111 | "socket.c", |
| 112 | "sources.c", |
| 113 | "sourcestats.c", |
| 114 | "util.c", |
| 115 | ], |
| 116 | deps = [ |
| 117 | ":common_hdrs", |
| 118 | ], |
| 119 | ) |
| 120 | |
| Serge Bazanski | 8ff4b7c | 2021-08-17 19:21:18 +0200 | [diff] [blame] | 121 | # MD5 library used by keys.c, which does #include "md5.c". |
| 122 | cc_library( |
| 123 | name = "md5", |
| 124 | textual_hdrs = [ |
| 125 | "md5.h", |
| 126 | "md5.c", |
| 127 | ], |
| 128 | ) |
| 129 | |
| 130 | cc_library( |
| 131 | name = "nameserv", |
| 132 | srcs = [ |
| 133 | "nameserv.c", |
| 134 | "nameserv_async.h", |
| 135 | "nameserv_async.c", |
| 136 | ], |
| 137 | deps = [ |
| 138 | ":common", |
| 139 | ], |
| 140 | ) |
| 141 | |
| 142 | cc_library( |
| 143 | name = "ntp", |
| 144 | srcs = [ |
| 145 | "nts_ke_client.h", |
| 146 | "nts_ke_server.h", |
| 147 | "nts_ke_session.h", |
| 148 | "nts_ntp_client.h", |
| 149 | "nts_ntp_auth.h", |
| 150 | "nts_ntp_server.h", |
| 151 | "nts_ntp.h", |
| Serge Bazanski | 8ff4b7c | 2021-08-17 19:21:18 +0200 | [diff] [blame] | 152 | "ntp_auth.h", |
| 153 | "ntp_auth.c", |
| 154 | "ntp_core.c", |
| 155 | "ntp_ext.h", |
| 156 | "ntp_ext.c", |
| 157 | "ntp_io.h", |
| 158 | "ntp_io.c", |
| 159 | "ntp_signd.h", |
| 160 | "ntp_sources.c", |
| 161 | ], |
| 162 | deps = [ |
| 163 | ":common", |
| 164 | ":nameserv", |
| 165 | ], |
| 166 | ) |
| 167 | |
| 168 | cc_library( |
| 169 | name = "sys", |
| 170 | srcs = [ |
| 171 | "sys.h", |
| 172 | "sys.c", |
| 173 | "sys_generic.h", |
| 174 | "sys_generic.c", |
| 175 | "sys_linux.h", |
| 176 | "sys_linux.c", |
| 177 | "sys_timex.h", |
| 178 | "sys_timex.c", |
| 179 | "sys_posix.h", |
| 180 | "sys_null.h", |
| 181 | "sys_null.c", |
| 182 | ], |
| 183 | deps = [ |
| 184 | ":common", |
| 185 | "@seccomp//:seccomp", |
| Tim Windelschmidt | 04b6708 | 2025-05-28 17:40:07 +0200 | [diff] [blame] | 186 | "@libcap//:libcap", |
| Serge Bazanski | 8ff4b7c | 2021-08-17 19:21:18 +0200 | [diff] [blame] | 187 | ], |
| 188 | ) |
| 189 | |
| 190 | cc_library( |
| 191 | name = "rtc", |
| 192 | srcs = [ |
| 193 | "rtc.h", |
| 194 | "rtc.c", |
| 195 | "rtc_linux.h", |
| 196 | "rtc_linux.c", |
| 197 | ], |
| 198 | deps = [ |
| 199 | ":common", |
| 200 | ":sys", |
| 201 | ], |
| 202 | ) |
| 203 | |
| 204 | cc_library( |
| 205 | name = "tempcomp", |
| 206 | srcs = [ |
| 207 | "tempcomp.h", |
| 208 | "tempcomp.c", |
| 209 | ], |
| 210 | deps = [ |
| 211 | ":common", |
| 212 | ], |
| 213 | ) |
| 214 | |
| 215 | cc_binary( |
| 216 | name = "chrony", |
| 217 | srcs = [ |
| 218 | "hash_intmd5.c", |
| 219 | "main.h", |
| 220 | "main.c", |
| 221 | "stubs.c", |
| Serge Bazanski | 8ff4b7c | 2021-08-17 19:21:18 +0200 | [diff] [blame] | 222 | ], |
| 223 | deps = [ |
| 224 | ":common", |
| 225 | ":md5", |
| 226 | ":ntp", |
| 227 | ":rtc", |
| 228 | ":tempcomp", |
| 229 | ], |
| 230 | visibility = ["//visibility:public"], |
| 231 | ) |