Skip to content

Commit

Permalink
refactor: Move Tox_Options to tox_options.h.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
iphydf committed Jan 24, 2025
1 parent 5ab42d4 commit d408c98
Show file tree
Hide file tree
Showing 25 changed files with 1,041 additions and 859 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ jobs:
steps:
- checkout
- run: git submodule update --init --recursive
- run: /src/workspace/tools/inject-repo c-toxcore
- run: cd /src/workspace &&
bazel test
-k
Expand Down
6 changes: 6 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,29 @@ genrule(
"//c-toxcore/toxcore:tox.h",
"//c-toxcore/toxcore:tox_dispatch.h",
"//c-toxcore/toxcore:tox_events.h",
"//c-toxcore/toxcore:tox_options.h",
"//c-toxcore/toxcore:tox_private.h",
"//c-toxcore/toxcore:tox_types.h",
"//c-toxcore/toxencryptsave:toxencryptsave.h",
],
outs = [
"tox/toxav.h",
"tox/tox.h",
"tox/tox_dispatch.h",
"tox/tox_events.h",
"tox/tox_options.h",
"tox/tox_private.h",
"tox/tox_types.h",
"tox/toxencryptsave.h",
],
cmd = """
cp $(location //c-toxcore/toxav:toxav.h) $(GENDIR)/c-toxcore/tox/toxav.h
cp $(location //c-toxcore/toxcore:tox.h) $(GENDIR)/c-toxcore/tox/tox.h
cp $(location //c-toxcore/toxcore:tox_dispatch.h) $(GENDIR)/c-toxcore/tox/tox_dispatch.h
cp $(location //c-toxcore/toxcore:tox_events.h) $(GENDIR)/c-toxcore/tox/tox_events.h
cp $(location //c-toxcore/toxcore:tox_options.h) $(GENDIR)/c-toxcore/tox/tox_options.h
cp $(location //c-toxcore/toxcore:tox_private.h) $(GENDIR)/c-toxcore/tox/tox_private.h
cp $(location //c-toxcore/toxcore:tox_types.h) $(GENDIR)/c-toxcore/tox/tox_types.h
cp $(location //c-toxcore/toxencryptsave:toxencryptsave.h) $(GENDIR)/c-toxcore/tox/toxencryptsave.h
""",
visibility = ["//visibility:public"],
Expand Down
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,14 @@ set(toxcore_SOURCES
toxcore/tox_events.c
toxcore/tox_events.h
toxcore/tox.h
toxcore/tox_options.c
toxcore/tox_options.h
toxcore/tox_private.c
toxcore/tox_private.h
toxcore/tox_pack.c
toxcore/tox_pack.h
toxcore/tox_types.c
toxcore/tox_types.h
toxcore/tox_unpack.c
toxcore/tox_unpack.h
toxcore/util.c
Expand All @@ -369,8 +373,10 @@ endif()
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} libsodium)
set(toxcore_API_HEADERS
${toxcore_SOURCE_DIR}/toxcore/tox.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_dispatch.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_events.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_dispatch.h^tox)
${toxcore_SOURCE_DIR}/toxcore/tox_options.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_types.h^tox)
if(EXPERIMENTAL_API)
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
${toxcore_SOURCE_DIR}/toxcore/tox_private.h^tox)
Expand Down
3 changes: 3 additions & 0 deletions cmake/StrictAbi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ function(_make_version_script target)
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"
OUTPUT_VARIABLE sublib_SYMS
OUTPUT_STRIP_TRAILING_WHITESPACE)
if("${sublib_SYMS}" STREQUAL "")
continue()
endif()
string(REPLACE "\n" ";" sublib_SYMS ${sublib_SYMS})

foreach(sym ${sublib_SYMS})
Expand Down
36 changes: 18 additions & 18 deletions other/docker/modules/check
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ 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/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"
Expand Down
2 changes: 2 additions & 0 deletions other/docker/modules/dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
!other/docker/modules/check
!**/BUILD.bazel
5 changes: 2 additions & 3 deletions other/docker/modules/modules.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM toxchat/c-toxcore:sources AS sources
FROM alpine:3.19.0
FROM alpine:3.21.0

RUN ["apk", "add", "--no-cache", \
"bash", \
Expand All @@ -15,7 +14,7 @@ RUN ["apk", "add", "--no-cache", \
"python3"]

WORKDIR /work
COPY --from=sources /src/ /work/
COPY . /work/

COPY toxcore/BUILD.bazel /work/toxcore/
COPY other/docker/modules/check /work/other/docker/modules/
Expand Down
25 changes: 25 additions & 0 deletions other/docker/modules/modules.Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# ===== common =====
# Ignore everything ...
**/*
# ... except sources
!**/*.[ch]
!**/*.cc
!**/*.hh
!CHANGELOG.md
!LICENSE
!README.md
!auto_tests/data/*
!other/bootstrap_daemon/bash-completion/**
!other/bootstrap_daemon/tox-bootstrapd.*
!other/proxy/*.mod
!other/proxy/*.sum
!other/proxy/*.go
# ... and CMake build files (used by most builds).
!**/CMakeLists.txt
!.github/scripts/flags*.sh
!cmake/*.cmake
!other/pkgconfig/*
!other/rpm/*
!so.version
!other/docker/modules/check
!**/BUILD.bazel
7 changes: 2 additions & 5 deletions other/docker/modules/run
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/bin/sh
#!/usr/bin/env bash

set -eux
BUILD=modules
other/docker/sources/build
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
. "$(cd "$(dirname "${BASH_SOURCE[0]}")/../sources" && pwd)/run.sh"
1 change: 1 addition & 0 deletions other/docker/pkgsrc/dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!other/docker/pkgsrc/pkgsrc.patch
9 changes: 6 additions & 3 deletions other/docker/pkgsrc/pkgsrc.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
FROM toxchat/pkgsrc:latest

WORKDIR /work
COPY . /work/c-toxcore-0.2.18
RUN ["tar", "zcf", "c-toxcore.tar.gz", "c-toxcore-0.2.18"]
COPY . /work/c-toxcore-0.2.20
RUN ["tar", "zcf", "c-toxcore.tar.gz", "c-toxcore-0.2.20"]

WORKDIR /work/pkgsrc
COPY other/docker/pkgsrc/pkgsrc.patch /tmp/pkgsrc.patch
RUN ["patch", "-p1", "-i", "/tmp/pkgsrc.patch"]

WORKDIR /work/pkgsrc/chat/toxcore
RUN ["sed", "-i", "-e", "s/libtoxcore.so.2.18.0/libtoxcore.so.2.20.0/g", "PLIST"]
RUN ["bmake", "clean"]
RUN ["bmake", "DISTFILES=c-toxcore.tar.gz", "DISTDIR=/work", "NO_CHECKSUM=yes"]
RUN ["bmake", "install"]
1 change: 1 addition & 0 deletions other/docker/pkgsrc/pkgsrc.Dockerfile.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
!other/pkgconfig/*
!other/rpm/*
!so.version
!other/docker/pkgsrc/pkgsrc.patch
31 changes: 31 additions & 0 deletions other/docker/pkgsrc/pkgsrc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/chat/toxcore/Makefile b/chat/toxcore/Makefile
index 70466704d..53a08ad08 100644
--- a/chat/toxcore/Makefile
+++ b/chat/toxcore/Makefile
@@ -1,6 +1,6 @@
# $NetBSD: Makefile,v 1.6 2024/01/22 13:16:56 ryoon Exp $

-DISTNAME= toxcore-0.2.18
+DISTNAME= toxcore-0.2.20
PKGREVISION= 2
CATEGORIES= chat
MASTER_SITES= ${MASTER_SITE_GITHUB:=TokTok/}
diff --git a/chat/toxcore/PLIST b/chat/toxcore/PLIST
index f0a5e4f04..4122b0867 100644
--- a/chat/toxcore/PLIST
+++ b/chat/toxcore/PLIST
@@ -4,11 +4,13 @@ bin/tox-bootstrapd
include/tox/tox.h
include/tox/tox_dispatch.h
include/tox/tox_events.h
+include/tox/tox_options.h
+include/tox/tox_types.h
include/tox/toxav.h
include/tox/toxencryptsave.h
lib/libtoxcore.a
lib/libtoxcore.so
lib/libtoxcore.so.2
-lib/libtoxcore.so.2.18.0
+lib/libtoxcore.so.2.20.0
lib/pkgconfig/toxcore.pc
share/bash-completion/completions/tox-bootstrapd
24 changes: 24 additions & 0 deletions toxcore/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ exports_files(
"tox.h",
"tox_dispatch.h",
"tox_events.h",
"tox_options.h",
"tox_private.h",
"tox_types.h",
],
visibility = ["//c-toxcore:__subpackages__"],
)
Expand Down Expand Up @@ -1072,6 +1074,25 @@ cc_library(
],
)

cc_library(
name = "tox_types",
srcs = ["tox_types.c"],
hdrs = ["tox_types.h"],
visibility = ["//c-toxcore:__subpackages__"],
)

cc_library(
name = "tox_options",
srcs = ["tox_options.c"],
hdrs = ["tox_options.h"],
copts = ["-UTOX_HIDE_DEPRECATED"],
visibility = ["//c-toxcore:__subpackages__"],
deps = [
":ccompat",
":tox_types",
],
)

cc_library(
name = "tox",
srcs = [
Expand Down Expand Up @@ -1104,6 +1125,8 @@ cc_library(
":network",
":onion_client",
":state",
":tox_options",
":tox_types",
":util",
"//c-toxcore/toxencryptsave:defines",
"@pthread",
Expand All @@ -1117,6 +1140,7 @@ cc_test(
deps = [
":crypto_core",
":tox",
":tox_options",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
Expand Down
Loading

0 comments on commit d408c98

Please sign in to comment.