Green Sky 3105cc20ef Squashed 'external/toxcore/c-toxcore/' changes from d9b8fa6098d..81b1e4f6348
81b1e4f6348 chore: Release v0.2.21-rc.1
9303e2e49a1 chore: Update the pkgsrc versions in the update-versions tool
71ec4b3b1e9 chore: Update the version-sync script to work in a post-tox.api.h world
66da842f753 chore: Add version update script compatible with ci-tools.
199878f7660 chore: Use new bazel script for circle ci.
8278e9cda46 chore: Add release issue template and workflow.
a9bb3a1c4d1 chore: Fix alpine-s390x build.
6e0a641272e chore: Add a source tarball deploy workflow.
4adebe4d8b1 chore: Don't upload ios/macos variants in deploy workflows.
18f1d858ccb chore: Move one of the 3 freebsd builds to post-submit.
432ab60c002 feat: Add a Makefile for the single file deploy build.
a86c0011fd5 chore: Add deploy job for single C file library.
2e7495e8f2a docs: Update changelog format to use the new clog-compatible way.
a682da99e84 chore: Export wasmExports from the wasm binary.
12f34cdff27 chore: Add wasm to the nightly binary deploys.
1451029613f chore: Add strict-abi support for macOS/iOS.
c53c30e09d9 chore: Add time option to manual fuzz trigger.
2ccecdc2a1a chore: Add remaining fuzz tests to cflite.
4626c2e230e test: Add a Net_Crypto fuzz test.
b4a0e617c48 refactor: Use IP string length from ip_ntoa instead of strlen.
b85b91f22f6 cleanup: rename getnodes/sendnodes to nodes request/response This change alignes the naming to be closer to the spec and make it less ambiguous. This change also changes the naming of some private/experimental marked APIs. - tox_callback_dht_nodes_response() - tox_dht_nodes_request() - Tox_Event_Dht_Get_Nodes_Response
f1991aaa029 perf: Use stack allocation for strerror rendering.
3984211ccbf cleanup: remove kicked peers from saved peers list
26a991ed2be fix: ip to string function not accepting tcp families
712861f2e6d cleanup: Make websockify output qtox-compatible logging.
01932ea2f73 chore: Add opus and vpx to the toxcore wasm build.
d29c42ef631 refactor: don't fully discard received DHT nodes. This is mostly forward thinking, where we might introduce other ip families, in addition to ipv4, ipv6, tcp_ipv4 etc.
21e2325934f chore: Fix xcframework tarball creation.
b10c8b766ba chore: Fix xcframework checksum creation.
93787a9322e chore: Add ios/macos framework build.
9f723f891d3 fix: run do_gca also in bootstrap nodes
496cc703556 chore: Support arm64 iphone simulator.
aa0e2a8e928 chore: Add support for more iOS architectures.
13ad8e81cbf chore: Add binary deploy workflows.
c8344726378 refactor: Move tox_log_level out into its own file.
8799bea76c3 cleanup: Mark events/dispatch headers as experimental.
d4164edb548 refactor: Remove tox_types.h; use `struct` tags instead.
d408c982090 refactor: Move `Tox_Options` to `tox_options.h`.
5ab42d41209 chore: Move most cirrus jobs to circleci.
463eeae1144 cleanup: Avoid clashing with global define `DEBUG`.
92cc1e91747 refactor: Make Tox_Options own the passed proxy host and savedata.
f276b397226 test: Add some more asserts for I/O and alloc to succeed.
edb4dfc4869 fix: Don't crash on malloc failures in bin_unpack.
be457d5d0b2 cleanup: Use tox memory for bin_unpack and net_strerror.

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: 81b1e4f6348124784088591c4fe9ab41e273031d
2025-03-12 19:16:50 +01:00

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++/14.2.0/algorithm"
textual header "/usr/include/c++/14.2.0/array"
textual header "/usr/include/c++/14.2.0/chrono"
textual header "/usr/include/c++/14.2.0/cstddef"
textual header "/usr/include/c++/14.2.0/cstdint"
textual header "/usr/include/c++/14.2.0/cstdio"
textual header "/usr/include/c++/14.2.0/cstdlib"
textual header "/usr/include/c++/14.2.0/cstring"
textual header "/usr/include/c++/14.2.0/iomanip"
textual header "/usr/include/c++/14.2.0/iosfwd"
textual header "/usr/include/c++/14.2.0/limits"
textual header "/usr/include/c++/14.2.0/memory"
textual header "/usr/include/c++/14.2.0/ostream"
textual header "/usr/include/c++/14.2.0/random"
textual header "/usr/include/c++/14.2.0/stdlib.h"
textual header "/usr/include/c++/14.2.0/thread"
textual header "/usr/include/c++/14.2.0/type_traits"
textual header "/usr/include/c++/14.2.0/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()