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
This commit is contained in:
Green Sky
2025-03-12 19:16:50 +01:00
parent 3b6bb15e86
commit 3105cc20ef
130 changed files with 3604 additions and 1776 deletions

102
other/deploy/android.sh Executable file
View File

@ -0,0 +1,102 @@
#!/bin/bash
set -eu
if [ -n "${CI-}" ]; then
sudo apt-get install -y --no-install-recommends ninja-build yasm
fi
# Set up environment
NDK=$ANDROID_NDK_HOME
ABI=${1:-"armeabi-v7a"}
case $ABI in
armeabi-v7a)
TARGET=armv7a-linux-androideabi
NDK_API=21
ANDROID_VPX_ABI=armv7-android-gcc
;;
arm64-v8a)
TARGET=aarch64-linux-android
NDK_API=21
ANDROID_VPX_ABI=arm64-android-gcc
;;
x86)
TARGET=i686-linux-android
NDK_API=21
ANDROID_VPX_ABI=x86-android-gcc
;;
x86_64)
TARGET=x86_64-linux-android
NDK_API=21
ANDROID_VPX_ABI=x86_64-android-gcc
;;
*)
exit 1
;;
esac
PREFIX="$PWD/deps-prefix-android-$ABI"
TOOLCHAIN="$NDK/toolchains/llvm/prebuilt/linux-x86_64"
SYSROOT="$TOOLCHAIN/sysroot"
export CC="$TOOLCHAIN/bin/$TARGET$NDK_API-clang"
export CXX="$TOOLCHAIN/bin/$TARGET$NDK_API-clang++"
export LDFLAGS=-static-libstdc++
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig"
# Build libsodium
if [ ! -f "$PREFIX/lib/libsodium.a" ]; then
tar zxf <(wget -O- https://github.com/jedisct1/libsodium/releases/download/1.0.20-RELEASE/libsodium-1.0.20.tar.gz)
pushd libsodium-1.0.20
./configure --prefix="$PREFIX" --host="$TARGET" --with-sysroot="$SYSROOT" --disable-shared --disable-pie
make -j"$(nproc)" install
popd
rm -rf libsodium-1.0.20
fi
# Build opus
if [ ! -f "$PREFIX/lib/libopus.a" ]; then
tar zxf <(wget -O- https://github.com/xiph/opus/releases/download/v1.5.2/opus-1.5.2.tar.gz)
pushd opus-1.5.2
CFLAGS="-fPIC" ./configure --prefix="$PREFIX" --host="$TARGET" --with-sysroot="$SYSROOT" --disable-shared
make "-j$(nproc)"
make install
popd
rm -rf opus-1.5.2
fi
# Build libvpx
if [ ! -f "$PREFIX/lib/libvpx.a" ]; then
tar zxf <(wget -O- https://github.com/webmproject/libvpx/archive/refs/tags/v1.15.0.tar.gz)
pushd libvpx-1.15.0
./configure --prefix="$PREFIX" --libc="$SYSROOT" --target="$ANDROID_VPX_ABI" --disable-examples --disable-unit-tests --enable-pic ||
(cat config.log && exit 1)
sed -i -e "s!^AS=as!AS=$CC -c!" ./*.mk
sed -i -e "s!^STRIP=strip!STRIP=$TOOLCHAIN/bin/llvm-strip!" ./*.mk
make "-j$(nproc)"
make install
popd
rm -rf libvpx-1.15.0
fi
# Build c-toxcore
rm -rf _build
cmake -B _build -G Ninja \
-DANDROID_ABI="$ABI" \
-DCMAKE_TOOLCHAIN_FILE="$NDK/build/cmake/android.toolchain.cmake" \
-DCMAKE_INSTALL_PREFIX="$PWD/toxcore-android-$ABI" \
-DCMAKE_PREFIX_PATH="$PREFIX" \
-DENABLE_STATIC=OFF \
-DENABLE_SHARED=ON \
-DMUST_BUILD_TOXAV=ON \
-DDHT_BOOTSTRAP=OFF \
-DBOOTSTRAP_DAEMON=OFF \
-DUNITTEST=OFF \
-DSTRICT_ABI=ON \
-DMIN_LOGGER_LEVEL=TRACE \
-DEXPERIMENTAL_API=ON
cmake --build _build
cmake --install _build

5
other/deploy/apple/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
/Tox.xcframework
/toxcore-ios*
/toxcore-iphonesimulator*
/toxcore-macos*
/smoke-test.c

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>Tox</string>
<key>CFBundleName</key>
<string>Tox</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>chat.tox.toxcore</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.2.20</string>
<key>CFBundleShortVersionString</key>
<string>0.2.20</string>
<key>CFBundleGetInfoString</key>
<string>Tox Framework</string>
</dict>
</plist>

1
other/deploy/apple/LICENSE Symbolic link
View File

@ -0,0 +1 @@
../../../LICENSE

View File

@ -0,0 +1,29 @@
#!/bin/bash
# Download the nightly builds of Tox for iOS, iPhone simulator, and macOS.
set -eux -o pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
for arch in arm64 armv7 armv7s; do
if [ ! -d "toxcore-ios-$arch" ]; then
tar -zxf \
<(curl -L "https://github.com/TokTok/c-toxcore/releases/download/nightly/toxcore-nightly-ios-$arch.tar.gz")
fi
done
for arch in arm64 x86_64; do
if [ ! -d "toxcore-iphonesimulator-$arch" ]; then
tar -zxf \
<(curl -L "https://github.com/TokTok/c-toxcore/releases/download/nightly/toxcore-nightly-iphonesimulator-$arch.tar.gz")
fi
done
for arch in arm64 x86_64; do
if [ ! -d "toxcore-macos-$arch" ]; then
tar -zxf \
<(curl -L "https://github.com/TokTok/c-toxcore/releases/download/nightly/toxcore-nightly-macos-$arch.tar.gz")
fi
done

View File

@ -0,0 +1,71 @@
#!/bin/bash
# Make a Tox.xcframework for iOS, iPhone simulator, and macOS from the nightly builds.
#
# Run download-nightly.sh before running this script if you run it locally.
set -eux -o pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Make a Tox.framework for iOS.
rm -rf toxcore-ios/Tox.framework
mkdir -p toxcore-ios/Tox.framework
cp Info.plist toxcore-ios/Tox.framework
cp -r toxcore-ios-arm64/include/tox toxcore-ios/Tox.framework/Headers
lipo -create -output toxcore-ios/Tox.framework/Tox \
toxcore-ios-arm64/lib/libtoxcore.dylib \
toxcore-ios-armv7/lib/libtoxcore.dylib \
toxcore-ios-armv7s/lib/libtoxcore.dylib
install_name_tool -id @rpath/Tox.framework/Tox toxcore-ios/Tox.framework/Tox
# Make a Tox.framework for iPhone simulator.
rm -rf toxcore-iphonesimulator/Tox.framework
mkdir -p toxcore-iphonesimulator/Tox.framework
cp Info.plist toxcore-iphonesimulator/Tox.framework
cp -r toxcore-iphonesimulator-arm64/include/tox toxcore-iphonesimulator/Tox.framework/Headers
lipo -create -output toxcore-iphonesimulator/Tox.framework/Tox \
toxcore-iphonesimulator-arm64/lib/libtoxcore.dylib \
toxcore-iphonesimulator-x86_64/lib/libtoxcore.dylib
install_name_tool -id @rpath/Tox.framework/Tox toxcore-iphonesimulator/Tox.framework/Tox
# Make a Tox.framework for macOS.
rm -rf toxcore-macos/Tox.framework
mkdir -p toxcore-macos/Tox.framework
cp Info.plist toxcore-macos/Tox.framework
cp -r toxcore-macos-arm64/include/tox toxcore-macos/Tox.framework/Headers
lipo -create -output toxcore-macos/Tox.framework/Tox \
toxcore-macos-arm64/lib/libtoxcore.dylib \
toxcore-macos-x86_64/lib/libtoxcore.dylib
install_name_tool -id @rpath/Tox.framework/Tox toxcore-macos/Tox.framework/Tox
# Make a Tox.xcframework for iOS, iPhone simulator, and macOS.
rm -rf Tox.xcframework
xcodebuild -create-xcframework -output Tox.xcframework \
-framework toxcore-ios/Tox.framework \
-framework toxcore-iphonesimulator/Tox.framework \
-framework toxcore-macos/Tox.framework
# Test the Tox.xcframework.
cat >smoke-test.c <<'EOF'
#include <stdio.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdocumentation-deprecated-sync"
#include <tox/tox.h>
#pragma GCC diagnostic pop
int main(void) {
Tox *tox = tox_new(NULL, NULL);
if (tox == NULL) {
fprintf(stderr, "tox_new failed\n");
return 1;
}
tox_kill(tox);
return 0;
}
EOF
pod lib lint toxcore.podspec
rm smoke-test.c

View File

@ -0,0 +1,24 @@
Pod::Spec.new do |s|
s.name = "toxcore"
s.version = "0.2.20"
s.summary = "Cocoapods wrapper for toxcore"
s.homepage = "https://github.com/TokTok/c-toxcore"
s.license = 'GPLv3'
s.author = { "Iphigenia Df" => "iphydf@gmail.com" }
s.source = {
:git => "https://github.com/TokTok/c-toxcore.git",
:tag => s.version.to_s,
:submodules => true
}
s.requires_arc = false
s.ios.deployment_target = '12.0'
s.osx.deployment_target = '10.15'
s.vendored_frameworks = 'Tox.xcframework'
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}"' }
s.test_spec 'Tests' do |test_spec|
test_spec.source_files = 'smoke-test.c'
end
end

30
other/deploy/deps.sh Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -eux -o pipefail
SYSTEM="$1"
ARCH="$2"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
DEP_PREFIX="$PWD/deps-prefix-$SYSTEM-$ARCH"
if [ -d "$DEP_PREFIX" ]; then
exit 0
fi
if [ -d ../dockerfiles ]; then
DOCKERFILES="$(realpath ../dockerfiles)"
else
git clone --depth=1 https://github.com/TokTok/dockerfiles "$SCRIPT_DIR/dockerfiles"
DOCKERFILES="$SCRIPT_DIR/dockerfiles"
fi
for dep in sodium opus vpx; do
mkdir -p "external/$dep"
pushd "external/$dep"
SCRIPT="$DOCKERFILES/qtox/build_$dep.sh"
"$SCRIPT" --arch "$SYSTEM-$ARCH" --libtype "static" --buildtype "release" --prefix "$DEP_PREFIX" --macos "10.15"
popd
rm -rf "external/$dep"
done

58
other/deploy/ios.sh Executable file
View File

@ -0,0 +1,58 @@
#!/usr/bin/env bash
set -eux -o pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
TARGET="$1"
if [ -n "${CI-}" ]; then
brew install bash coreutils ninja yasm
fi
SYSTEM="${TARGET%%-*}"
ARCH="${TARGET#*-}"
"$SCRIPT_DIR/deps.sh" "$SYSTEM" "$ARCH"
export PKG_CONFIG_PATH="$PWD/deps-prefix-$SYSTEM-$ARCH/lib/pkgconfig"
if [ "$SYSTEM" = "ios" ]; then
XC_SDK="iphoneos"
TARGET_IPHONE_SIMULATOR=OFF
IOS_FLAGS="-miphoneos-version-min=10.0 -arch $ARCH"
elif [ "$SYSTEM" = "iphonesimulator" ]; then
XC_SDK="iphonesimulator"
TARGET_IPHONE_SIMULATOR=ON
IOS_FLAGS="-arch $ARCH"
else
echo "Unexpected system $SYSTEM"
exit 1
fi
BUILD_DIR="_build-$SYSTEM-$ARCH"
# Build for iOS 10
cmake \
-B "$BUILD_DIR" \
-G Ninja \
-DCMAKE_INSTALL_PREFIX="$PWD/toxcore-$SYSTEM-$ARCH" \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_STATIC=OFF \
-DENABLE_SHARED=ON \
-DMUST_BUILD_TOXAV=ON \
-DDHT_BOOTSTRAP=OFF \
-DBOOTSTRAP_DAEMON=OFF \
-DUNITTEST=OFF \
-DSTRICT_ABI=ON \
-DMIN_LOGGER_LEVEL=TRACE \
-DEXPERIMENTAL_API=ON \
-DCMAKE_C_FLAGS="$IOS_FLAGS" \
-DCMAKE_CXX_FLAGS="$IOS_FLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="$IOS_FLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS="$IOS_FLAGS" \
-DCMAKE_OSX_SYSROOT="$(xcrun --sdk "$XC_SDK" --show-sdk-path)" \
-DCMAKE_OSX_ARCHITECTURES="$ARCH"
cmake --build "$BUILD_DIR"
cmake --install "$BUILD_DIR"

29
other/deploy/linux.sh Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -eux -o pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ARCH="$1"
"$SCRIPT_DIR/deps.sh" linux "$ARCH"
export PKG_CONFIG_PATH="$PWD/deps-prefix-linux-$ARCH/lib/pkgconfig"
# Build
cmake \
-B _build \
-G Ninja \
-DCMAKE_INSTALL_PREFIX="$PWD/toxcore-linux-$ARCH" \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_STATIC=OFF \
-DENABLE_SHARED=ON \
-DMUST_BUILD_TOXAV=ON \
-DDHT_BOOTSTRAP=OFF \
-DBOOTSTRAP_DAEMON=OFF \
-DUNITTEST=OFF \
-DSTRICT_ABI=ON \
-DMIN_LOGGER_LEVEL=TRACE \
-DEXPERIMENTAL_API=ON
cmake --build _build
cmake --install _build

37
other/deploy/macos.sh Executable file
View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -eux -o pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ARCH="$1"
if [ -n "${CI-}" ]; then
brew install bash coreutils ninja yasm
fi
"$SCRIPT_DIR/deps.sh" macos "$ARCH"
export PKG_CONFIG_PATH="$PWD/deps-prefix-macos-$ARCH/lib/pkgconfig"
BUILD_DIR="_build-macos-$ARCH"
# Build for macOS
cmake \
-B "$BUILD_DIR" \
-G Ninja \
-DCMAKE_INSTALL_PREFIX="$PWD/toxcore-macos-$ARCH" \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_STATIC=OFF \
-DENABLE_SHARED=ON \
-DMUST_BUILD_TOXAV=ON \
-DDHT_BOOTSTRAP=OFF \
-DBOOTSTRAP_DAEMON=OFF \
-DUNITTEST=OFF \
-DSTRICT_ABI=ON \
-DMIN_LOGGER_LEVEL=TRACE \
-DEXPERIMENTAL_API=ON \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15
cmake --build "$BUILD_DIR"
cmake --install "$BUILD_DIR"

1
other/deploy/single-file/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
!/Makefile

View File

@ -0,0 +1,26 @@
TARGETS = libtoxcore.a libtoxcore-minimal.a
all: $(TARGETS)
libtoxcore.o: $(wildcard toxcore-*av.c)
$(CC) -c -o $@ $< \
-O2 \
-Wno-discarded-qualifiers \
-fPIC \
-Wl,-Bstatic \
$(shell pkg-config --cflags --libs libsodium) \
-Wl,-Bdynamic \
$(shell pkg-config --cflags --libs opus vpx) \
-pthread
libtoxcore-minimal.o: $(wildcard toxcore-*core.c)
$(CC) -c -o $@ $< \
-O2 \
-Wno-discarded-qualifiers \
-fPIC \
-Wl,-Bstatic \
$(shell pkg-config --cflags --libs libsodium) \
-pthread
%.a: %.o
$(AR) rcs $@ $^

View File

@ -0,0 +1,60 @@
#!/usr/bin/env perl
#
# This script can be used to create a single .c file with all of toxcore in it
# as well as your code or test file. It does not depend on any header files
# anymore, as those are emitted directly into the .c file.
#
# Example:
#
# other/deploy/single-file/make_single_file auto_tests/toxav_basic_test.c auto_tests/auto_test_support.c testing/misc_tools.c | \
# tcc -o toxav_basic_test - $(pkg-config --cflags --libs libsodium opus vpx)
#
# other/deploy/single-file/make_single_file -core auto_tests/send_message_test.c auto_tests/auto_test_support.c testing/misc_tools.c | \
# tcc -o send_message_test - $(pkg-config --cflags --libs libsodium)
use strict;
use warnings;
use Cwd 'abs_path';
sub relative_to {
my ($rel, $fn) = @_;
my @path = split "/", $rel;
pop @path;
abs_path(join "/", @path, $fn)
}
my %seen;
sub emit {
my ($fn) = @_;
return if $seen{$fn};
$seen{$fn} = 1;
open my $fh, "<", $fn or die "$fn: $!";
my $line = 1;
print "#line $line \"$fn\"\n";
while (<$fh>) {
if (/^#include "([^"]*)"/) {
emit(relative_to($fn, $1), $1);
++$line;
print "#line $line \"$fn\"\n";
} else {
print;
++$line;
}
}
}
my @core = (<toxcore/*.c>, <toxcore/*/*.c>, <toxencryptsave/*.c>, <third_party/cmp/*.c>);
if (@ARGV and $ARGV[0] eq "-core") {
shift @ARGV;
emit(abs_path $_) for @core;
} else {
if (@ARGV and $ARGV[0] eq "-av") {
# Ignore -av, it's the default.
shift @ARGV;
}
emit(abs_path $_) for (<toxav/*.c>, @core);
}
emit(abs_path $_) for @ARGV;