Skip to content

Commit

Permalink
refactor: Use cmp instead of msgpack-c for events packing.
Browse files Browse the repository at this point in the history
This library is better in every way.
  • Loading branch information
iphydf committed Mar 26, 2022
1 parent 6749974 commit ee154da
Show file tree
Hide file tree
Showing 73 changed files with 1,330 additions and 806 deletions.
31 changes: 26 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,20 @@ jobs:
apt-get update &&
DEBIAN_FRONTEND=noninteractive
apt-get install -y --no-install-recommends
ca-certificates
clang
cmake
git
libconfig-dev
libgtest-dev
libmsgpack-dev
libopus-dev
libsodium-dev
libvpx-dev
llvm-dev
ninja-build
pkg-config
- checkout
- run: git submodule update --init --recursive
- run: CC=clang .circleci/cmake-asan

tsan:
Expand All @@ -51,6 +52,7 @@ jobs:
steps:
- run: *apt_install
- checkout
- run: git submodule update --init --recursive
- run: CC=clang .circleci/cmake-tsan

ubsan:
Expand All @@ -61,6 +63,7 @@ jobs:
steps:
- run: *apt_install
- checkout
- run: git submodule update --init --recursive
- run: CC=clang .circleci/cmake-ubsan

msan:
Expand All @@ -70,6 +73,7 @@ jobs:

steps:
- checkout
- run: git submodule update --init --recursive
- run: rm -rf /src/workspace/c-toxcore/* && mv * /src/workspace/c-toxcore/
- run: cd /src/workspace && bazel test //c-toxcore/auto_tests:lossless_packet_test

Expand All @@ -81,6 +85,7 @@ jobs:
steps:
- run: *apt_install
- checkout
- run: git submodule update --init --recursive
- run: infer --no-progress-bar -- cc
auto_tests/auto_test_support.c
auto_tests/lossless_packet_test.c
Expand All @@ -89,8 +94,9 @@ jobs:
toxcore/*.c
toxcore/*/*.c
toxencryptsave/*.c
third_party/cmp/*.c
-lpthread
$(pkg-config --cflags --libs libsodium msgpack opus vpx)
$(pkg-config --cflags --libs libsodium opus vpx)

static-analysis:
working_directory: ~/work
Expand All @@ -99,8 +105,14 @@ jobs:

steps:
- run: *apt_install
- run: apt-get install -y --no-install-recommends cppcheck g++ llvm-dev
- run:
apt-get install -y --no-install-recommends
ca-certificates
cppcheck
g++
llvm-dev
- checkout
- run: git submodule update --init --recursive
- run: other/analysis/check_includes
- run: other/analysis/check_logger_levels
- run: other/analysis/run-check-recursion
Expand All @@ -116,6 +128,7 @@ jobs:
steps:
- run: *apt_install
- checkout
- run: git submodule update --init --recursive
- run: other/analysis/run-clang-analyze

clang-tidy:
Expand All @@ -125,8 +138,12 @@ jobs:

steps:
- run: *apt_install
- run: apt-get install -y --no-install-recommends clang-tidy-12
- run:
apt-get install -y --no-install-recommends
ca-certificates
clang-tidy-12
- checkout
- run: git submodule update --init --recursive
- run: cmake . -B_build -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- run:
other/analysis/run-clang-tidy ||
Expand All @@ -140,7 +157,11 @@ jobs:

steps:
- run: *apt_install
- run: apt-get install -y --no-install-recommends python3-pip
- run:
apt-get install -y --no-install-recommends
ca-certificates
python3-pip
- checkout
- run: git submodule update --init --recursive
- run: pip install cpplint
- run: other/analysis/run-cpplint
7 changes: 7 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ bazel-opt_task:
cpu: 2
memory: 2G
configure_script:
- git submodule update --init --recursive
- /src/workspace/tools/inject-repo c-toxcore
test_all_script:
- cd /src/workspace && bazel test -k
Expand All @@ -22,6 +23,7 @@ bazel-dbg_task:
cpu: 2
memory: 2G
configure_script:
- git submodule update --init --recursive
- /src/workspace/tools/inject-repo c-toxcore
test_all_script:
- cd /src/workspace && bazel test -k
Expand All @@ -39,6 +41,7 @@ bazel-asan_task:
cpu: 2
memory: 4G
configure_script:
- git submodule update --init --recursive
- /src/workspace/tools/inject-repo c-toxcore
test_all_script:
- cd /src/workspace && bazel test -k
Expand All @@ -57,6 +60,7 @@ bazel-asan_task:
# cpu: 2
# memory: 4G
# configure_script:
# - git submodule update --init --recursive
# - /src/workspace/tools/inject-repo c-toxcore
# test_all_script:
# - cd /src/workspace && bazel test -k
Expand All @@ -75,6 +79,7 @@ bazel-tsan_task:
cpu: 2
memory: 4G
configure_script:
- git submodule update --init --recursive
- /src/workspace/tools/inject-repo c-toxcore
test_all_script:
- cd /src/workspace && bazel test -k
Expand All @@ -98,6 +103,7 @@ bazel-valgrind_task:
cpu: 2
memory: 4G
configure_script:
- git submodule update --init --recursive
- /src/workspace/tools/inject-repo c-toxcore
test_all_script:
- cd /src/workspace && bazel test -k
Expand All @@ -123,6 +129,7 @@ cimple_task:
cpu: 2
memory: 4G
configure_script:
- git submodule update --init --recursive
- /src/workspace/tools/inject-repo c-toxcore
test_all_script:
- cd /src/workspace && bazel test -k
Expand Down
5 changes: 0 additions & 5 deletions .clusterfuzzlite/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ WORKDIR $SRC/libsodium
RUN ./autogen.sh && ./configure --enable-shared=no && make install
WORKDIR $SRC

# msgpack-c
RUN git clone --depth 1 --branch c_master https://github.com/msgpack/msgpack-c.git msgpack
WORKDIR $SRC/msgpack
RUN cmake -DBUILD_SHARED_LIBS=OFF . && make && make install

# Copy your project's source code.
COPY . $SRC/c-toxcore
# Working directory for build.sh.
Expand Down
16 changes: 0 additions & 16 deletions .github/scripts/cmake-android
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,6 @@ autoreconf -fi
make -j"$(nproc)" install
cd ..

# Build msgpack
if [ ! -d msgpack-c ]; then
git clone --branch=c-4.0.0 https://github.com/msgpack/msgpack-c.git
fi
rm -rf msgpack-c/build
mkdir -p msgpack-c/build
cd msgpack-c/build
cmake .. \
-DMSGPACK_BUILD_EXAMPLES=OFF \
-DCMAKE_TOOLCHAIN_FILE="$NDK/build/cmake/android.toolchain.cmake" \
-DANDROID_ABI="$ABI" \
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
-DCMAKE_PREFIX_PATH="$PREFIX"
cmake --build . --target install
cd ../..

# Build c-toxcore
rm -rf _build
mkdir -p _build
Expand Down
1 change: 0 additions & 1 deletion .github/scripts/cmake-osx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ brew install \
libconfig \
libsodium \
libvpx \
msgpack \
opus

. ".github/scripts/flags-clang.sh"
Expand Down
1 change: 0 additions & 1 deletion .github/scripts/coverage-linux
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ NPROC=$(nproc)

sudo apt-get install -y --no-install-recommends \
libgtest-dev \
libmsgpack-dev \
libopus-dev \
libsodium-dev \
libvpx-dev \
Expand Down
1 change: 0 additions & 1 deletion .github/scripts/sonar-prepare
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ set -eu

sudo apt-get install -y --no-install-recommends \
libconfig-dev \
libmsgpack-dev \
libopus-dev \
libsodium-dev \
libvpx-dev \
Expand Down
29 changes: 25 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
Expand Down Expand Up @@ -52,6 +54,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Run cimplefmt
run: other/docker/cimplefmt/run -u $(find tox* -name "*.[ch]")

Expand All @@ -69,13 +73,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Cross compilation
run: .github/scripts/cmake-win32 script

build-win64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Cross compilation
run: .github/scripts/cmake-win64 script

Expand All @@ -84,33 +92,40 @@ jobs:
container: toxchat/freebsd
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Build on FreeBSD
run: .github/scripts/cmake-freebsd-stage2

build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Build and test
run: .github/scripts/cmake-osx

coverage-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Build, test, and upload coverage
run: .github/scripts/coverage-linux

build-tcc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install dependencies
run:
sudo apt-get install -y --no-install-recommends
tcc
libconfig-dev
libmsgpack-dev
libopus-dev
libsodium-dev
libvpx-dev
Expand All @@ -128,7 +143,8 @@ jobs:
toxcore/*.c
toxcore/*/*.c
toxencryptsave/*.c
$(pkg-config --cflags --libs libsodium msgpack opus vpx)
third_party/cmp/*.c
$(pkg-config --cflags --libs libsodium opus vpx)
- name: Run the test
run: "./send_message_test | grep 'tox clients connected'"
- name: Build amalgamation file with TCC
Expand All @@ -141,7 +157,7 @@ jobs:
-o send_message_test
-Wall -Werror
-bench -g
$(pkg-config --cflags --libs libsodium msgpack opus vpx)
$(pkg-config --cflags --libs libsodium opus vpx)
- name: Run the test again
run: "./send_message_test | grep 'tox clients connected'"

Expand All @@ -150,6 +166,8 @@ jobs:
container: toxchat/compcert
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Build with CompCert
run:
ccomp
Expand All @@ -166,15 +184,18 @@ jobs:
toxcore/*.c
toxcore/*/*.c
toxencryptsave/*.c
third_party/cmp/*.c
-D__COMPCERT__ -DDISABLE_VLA -Dinline=
-lpthread $(pkg-config --cflags --libs libsodium msgpack opus vpx)
-lpthread $(pkg-config --cflags --libs libsodium opus vpx)
- name: Run the test
run: "./send_message_test | grep 'tox clients connected'"

build-android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- run: .github/scripts/cmake-android armeabi-v7a
- run: .github/scripts/cmake-android arm64-v8a
- run: .github/scripts/cmake-android x86
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/coverity-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install libraries
run:
sudo apt-get update &&
sudo apt-get install -y --no-install-recommends
libmsgpack-dev
libopus-dev
libsodium-dev
libvpx-dev
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Docker Build
run: .github/scripts/tox-bootstrapd-docker local
- name: Push latest image to DockerHub
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/sonar-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
submodules: recursive
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "third_party/cmp"]
path = third_party/cmp
url = https://github.com/TokTok/cmp
Loading

0 comments on commit ee154da

Please sign in to comment.