From 18a33169b8d9b96fc85d8819a1700c729cf794f6 Mon Sep 17 00:00:00 2001 From: iphydf Date: Thu, 18 Jan 2018 15:14:50 +0000 Subject: [PATCH] Add bazel build scripts for c-toxcore. This allows us and users to reproducibly build verified versions of the library with checksums. It will power the toktok-stack continuous build with checked-in checksums at specific git revisions. --- BUILD | 29 ++++++++++++++ auto_tests/BUILD | 25 ++++++++++++ auto_tests/helpers.h | 2 + other/BUILD | 10 +++++ testing/BUILD | 7 ++++ toxav/BUILD | 46 +++++++++++++++++++++ toxcore/BUILD | 95 ++++++++++++++++++++++++++++++++++++++++++++ toxencryptsave/BUILD | 31 +++++++++++++++ 8 files changed, 245 insertions(+) create mode 100644 BUILD create mode 100644 auto_tests/BUILD create mode 100644 other/BUILD create mode 100644 testing/BUILD create mode 100644 toxav/BUILD create mode 100644 toxcore/BUILD create mode 100644 toxencryptsave/BUILD diff --git a/BUILD b/BUILD new file mode 100644 index 00000000..58dc7b43 --- /dev/null +++ b/BUILD @@ -0,0 +1,29 @@ +genrule( + name = "copy_headers", + srcs = [ + "//c-toxcore/toxav:public", + "//c-toxcore/toxcore:public", + "//c-toxcore/toxencryptsave:public", + ], + outs = [ + "tox/toxav.h", + "tox/tox.h", + "tox/toxencryptsave.h", + ], + cmd = """ + cp $(location //c-toxcore/toxav:public) $(GENDIR)/c-toxcore/tox/toxav.h + cp $(location //c-toxcore/toxcore:public) $(GENDIR)/c-toxcore/tox/tox.h + cp $(location //c-toxcore/toxencryptsave:public) $(GENDIR)/c-toxcore/tox/toxencryptsave.h + """, +) + +cc_library( + name = "headers", + hdrs = [ + "tox/tox.h", + "tox/toxav.h", + "tox/toxencryptsave.h", + ], + includes = ["."], + visibility = ["//visibility:public"], +) diff --git a/auto_tests/BUILD b/auto_tests/BUILD new file mode 100644 index 00000000..d94442a1 --- /dev/null +++ b/auto_tests/BUILD @@ -0,0 +1,25 @@ +cc_library( + name = "helpers", + testonly = True, + hdrs = [ + "check_compat.h", + "helpers.h", + ], +) + +[cc_test( + name = src[:-2], + size = "small", + srcs = [src], + copts = [ + "-Wno-parentheses", + ], + deps = [ + ":helpers", + "//c-toxcore/other:monolith", + "//c-toxcore/testing:misc_tools", + "//c-toxcore/toxav", + "//c-toxcore/toxcore", + "@check", + ], +) for src in glob(["*_test.c"])] diff --git a/auto_tests/helpers.h b/auto_tests/helpers.h index 745c5d22..373b4a37 100644 --- a/auto_tests/helpers.h +++ b/auto_tests/helpers.h @@ -42,6 +42,8 @@ static const char *tox_log_level_name(TOX_LOG_LEVEL level) case TOX_LOG_LEVEL_ERROR: return "ERROR"; } + + return ""; } static void print_debug_log(Tox *m, TOX_LOG_LEVEL level, const char *path, uint32_t line, const char *func, diff --git a/other/BUILD b/other/BUILD new file mode 100644 index 00000000..5c8997ec --- /dev/null +++ b/other/BUILD @@ -0,0 +1,10 @@ +cc_library( + name = "monolith", + hdrs = ["monolith.h"], + visibility = ["//c-toxcore/auto_tests:__pkg__"], + deps = [ + "//c-toxcore/toxav:monolith", + "//c-toxcore/toxcore:monolith", + "//c-toxcore/toxencryptsave:monolith", + ], +) diff --git a/testing/BUILD b/testing/BUILD new file mode 100644 index 00000000..cf7cd40f --- /dev/null +++ b/testing/BUILD @@ -0,0 +1,7 @@ +cc_library( + name = "misc_tools", + hdrs = [ + "misc_tools.c", + ], + visibility = ["//visibility:public"], +) diff --git a/toxav/BUILD b/toxav/BUILD new file mode 100644 index 00000000..ab074841 --- /dev/null +++ b/toxav/BUILD @@ -0,0 +1,46 @@ +filegroup( + name = "public", + srcs = ["toxav.h"], + visibility = ["//visibility:public"], +) + +cc_library( + name = "toxav", + srcs = [ + "audio.c", + "bwcontroller.c", + "groupav.c", + "msi.c", + "ring_buffer.c", + "rtp.c", + "toxav.c", + "toxav_old.c", + "video.c", + ], + hdrs = [ + "audio.h", + "bwcontroller.h", + "groupav.h", + "msi.h", + "ring_buffer.h", + "rtp.h", + "toxav.api.h", + "toxav.h", + "video.h", + ], + visibility = ["//visibility:public"], + deps = [ + "//c-toxcore/toxcore", + "@libvpx", + "@opus", + ], +) + +cc_library( + name = "monolith", + hdrs = glob([ + "*.c", + "*.h", + ]), + visibility = ["//c-toxcore/other:__pkg__"], +) diff --git a/toxcore/BUILD b/toxcore/BUILD new file mode 100644 index 00000000..48ac56fe --- /dev/null +++ b/toxcore/BUILD @@ -0,0 +1,95 @@ +filegroup( + name = "public", + srcs = ["tox.h"], + visibility = ["//visibility:public"], +) + +cc_library( + name = "ccompat", + hdrs = [ + "ccompat.h", + ], + visibility = ["//visibility:public"], +) + +cc_library( + name = "crypto_core", + srcs = [ + "crypto_core.c", + "crypto_core_mem.c", + ], + hdrs = [ + "crypto_core.h", + ], + visibility = ["//visibility:public"], + deps = [ + ":ccompat", + "@libsodium", + ], +) + +cc_library( + name = "toxcore", + srcs = [ + "DHT.c", + "DHT.h", + "LAN_discovery.c", + "LAN_discovery.h", + "Messenger.c", + "Messenger.h", + "TCP_client.c", + "TCP_client.h", + "TCP_connection.c", + "TCP_connection.h", + "TCP_server.c", + "TCP_server.h", + "friend_connection.c", + "friend_connection.h", + "friend_requests.c", + "friend_requests.h", + "group.c", + "group.h", + "list.c", + "list.h", + "logger.c", + "logger.h", + "net_crypto.c", + "net_crypto.h", + "network.c", + "network.h", + "onion.c", + "onion.h", + "onion_announce.c", + "onion_announce.h", + "onion_client.c", + "onion_client.h", + "ping.c", + "ping.h", + "ping_array.c", + "ping_array.h", + "tox.c", + "tox.h", + "tox_api.c", + "util.c", + "util.h", + ], + copts = [ + "-Wno-parentheses", + ], + linkopts = ["-lpthread"], + visibility = ["//visibility:public"], + deps = [ + ":ccompat", + ":crypto_core", + "//c-toxcore/toxencryptsave", + ], +) + +cc_library( + name = "monolith", + hdrs = glob([ + "*.c", + "*.h", + ]), + visibility = ["//c-toxcore/other:__pkg__"], +) diff --git a/toxencryptsave/BUILD b/toxencryptsave/BUILD new file mode 100644 index 00000000..8b49d554 --- /dev/null +++ b/toxencryptsave/BUILD @@ -0,0 +1,31 @@ +filegroup( + name = "public", + srcs = ["toxencryptsave.h"], + visibility = ["//visibility:public"], +) + +cc_library( + name = "toxencryptsave", + srcs = [ + "toxencryptsave.c", + ], + hdrs = [ + "defines.h", + "toxencryptsave.h", + ], + visibility = [ + "//visibility:public", + ], + deps = [ + "//c-toxcore/toxcore:crypto_core", + ], +) + +cc_library( + name = "monolith", + hdrs = glob([ + "*.c", + "*.h", + ]), + visibility = ["//c-toxcore/other:__pkg__"], +)