261d2e53b7
11ab1d2a723 fix: reduce memory usage in group chats by 75% Significantly reduced the memory usage of groups since all message slots are preallocated for every peer for send and receive buffers of buffer size (hundreds of MiB peak when save contained alot of peers to try to connect to) 4f09f4e147c chore: Fix tsan build by moving it to GitHub CI. 6460c25c9e0 refactor: Use `merge_sort` instead of `qsort` for sorting. c660bbe8c95 test: Fix crypto_test to initialise its plain text buffer. 0204db6184b cleanup: Fix layering check warnings. df2211e1548 refactor: Use tox memory allocator for temporary buffers in crypto. ac812871a2e feat: implement the last 2 missing network struct functions and make use of them 29d1043be0b test: friend request test now tests min/max message sizes 93aafd78c1f fix: friend requests with very long messages are no longer dropped 819aa2b2618 feat: Add option to disable DNS lookups in toxcore. 0ac23cee035 fix: windows use of REUSEADDR 7d2811d302d chore(ci): make bazel server shutdown faster 1dc399ba20d chore: Use vcpkg instead of conan in the MSVC build. 14d823165d9 chore: Migrate to conan 2. bdd17c16787 cleanup: Allocate logger using tox memory allocator. b396c061515 chore(deps): bump third_party/cmp from `2ac6bca` to `52bfcfa` 2e94da60d09 feat(net): add missing connect to network struct 41fb1839c7b chore: Add check to ensure version numbers agree. 934a8301113 chore: Release 0.2.20 3acef4bf044 fix: Add missing free in dht_get_nodes_response event. git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: 11ab1d2a7232eee19b51ce126ccce267d6578903
231 lines
7.2 KiB
Python
Executable File
231 lines
7.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import glob
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
from dataclasses import dataclass
|
|
from typing import Iterable
|
|
from typing import Optional
|
|
|
|
LIBS = {}
|
|
MODS = {}
|
|
STD_MODULE = """module std [system] {
|
|
textual header "/usr/include/alloca.h"
|
|
textual header "/usr/include/assert.h"
|
|
textual header "/usr/include/c++/13.2.1/algorithm"
|
|
textual header "/usr/include/c++/13.2.1/array"
|
|
textual header "/usr/include/c++/13.2.1/chrono"
|
|
textual header "/usr/include/c++/13.2.1/cstddef"
|
|
textual header "/usr/include/c++/13.2.1/cstdint"
|
|
textual header "/usr/include/c++/13.2.1/cstdio"
|
|
textual header "/usr/include/c++/13.2.1/cstdlib"
|
|
textual header "/usr/include/c++/13.2.1/cstring"
|
|
textual header "/usr/include/c++/13.2.1/iomanip"
|
|
textual header "/usr/include/c++/13.2.1/iosfwd"
|
|
textual header "/usr/include/c++/13.2.1/limits"
|
|
textual header "/usr/include/c++/13.2.1/memory"
|
|
textual header "/usr/include/c++/13.2.1/ostream"
|
|
textual header "/usr/include/c++/13.2.1/random"
|
|
textual header "/usr/include/c++/13.2.1/stdlib.h"
|
|
textual header "/usr/include/c++/13.2.1/thread"
|
|
textual header "/usr/include/c++/13.2.1/type_traits"
|
|
textual header "/usr/include/c++/13.2.1/vector"
|
|
textual header "/usr/include/errno.h"
|
|
textual header "/usr/include/fortify/stdio.h"
|
|
textual header "/usr/include/fortify/string.h"
|
|
textual header "/usr/include/fortify/unistd.h"
|
|
textual header "/usr/include/limits.h"
|
|
textual header "/usr/include/stdarg.h"
|
|
textual header "/usr/include/stdbool.h"
|
|
textual header "/usr/include/stddef.h"
|
|
textual header "/usr/include/stdint.h"
|
|
textual header "/usr/include/sys/time.h"
|
|
textual header "/usr/include/sys/types.h"
|
|
textual header "/usr/include/time.h"
|
|
}
|
|
module "//c-toxcore/third_party:cmp" {
|
|
header "third_party/cmp/cmp.h"
|
|
use std
|
|
}
|
|
module "//c-toxcore/toxencryptsave:defines" {
|
|
header "toxencryptsave/defines.h"
|
|
}
|
|
module "@benchmark" {
|
|
textual header "/usr/include/benchmark/benchmark.h"
|
|
use std
|
|
}
|
|
module "@com_google_googletest//:gtest" {
|
|
textual header "/usr/include/gmock/gmock.h"
|
|
textual header "/usr/include/gtest/gtest.h"
|
|
use std
|
|
}
|
|
module "@libsodium" {
|
|
textual header "/usr/include/sodium.h"
|
|
}
|
|
module "@pthread" {
|
|
textual header "/usr/include/pthread.h"
|
|
}
|
|
module "@psocket" {
|
|
textual header "/usr/include/arpa/inet.h"
|
|
textual header "/usr/include/fcntl.h"
|
|
textual header "/usr/include/fortify/sys/socket.h"
|
|
textual header "/usr/include/linux/if.h"
|
|
textual header "/usr/include/netdb.h"
|
|
textual header "/usr/include/netinet/in.h"
|
|
textual header "/usr/include/sys/epoll.h"
|
|
textual header "/usr/include/sys/ioctl.h"
|
|
}
|
|
"""
|
|
|
|
|
|
@dataclass
|
|
class Context:
|
|
pkg: str
|
|
pkg_prefix: str
|
|
|
|
def bzl_load(self, bzl: str, *syms: str) -> None:
|
|
pass
|
|
|
|
def bzl_exports_files(
|
|
self,
|
|
srcs: list[str],
|
|
visibility: Optional[list[str]] = None,
|
|
) -> None:
|
|
pass
|
|
|
|
def bzl_cc_library(
|
|
self,
|
|
name: str,
|
|
srcs: Iterable[str] = tuple(),
|
|
hdrs: Iterable[str] = tuple(),
|
|
deps: Iterable[str] = tuple(),
|
|
visibility: Iterable[str] = tuple(),
|
|
testonly: bool = False,
|
|
copts: Iterable[str] = tuple(),
|
|
) -> None:
|
|
LIBS[name] = {
|
|
"srcs":
|
|
srcs,
|
|
"deps": [
|
|
f"{self.pkg_prefix}{dep}" if dep[0] == ":" else dep
|
|
for dep in deps
|
|
],
|
|
"hdrs":
|
|
hdrs,
|
|
}
|
|
|
|
def bzl_cc_binary(
|
|
self,
|
|
name: str,
|
|
srcs: Iterable[str] = tuple(),
|
|
hdrs: Iterable[str] = tuple(),
|
|
deps: Iterable[str] = tuple(),
|
|
**kwargs: list[str],
|
|
) -> None:
|
|
LIBS[name] = {
|
|
"srcs":
|
|
srcs,
|
|
"deps": [
|
|
f"{self.pkg_prefix}{dep}" if dep[0] == ":" else dep
|
|
for dep in deps
|
|
],
|
|
"hdrs":
|
|
hdrs,
|
|
}
|
|
|
|
def bzl_cc_fuzz_test(self, name: str, **kwargs: list[str]) -> None:
|
|
pass
|
|
|
|
def bzl_select(self, selector: dict[str, list[str]]) -> list[str]:
|
|
return selector["//tools/config:linux"]
|
|
|
|
def bzl_glob(self, include: list[str]) -> list[str]:
|
|
return [
|
|
f[len(self.pkg) + 1:] for p in include
|
|
for f in glob.glob(os.path.join(self.pkg, p))
|
|
]
|
|
|
|
def bzl_alias(self, name: str, actual: str, visibility: list[str]) -> None:
|
|
pass
|
|
|
|
def bzl_sh_library(self, name: str, **kwargs: list[str]) -> None:
|
|
pass
|
|
|
|
|
|
def main() -> None:
|
|
srcs: list[str] = []
|
|
for pkg in ("toxcore", ):
|
|
# TODO(iphydf): Why does this break everything?
|
|
# ctx = Context(pkg, "//c-toxcore/{pkg}")
|
|
ctx = Context(pkg, "")
|
|
with open(os.path.join(pkg, "BUILD.bazel"), "r") as fh:
|
|
exec(
|
|
fh.read(),
|
|
{
|
|
"load": ctx.bzl_load,
|
|
"exports_files": ctx.bzl_exports_files,
|
|
"cc_library": ctx.bzl_cc_library,
|
|
"cc_binary": ctx.bzl_cc_binary,
|
|
"cc_test": ctx.bzl_cc_binary,
|
|
"cc_fuzz_test": ctx.bzl_cc_fuzz_test,
|
|
"select": ctx.bzl_select,
|
|
"glob": ctx.bzl_glob,
|
|
"alias": ctx.bzl_alias,
|
|
"sh_library": ctx.bzl_sh_library,
|
|
},
|
|
)
|
|
|
|
with open("module.modulemap", "w") as fh:
|
|
fh.write(STD_MODULE)
|
|
for name, lib in LIBS.items():
|
|
fh.write(f'module "{ctx.pkg_prefix}:{name}"' + " {\n")
|
|
for hdr in lib["hdrs"]:
|
|
fh.write(f' header "{pkg}/{hdr}"\n')
|
|
fh.write(f" use std\n")
|
|
for dep in lib.get("deps", []):
|
|
fh.write(f' use "{dep}"\n')
|
|
fh.write("}\n")
|
|
|
|
for name, lib in LIBS.items():
|
|
for src in lib.get("srcs", []):
|
|
MODS[os.path.join(pkg, src)] = name
|
|
srcs.extend(
|
|
os.path.join(pkg, src) # just within a package for now
|
|
for lib in LIBS.values() for src in lib.get("srcs", []))
|
|
# subprocess.run(["cat", "module.modulemap"], check=True)
|
|
for src in sorted(
|
|
set(srcs) - set([
|
|
# TODO(iphydf): Figure out what's wrong here.
|
|
"toxcore/crypto_core_test.cc",
|
|
"toxcore/group_announce_test.cc",
|
|
"toxcore/group_moderation_test.cc",
|
|
"toxcore/mono_time_test.cc",
|
|
"toxcore/network_test.cc",
|
|
"toxcore/ping_array_test.cc",
|
|
"toxcore/util_test.cc",
|
|
])):
|
|
print(f"Validating {src}", file=sys.stderr)
|
|
subprocess.run(
|
|
[
|
|
"clang",
|
|
"-fsyntax-only",
|
|
"-xc++",
|
|
"-Wall",
|
|
"-Werror",
|
|
"-Wno-missing-braces",
|
|
"-DTCP_SERVER_USE_EPOLL",
|
|
"-std=c++23",
|
|
"-fdiagnostics-color=always",
|
|
"-fmodules",
|
|
"-fmodules-strict-decluse",
|
|
"-fmodule-map-file=module.modulemap",
|
|
f"-fmodule-name={ctx.pkg_prefix}:{MODS[src]}",
|
|
src,
|
|
],
|
|
check=True,
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|