Skip to content

Commit d408c98

Browse files
committed
refactor: Move Tox_Options to tox_options.h.
For backwards compatibility, we also `#include "tox_options.h"` in `tox.h`, but in 0.3.0 we can break that so most toxcore client code doesn't need the options, only the part that creates the instance.
1 parent 5ab42d4 commit d408c98

25 files changed

+1041
-859
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ jobs:
126126
steps:
127127
- checkout
128128
- run: git submodule update --init --recursive
129+
- run: /src/workspace/tools/inject-repo c-toxcore
129130
- run: cd /src/workspace &&
130131
bazel test
131132
-k

BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,29 @@ genrule(
1010
"//c-toxcore/toxcore:tox.h",
1111
"//c-toxcore/toxcore:tox_dispatch.h",
1212
"//c-toxcore/toxcore:tox_events.h",
13+
"//c-toxcore/toxcore:tox_options.h",
1314
"//c-toxcore/toxcore:tox_private.h",
15+
"//c-toxcore/toxcore:tox_types.h",
1416
"//c-toxcore/toxencryptsave:toxencryptsave.h",
1517
],
1618
outs = [
1719
"tox/toxav.h",
1820
"tox/tox.h",
1921
"tox/tox_dispatch.h",
2022
"tox/tox_events.h",
23+
"tox/tox_options.h",
2124
"tox/tox_private.h",
25+
"tox/tox_types.h",
2226
"tox/toxencryptsave.h",
2327
],
2428
cmd = """
2529
cp $(location //c-toxcore/toxav:toxav.h) $(GENDIR)/c-toxcore/tox/toxav.h
2630
cp $(location //c-toxcore/toxcore:tox.h) $(GENDIR)/c-toxcore/tox/tox.h
2731
cp $(location //c-toxcore/toxcore:tox_dispatch.h) $(GENDIR)/c-toxcore/tox/tox_dispatch.h
2832
cp $(location //c-toxcore/toxcore:tox_events.h) $(GENDIR)/c-toxcore/tox/tox_events.h
33+
cp $(location //c-toxcore/toxcore:tox_options.h) $(GENDIR)/c-toxcore/tox/tox_options.h
2934
cp $(location //c-toxcore/toxcore:tox_private.h) $(GENDIR)/c-toxcore/tox/tox_private.h
35+
cp $(location //c-toxcore/toxcore:tox_types.h) $(GENDIR)/c-toxcore/tox/tox_types.h
3036
cp $(location //c-toxcore/toxencryptsave:toxencryptsave.h) $(GENDIR)/c-toxcore/tox/toxencryptsave.h
3137
""",
3238
visibility = ["//visibility:public"],

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,14 @@ set(toxcore_SOURCES
348348
toxcore/tox_events.c
349349
toxcore/tox_events.h
350350
toxcore/tox.h
351+
toxcore/tox_options.c
352+
toxcore/tox_options.h
351353
toxcore/tox_private.c
352354
toxcore/tox_private.h
353355
toxcore/tox_pack.c
354356
toxcore/tox_pack.h
357+
toxcore/tox_types.c
358+
toxcore/tox_types.h
355359
toxcore/tox_unpack.c
356360
toxcore/tox_unpack.h
357361
toxcore/util.c
@@ -369,8 +373,10 @@ endif()
369373
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} libsodium)
370374
set(toxcore_API_HEADERS
371375
${toxcore_SOURCE_DIR}/toxcore/tox.h^tox
376+
${toxcore_SOURCE_DIR}/toxcore/tox_dispatch.h^tox
372377
${toxcore_SOURCE_DIR}/toxcore/tox_events.h^tox
373-
${toxcore_SOURCE_DIR}/toxcore/tox_dispatch.h^tox)
378+
${toxcore_SOURCE_DIR}/toxcore/tox_options.h^tox
379+
${toxcore_SOURCE_DIR}/toxcore/tox_types.h^tox)
374380
if(EXPERIMENTAL_API)
375381
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
376382
${toxcore_SOURCE_DIR}/toxcore/tox_private.h^tox)

cmake/StrictAbi.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ function(_make_version_script target)
3232
COMMAND ${SHELL} -c "egrep '^\\w' ${header} | grep '${ns}_[a-z0-9_]*(' | grep -v '^typedef' | grep -o '${ns}_[a-z0-9_]*(' | egrep -o '[a-z0-9_]+' | sort -u"
3333
OUTPUT_VARIABLE sublib_SYMS
3434
OUTPUT_STRIP_TRAILING_WHITESPACE)
35+
if("${sublib_SYMS}" STREQUAL "")
36+
continue()
37+
endif()
3538
string(REPLACE "\n" ";" sublib_SYMS ${sublib_SYMS})
3639

3740
foreach(sym ${sublib_SYMS})

other/docker/modules/check

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ MODS = {}
1212
STD_MODULE = """module std [system] {
1313
textual header "/usr/include/alloca.h"
1414
textual header "/usr/include/assert.h"
15-
textual header "/usr/include/c++/13.2.1/algorithm"
16-
textual header "/usr/include/c++/13.2.1/array"
17-
textual header "/usr/include/c++/13.2.1/chrono"
18-
textual header "/usr/include/c++/13.2.1/cstddef"
19-
textual header "/usr/include/c++/13.2.1/cstdint"
20-
textual header "/usr/include/c++/13.2.1/cstdio"
21-
textual header "/usr/include/c++/13.2.1/cstdlib"
22-
textual header "/usr/include/c++/13.2.1/cstring"
23-
textual header "/usr/include/c++/13.2.1/iomanip"
24-
textual header "/usr/include/c++/13.2.1/iosfwd"
25-
textual header "/usr/include/c++/13.2.1/limits"
26-
textual header "/usr/include/c++/13.2.1/memory"
27-
textual header "/usr/include/c++/13.2.1/ostream"
28-
textual header "/usr/include/c++/13.2.1/random"
29-
textual header "/usr/include/c++/13.2.1/stdlib.h"
30-
textual header "/usr/include/c++/13.2.1/thread"
31-
textual header "/usr/include/c++/13.2.1/type_traits"
32-
textual header "/usr/include/c++/13.2.1/vector"
15+
textual header "/usr/include/c++/14.2.0/algorithm"
16+
textual header "/usr/include/c++/14.2.0/array"
17+
textual header "/usr/include/c++/14.2.0/chrono"
18+
textual header "/usr/include/c++/14.2.0/cstddef"
19+
textual header "/usr/include/c++/14.2.0/cstdint"
20+
textual header "/usr/include/c++/14.2.0/cstdio"
21+
textual header "/usr/include/c++/14.2.0/cstdlib"
22+
textual header "/usr/include/c++/14.2.0/cstring"
23+
textual header "/usr/include/c++/14.2.0/iomanip"
24+
textual header "/usr/include/c++/14.2.0/iosfwd"
25+
textual header "/usr/include/c++/14.2.0/limits"
26+
textual header "/usr/include/c++/14.2.0/memory"
27+
textual header "/usr/include/c++/14.2.0/ostream"
28+
textual header "/usr/include/c++/14.2.0/random"
29+
textual header "/usr/include/c++/14.2.0/stdlib.h"
30+
textual header "/usr/include/c++/14.2.0/thread"
31+
textual header "/usr/include/c++/14.2.0/type_traits"
32+
textual header "/usr/include/c++/14.2.0/vector"
3333
textual header "/usr/include/errno.h"
3434
textual header "/usr/include/fortify/stdio.h"
3535
textual header "/usr/include/fortify/string.h"

other/docker/modules/dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
!other/docker/modules/check
2+
!**/BUILD.bazel

other/docker/modules/modules.Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
FROM toxchat/c-toxcore:sources AS sources
2-
FROM alpine:3.19.0
1+
FROM alpine:3.21.0
32

43
RUN ["apk", "add", "--no-cache", \
54
"bash", \
@@ -15,7 +14,7 @@ RUN ["apk", "add", "--no-cache", \
1514
"python3"]
1615

1716
WORKDIR /work
18-
COPY --from=sources /src/ /work/
17+
COPY . /work/
1918

2019
COPY toxcore/BUILD.bazel /work/toxcore/
2120
COPY other/docker/modules/check /work/other/docker/modules/
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# ===== common =====
2+
# Ignore everything ...
3+
**/*
4+
# ... except sources
5+
!**/*.[ch]
6+
!**/*.cc
7+
!**/*.hh
8+
!CHANGELOG.md
9+
!LICENSE
10+
!README.md
11+
!auto_tests/data/*
12+
!other/bootstrap_daemon/bash-completion/**
13+
!other/bootstrap_daemon/tox-bootstrapd.*
14+
!other/proxy/*.mod
15+
!other/proxy/*.sum
16+
!other/proxy/*.go
17+
# ... and CMake build files (used by most builds).
18+
!**/CMakeLists.txt
19+
!.github/scripts/flags*.sh
20+
!cmake/*.cmake
21+
!other/pkgconfig/*
22+
!other/rpm/*
23+
!so.version
24+
!other/docker/modules/check
25+
!**/BUILD.bazel

other/docker/modules/run

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22

3-
set -eux
4-
BUILD=modules
5-
other/docker/sources/build
6-
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
3+
. "$(cd "$(dirname "${BASH_SOURCE[0]}")/../sources" && pwd)/run.sh"

other/docker/pkgsrc/dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!other/docker/pkgsrc/pkgsrc.patch

other/docker/pkgsrc/pkgsrc.Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
FROM toxchat/pkgsrc:latest
22

33
WORKDIR /work
4-
COPY . /work/c-toxcore-0.2.18
5-
RUN ["tar", "zcf", "c-toxcore.tar.gz", "c-toxcore-0.2.18"]
4+
COPY . /work/c-toxcore-0.2.20
5+
RUN ["tar", "zcf", "c-toxcore.tar.gz", "c-toxcore-0.2.20"]
6+
7+
WORKDIR /work/pkgsrc
8+
COPY other/docker/pkgsrc/pkgsrc.patch /tmp/pkgsrc.patch
9+
RUN ["patch", "-p1", "-i", "/tmp/pkgsrc.patch"]
610

711
WORKDIR /work/pkgsrc/chat/toxcore
8-
RUN ["sed", "-i", "-e", "s/libtoxcore.so.2.18.0/libtoxcore.so.2.20.0/g", "PLIST"]
912
RUN ["bmake", "clean"]
1013
RUN ["bmake", "DISTFILES=c-toxcore.tar.gz", "DISTDIR=/work", "NO_CHECKSUM=yes"]
1114
RUN ["bmake", "install"]

other/docker/pkgsrc/pkgsrc.Dockerfile.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
!other/pkgconfig/*
2222
!other/rpm/*
2323
!so.version
24+
!other/docker/pkgsrc/pkgsrc.patch

other/docker/pkgsrc/pkgsrc.patch

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
diff --git a/chat/toxcore/Makefile b/chat/toxcore/Makefile
2+
index 70466704d..53a08ad08 100644
3+
--- a/chat/toxcore/Makefile
4+
+++ b/chat/toxcore/Makefile
5+
@@ -1,6 +1,6 @@
6+
# $NetBSD: Makefile,v 1.6 2024/01/22 13:16:56 ryoon Exp $
7+
8+
-DISTNAME= toxcore-0.2.18
9+
+DISTNAME= toxcore-0.2.20
10+
PKGREVISION= 2
11+
CATEGORIES= chat
12+
MASTER_SITES= ${MASTER_SITE_GITHUB:=TokTok/}
13+
diff --git a/chat/toxcore/PLIST b/chat/toxcore/PLIST
14+
index f0a5e4f04..4122b0867 100644
15+
--- a/chat/toxcore/PLIST
16+
+++ b/chat/toxcore/PLIST
17+
@@ -4,11 +4,13 @@ bin/tox-bootstrapd
18+
include/tox/tox.h
19+
include/tox/tox_dispatch.h
20+
include/tox/tox_events.h
21+
+include/tox/tox_options.h
22+
+include/tox/tox_types.h
23+
include/tox/toxav.h
24+
include/tox/toxencryptsave.h
25+
lib/libtoxcore.a
26+
lib/libtoxcore.so
27+
lib/libtoxcore.so.2
28+
-lib/libtoxcore.so.2.18.0
29+
+lib/libtoxcore.so.2.20.0
30+
lib/pkgconfig/toxcore.pc
31+
share/bash-completion/completions/tox-bootstrapd

toxcore/BUILD.bazel

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ exports_files(
66
"tox.h",
77
"tox_dispatch.h",
88
"tox_events.h",
9+
"tox_options.h",
910
"tox_private.h",
11+
"tox_types.h",
1012
],
1113
visibility = ["//c-toxcore:__subpackages__"],
1214
)
@@ -1072,6 +1074,25 @@ cc_library(
10721074
],
10731075
)
10741076

1077+
cc_library(
1078+
name = "tox_types",
1079+
srcs = ["tox_types.c"],
1080+
hdrs = ["tox_types.h"],
1081+
visibility = ["//c-toxcore:__subpackages__"],
1082+
)
1083+
1084+
cc_library(
1085+
name = "tox_options",
1086+
srcs = ["tox_options.c"],
1087+
hdrs = ["tox_options.h"],
1088+
copts = ["-UTOX_HIDE_DEPRECATED"],
1089+
visibility = ["//c-toxcore:__subpackages__"],
1090+
deps = [
1091+
":ccompat",
1092+
":tox_types",
1093+
],
1094+
)
1095+
10751096
cc_library(
10761097
name = "tox",
10771098
srcs = [
@@ -1104,6 +1125,8 @@ cc_library(
11041125
":network",
11051126
":onion_client",
11061127
":state",
1128+
":tox_options",
1129+
":tox_types",
11071130
":util",
11081131
"//c-toxcore/toxencryptsave:defines",
11091132
"@pthread",
@@ -1117,6 +1140,7 @@ cc_test(
11171140
deps = [
11181141
":crypto_core",
11191142
":tox",
1143+
":tox_options",
11201144
"@com_google_googletest//:gtest",
11211145
"@com_google_googletest//:gtest_main",
11221146
],

0 commit comments

Comments
 (0)