Merge commit '565efa4f39650d09c05f3895f9a2b16d0f5e7bad'
Some checks failed
ContinuousDelivery / linux-ubuntu (push) Has been cancelled
ContinuousDelivery / linux-debian12 (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android-23]) (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android-23]) (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android-23]) (push) Has been cancelled
ContinuousDelivery / windows (windows-2022, ) (push) Has been cancelled
ContinuousDelivery / windows (windows-2022, asan) (push) Has been cancelled
ContinuousIntegration / on ubuntu-24.04-arm (push) Has been cancelled
ContinuousIntegration / asan on ubuntu-24.04-arm (push) Has been cancelled
ContinuousIntegration / on ubuntu-latest (push) Has been cancelled
ContinuousIntegration / asan on ubuntu-latest (push) Has been cancelled
ContinuousIntegration / linux-debian12 (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android-23]) (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android-23]) (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android-23]) (push) Has been cancelled
ContinuousIntegration / macos (push) Has been cancelled
ContinuousIntegration / windows (push) Has been cancelled
ContinuousDelivery / dumpsyms (push) Has been cancelled
ContinuousDelivery / release (push) Has been cancelled

This commit is contained in:
Green Sky
2026-01-11 14:42:31 +01:00
328 changed files with 19057 additions and 13982 deletions

View File

@@ -6,6 +6,7 @@
!*.spec.in
!**/Makefile.am
!**/Makefile.inc
!tools/*
!docs/updates/*
!other/DHTnodes
!other/astyle/*

View File

@@ -19,8 +19,8 @@ $(libsodium_OBJECTS): CFLAGS += \
-Ilibsodium/src/libsodium/include/sodium
toxcore_SOURCES := $(wildcard \
auto_tests/auto_test_support.c \
auto_tests/send_message_test.c \
auto_tests/scenarios/framework/framework.c \
auto_tests/scenarios/scenario_send_message_test.c \
testing/misc_tools.c \
toxav/*.c \
toxcore/*.c \

View File

@@ -16,4 +16,4 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN git clone --depth=1 --branch=stable https://github.com/jedisct1/libsodium /work/libsodium
COPY other/docker/compcert/Makefile /work/
RUN make "-j$(nproc)"
RUN ./send_message_test | grep 'tox clients connected'
RUN ./send_message_test 2>&1 | grep 'Correctly failed to send too long message'

View File

@@ -42,6 +42,10 @@ SUPPRESSIONS += 10.8
#
# Reason: this is needed for generic callbacks to make any sense.
SUPPRESSIONS += 11.5
# A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer.
#
# Reason: we need to cast from _Nullable to _Nonnull.
SUPPRESSIONS += 11.8
# The precedence of operators within expressions should be made explicit.
#
# Reason: this asks us to add a lot of extra parentheses that don't really help

View File

@@ -4,29 +4,43 @@ import os
import subprocess
import sys
from dataclasses import dataclass
from typing import Iterable
from typing import Optional
from dataclasses import field
from typing import Any
from typing import Dict
from typing import List
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/atomic"
textual header "/usr/include/c++/14.2.0/cassert"
textual header "/usr/include/c++/14.2.0/cerrno"
textual header "/usr/include/c++/14.2.0/chrono"
textual header "/usr/include/c++/14.2.0/climits"
textual header "/usr/include/c++/14.2.0/compare"
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/deque"
textual header "/usr/include/c++/14.2.0/functional"
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/iostream"
textual header "/usr/include/c++/14.2.0/limits"
textual header "/usr/include/c++/14.2.0/map"
textual header "/usr/include/c++/14.2.0/memory"
textual header "/usr/include/c++/14.2.0/mutex"
textual header "/usr/include/c++/14.2.0/new"
textual header "/usr/include/c++/14.2.0/optional"
textual header "/usr/include/c++/14.2.0/ostream"
textual header "/usr/include/c++/14.2.0/queue"
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/string"
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"
@@ -43,29 +57,33 @@ STD_MODULE = """module std [system] {
textual header "/usr/include/sys/types.h"
textual header "/usr/include/time.h"
}
module "//c-toxcore/third_party:cmp" {
module "c_toxcore_third_party_cmp" {
header "third_party/cmp/cmp.h"
use std
}
module "//c-toxcore/toxencryptsave:defines" {
module "c_toxcore_toxencryptsave_defines" {
header "toxencryptsave/defines.h"
}
module "@benchmark" {
module "_benchmark" {
textual header "/usr/include/benchmark/benchmark.h"
use std
}
module "@com_google_googletest//:gtest" {
module "_com_google_googletest___gtest" {
textual header "/usr/include/gmock/gmock.h"
textual header "/usr/include/gtest/gtest.h"
use std
}
module "@libsodium" {
module "_com_google_googletest___gtest_main" {
// Dummy module for gtest_main, assuming it links but headers are in gtest
use "_com_google_googletest___gtest"
}
module "_libsodium" {
textual header "/usr/include/sodium.h"
}
module "@pthread" {
module "_pthread" {
textual header "/usr/include/pthread.h"
}
module "@psocket" {
module "_psocket" {
textual header "/usr/include/arpa/inet.h"
textual header "/usr/include/fcntl.h"
textual header "/usr/include/fortify/sys/socket.h"
@@ -79,94 +97,132 @@ module "@psocket" {
@dataclass
class Context:
pkg: str
pkg_prefix: str
class Target:
name: str
package: str
srcs: List[str] = field(default_factory=list)
hdrs: List[str] = field(default_factory=list)
deps: List[str] = field(default_factory=list)
def bzl_load(self, bzl: str, *syms: str) -> None:
@property
def label(self) -> str:
# Sanitize label for module name
sanitized = (f"//c-toxcore/{self.package}:{self.name}".replace(
"/", "_").replace(":",
"_").replace(".",
"_").replace("-",
"_").replace("@", "_"))
if sanitized.startswith("__"):
sanitized = sanitized[2:]
return sanitized
TARGETS: List[Target] = []
class BuildContext:
def __init__(self, package: str):
self.package = package
def bzl_load(self, *args: Any, **kwargs: Any) -> None:
pass
def bzl_exports_files(
self,
srcs: list[str],
visibility: Optional[list[str]] = None,
) -> None:
def bzl_exports_files(self, *args: Any, **kwargs: Any) -> 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:
def bzl_alias(self, *args: Any, **kwargs: Any) -> 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:
def bzl_sh_library(self, *args: Any, **kwargs: Any) -> None:
pass
def bzl_sh_library(self, name: str, **kwargs: list[str]) -> None:
def bzl_cc_fuzz_test(self, *args: Any, **kwargs: Any) -> None:
pass
def bzl_select(self, selector: Dict[str, List[str]]) -> List[str]:
return selector.get("//tools/config:linux",
selector.get("//conditions:default", []))
def bzl_glob(self, include: List[str]) -> List[str]:
results = []
for pattern in include:
full_pattern = os.path.join(self.package, pattern)
files = glob.glob(full_pattern)
results.extend([os.path.relpath(f, self.package) for f in files])
return results
def _add_target(self, name: str, srcs: Any, hdrs: Any, deps: Any) -> None:
srcs = list(srcs) if srcs else []
hdrs = list(hdrs) if hdrs else []
deps = list(deps) if deps else []
TARGETS.append(Target(name, self.package, srcs, hdrs, deps))
def bzl_cc_library(self,
name: str,
srcs: Any = (),
hdrs: Any = (),
deps: Any = (),
**kwargs: Any) -> None:
self._add_target(name, srcs, hdrs, deps)
def bzl_cc_binary(self,
name: str,
srcs: Any = (),
hdrs: Any = (),
deps: Any = (),
**kwargs: Any) -> None:
self._add_target(name, srcs, hdrs, deps)
def bzl_cc_test(self,
name: str,
srcs: Any = (),
hdrs: Any = (),
deps: Any = (),
**kwargs: Any) -> None:
self._add_target(name, srcs, hdrs, deps)
def resolve_module_name(dep: str, current_pkg: str) -> str:
# Resolve to canonical label first
label = dep
if dep.startswith("@"):
label = dep
elif dep.startswith("//"):
if ":" in dep:
label = dep
else:
pkg_name = os.path.basename(dep)
label = f"{dep}:{pkg_name}"
elif dep.startswith(":"):
label = f"//c-toxcore/{current_pkg}{dep}"
# Sanitize
sanitized = (label.replace("/", "_").replace(":", "_").replace(
".", "_").replace("-", "_").replace("@", "_"))
if sanitized.startswith("__"):
sanitized = sanitized[2:]
return sanitized
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:
packages = ["toxcore", "testing/support"]
for pkg in packages:
ctx = BuildContext(pkg)
build_file = os.path.join(pkg, "BUILD.bazel")
if not os.path.exists(build_file):
continue
with open(build_file, "r") as f:
exec(
fh.read(),
f.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_test": ctx.bzl_cc_test,
"cc_fuzz_test": ctx.bzl_cc_fuzz_test,
"select": ctx.bzl_select,
"glob": ctx.bzl_glob,
@@ -175,36 +231,36 @@ def main() -> None:
},
)
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")
with open("module.modulemap", "w") as f:
f.write(STD_MODULE)
for t in TARGETS:
f.write(f'module "{t.label}" {{\n')
for hdr in t.hdrs:
f.write(f' header "{os.path.join(t.package, hdr)}"\n')
f.write(" use std\n")
for dep in t.deps:
mod_name = resolve_module_name(dep, t.package)
# Export all dependencies to ensure visibility of types used in headers
f.write(f" use {mod_name}\n")
f.write(f" export {mod_name}\n")
f.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",
])):
# with open("module.modulemap", "r") as f:
# print(f.read(), file=sys.stderr)
src_to_module = {}
for t in TARGETS:
for src in t.srcs:
full_src = os.path.join(t.package, src)
src_to_module[full_src] = t.label
# Sort for deterministic output
all_srcs = sorted(src_to_module.keys())
for src in all_srcs:
print(f"Validating {src}", file=sys.stderr)
module_name = src_to_module[src]
subprocess.run(
[
"clang",
@@ -219,7 +275,8 @@ def main() -> None:
"-fmodules",
"-fmodules-strict-decluse",
"-fmodule-map-file=module.modulemap",
f"-fmodule-name={ctx.pkg_prefix}:{MODS[src]}",
f"-fmodule-name={module_name}",
"-I.",
src,
],
check=True,

View File

@@ -1,5 +1,6 @@
SOURCES := auto_tests/send_message_test.c \
auto_tests/auto_test_support.c \
SOURCES := \
auto_tests/scenarios/framework/framework.c \
auto_tests/scenarios/scenario_send_message_test.c \
testing/misc_tools.c \
$(wildcard tox*/*.c tox*/*/*.c) \
third_party/cmp/cmp.c

View File

@@ -41,4 +41,4 @@ COPY other/docker/slimcc/Makefile /work/c-toxcore/
RUN ["make"]
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN ./send_message_test | grep "tox clients connected"
RUN ./send_message_test 2>&1 | grep "Correctly failed to send too long message"

View File

@@ -22,8 +22,8 @@ RUN tcc \
-o send_message_test \
-Wall -Werror \
-bench -g \
auto_tests/auto_test_support.c \
auto_tests/send_message_test.c \
auto_tests/scenarios/framework/framework.c \
auto_tests/scenarios/scenario_send_message_test.c \
testing/misc_tools.c \
toxav/*.c \
toxcore/*.c \
@@ -31,29 +31,29 @@ RUN tcc \
toxencryptsave/*.c \
third_party/cmp/*.c \
$(pkg-config --cflags --libs libsodium opus vpx) \
&& ./send_message_test | grep 'tox clients connected'
&& ./send_message_test 2>&1 | grep 'Correctly failed to send too long message'
COPY other/deploy/single-file/make_single_file /work/
RUN \
./make_single_file -core \
auto_tests/auto_test_support.c \
auto_tests/send_message_test.c \
auto_tests/scenarios/framework/framework.c \
auto_tests/scenarios/scenario_send_message_test.c \
testing/misc_tools.c | \
tcc - \
-o send_message_test \
-Wall -Werror \
-bench -g \
$(pkg-config --cflags --libs libsodium) \
&& ./send_message_test | grep 'tox clients connected'
&& ./send_message_test 2>&1 | grep 'Correctly failed to send too long message'
RUN \
./make_single_file \
auto_tests/auto_test_support.c \
auto_tests/toxav_basic_test.c \
auto_tests/scenarios/framework/framework.c \
auto_tests/scenarios/scenario_toxav_basic_test.c \
testing/misc_tools.c | \
tcc - \
-o toxav_basic_test \
-Wall -Werror \
-bench -g \
$(pkg-config --cflags --libs libsodium opus vpx) \
&& ./toxav_basic_test | grep 'Test successful'
&& ./toxav_basic_test 2>&1 | grep 'Cancel Flow finished'

View File

@@ -1,4 +1,4 @@
FROM debian:bookworm-slim
FROM debian:trixie-slim
# When editing, make sure to update /other/windows_build_script_toxcore.sh and
# INSTALL.md to match.

View File

@@ -56,7 +56,7 @@ build() {
" >windows_toolchain.cmake
if [ "$ENABLE_TEST" = "true" ]; then
echo "SET(CROSSCOMPILING_EMULATOR /usr/bin/wine)" >>windows_toolchain.cmake
echo "SET(CMAKE_CROSSCOMPILING_EMULATOR /usr/bin/wine)" >>windows_toolchain.cmake
fi
if [ "$ARCH" = "i686" ]; then

View File

@@ -43,19 +43,19 @@ if [ "$SUPPORT_TEST" = "true" ]; then
CURL_OPTIONS=(-L --connect-timeout 10)
# While we would prefer to use Debian's Wine packages, use WineHQ's packages
# instead as Debian Bookworm's Wine crashes when creating a 64-bit prefix.
# instead as Debian Trixie's Wine crashes when creating a 64-bit prefix.
# see https://github.com/TokTok/c-toxcore/pull/2713#issuecomment-1967319113
# for the crash details
curl "${CURL_OPTIONS[@]}" -o /etc/apt/keyrings/winehq-archive.key \
https://dl.winehq.org/wine-builds/winehq.key
curl "${CURL_OPTIONS[@]}" -O --output-dir /etc/apt/sources.list.d/ \
https://dl.winehq.org/wine-builds/debian/dists/bookworm/winehq-bookworm.sources
https://dl.winehq.org/wine-builds/debian/dists/trixie/winehq-trixie.sources
. ./check_sha256.sh
check_sha256 "d965d646defe94b3dfba6d5b4406900ac6c81065428bf9d9303ad7a72ee8d1b8" \
"/etc/apt/keyrings/winehq-archive.key"
check_sha256 "8dd8ef66c749d56e798646674c1c185a99b3ed6727ca0fbb5e493951e66c0f9e" \
"/etc/apt/sources.list.d/winehq-bookworm.sources"
check_sha256 "d10fb49718b5ceda9cc9c2f8f52b076772396b4b3563a1aad2ab6503414dcee7" \
"/etc/apt/sources.list.d/winehq-trixie.sources"
dpkg --add-architecture i386
apt-get update