Skip to content

Commit

Permalink
test: Add an s390x build (on alpine) for CI.
Browse files Browse the repository at this point in the history
It doesn't work at all, because we're missing something in the net code
to do with endian conversions. I haven't investigated, yet, but at least
now we have a failing test that can be investigated.

Also moved to cmake 3.5 at minimum. CMake will stop supporting lower
versions than that, soon.

Also moved to C17 from C99 to get `static_assert`.
  • Loading branch information
iphydf committed Nov 22, 2023
1 parent 6c35cef commit 80ca018
Show file tree
Hide file tree
Showing 19 changed files with 116 additions and 41 deletions.
46 changes: 46 additions & 0 deletions .github/scripts/cmake-alpine-s390x
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
# Copyright (C) 2018-2021 nurupo

# Toxcore building

set -eux

cd /work

. cmake-alpine-run.sh

# === Get VM ready to build the code ===

start_vm

RUN apk add cmake g++ ninja

mv c-toxcore /

# Copy over toxcore code from host to qemu
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -P "$SSH_PORT" -r /c-toxcore root@localhost:~

cd /c-toxcore
. ".github/scripts/flags-gcc.sh"

# Make compilation error on a warning
add_flag -Werror

RUN "cmake -B_build -Hc-toxcore -GNinja \
-DCMAKE_C_FLAGS='$C_FLAGS' \
-DCMAKE_CXX_FLAGS='$CXX_FLAGS' \
-DCMAKE_EXE_LINKER_FLAGS='$LD_FLAGS' \
-DCMAKE_SHARED_LINKER_FLAGS='$LD_FLAGS' \
-DCMAKE_INSTALL_PREFIX:PATH='_install' \
-DCMAKE_UNITY_BUILD=ON \
-DMIN_LOGGER_LEVEL=TRACE \
-DNON_HERMETIC_TESTS=ON \
-DBUILD_TOXAV=OFF \
-DBOOTSTRAP_DAEMON=OFF \
-DSTRICT_ABI=ON \
-DTEST_TIMEOUT_SECONDS=90 \
-DUSE_IPV6=OFF \
-DAUTOTEST=ON"

RUN 'cmake --build _build --parallel 2 --target install -- -k 0'
RUN 'cd _build && ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:1 || true'
File renamed without changes.
2 changes: 0 additions & 2 deletions .github/scripts/flags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ add_flag -O3 -march=native

# Warn on non-ISO C.
add_c_flag -pedantic
add_c_flag -std=c99
add_cxx_flag -std=c++11

add_flag -g3
add_flag -ftrapv
30 changes: 20 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,26 @@ jobs:
with:
file: other/docker/compcert/Dockerfile

build-alpine-s390x:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker Build
uses: docker/build-push-action@v2
with:
file: other/docker/alpine-s390x/Dockerfile

build-freebsd:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker Build
uses: docker/build-push-action@v2
with:
file: other/docker/freebsd/Dockerfile

cimplefmt:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -117,16 +137,6 @@ jobs:
- name: Cross compilation
run: .github/scripts/cmake-win64 script

build-freebsd:
runs-on: ubuntu-latest
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:
Expand Down
27 changes: 10 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#
################################################################################

cmake_minimum_required(VERSION 2.8.12)
cmake_policy(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.5)
cmake_policy(VERSION 3.5)
project(toxcore)

list(APPEND CMAKE_MODULE_PATH ${toxcore_SOURCE_DIR}/cmake)
Expand Down Expand Up @@ -79,21 +79,14 @@ enable_testing()

set(CMAKE_MACOSX_RPATH ON)

if(${CMAKE_VERSION} VERSION_LESS "3.1.0")
if(NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
endif()
else()
# Set standard version for compiler.
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_EXTENSIONS OFF)

message(STATUS "Supported C compiler features = ${CMAKE_C_COMPILE_FEATURES}")
message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}")
endif()
# Set standard version for compiler.
set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_EXTENSIONS OFF)

message(STATUS "Supported C compiler features = ${CMAKE_C_COMPILE_FEATURES}")
message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}")

set(MIN_LOGGER_LEVEL "" CACHE STRING "Logging level to use (TRACE, DEBUG, INFO, WARNING, ERROR)")
if(MIN_LOGGER_LEVEL)
Expand Down
6 changes: 6 additions & 0 deletions other/docker/alpine-s390x/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM toxchat/alpine-s390x:latest

WORKDIR /work/c-toxcore
COPY . /work/c-toxcore/

RUN .github/scripts/cmake-alpine-s390x
5 changes: 5 additions & 0 deletions other/docker/alpine-s390x/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -eux
BUILD=alpine-s390x
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" .
4 changes: 3 additions & 1 deletion other/docker/autotools/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

docker build -t toxchat/c-toxcore:autotools -f other/docker/autotools/Dockerfile .
set -eux
BUILD=autotools
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" .
2 changes: 1 addition & 1 deletion other/docker/cimplefmt/run
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ if [ "$1" = "-u" ]; then
docker pull toxchat/haskell:hs-cimple
docker build -t toxchat/cimplefmt -f other/docker/cimplefmt/Dockerfile .
fi
docker run --rm -v "$PWD:/work" toxchat/cimplefmt "$@"
docker run --name toxcore-cimplefmt --rm -v "$PWD:/work" toxchat/cimplefmt "$@"
2 changes: 1 addition & 1 deletion other/docker/circleci/run
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
SANITIZER="${1:-asan}"

docker build -t toxchat/c-toxcore:circleci other/docker/circleci
docker run --rm -it -v "$PWD:/c-toxcore" toxchat/c-toxcore:circleci "$SANITIZER"
docker run --name toxcore-circleci --rm -it -v "$PWD:/c-toxcore" toxchat/c-toxcore:circleci "$SANITIZER"
4 changes: 2 additions & 2 deletions other/docker/compcert/run
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh

set -eux

docker build -t toxchat/c-toxcore:compcert -f other/docker/compcert/Dockerfile .
BUILD=compcert
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" .
2 changes: 1 addition & 1 deletion other/docker/coverage/run
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -eux

docker build -t toxchat/c-toxcore:sources -f other/docker/sources/Dockerfile .
docker build -t toxchat/c-toxcore:coverage other/docker/coverage
docker run --rm -it -p "28192:80" toxchat/c-toxcore:coverage
docker run --name toxcore-coverage --rm -it -p "28192:80" toxchat/c-toxcore:coverage
2 changes: 1 addition & 1 deletion other/docker/doxygen/run
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
set -eux

docker build -t toxchat/c-toxcore:docs -f other/docker/doxygen/Dockerfile .
docker run --rm -it -p "28192:80" toxchat/c-toxcore:docs
docker run --name toxcore-docs --rm -it -p "28192:80" toxchat/c-toxcore:docs
6 changes: 6 additions & 0 deletions other/docker/freebsd/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM toxchat/freebsd:latest

WORKDIR /work/c-toxcore
COPY . /work/c-toxcore/

RUN .github/scripts/cmake-freebsd
5 changes: 5 additions & 0 deletions other/docker/freebsd/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -eux
BUILD=freebsd
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" .
4 changes: 3 additions & 1 deletion other/docker/misra/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

docker build -f other/docker/misra/Dockerfile .
set -eux
BUILD=misra
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" .
2 changes: 1 addition & 1 deletion other/docker/perf/run
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -eux

docker build -t toxchat/c-toxcore:perf -f other/docker/perf/Dockerfile .
docker run --privileged --rm -it \
docker run --name toxcore-perf --privileged --rm -it \
-v "$PWD:/work/c-toxcore" \
toxchat/c-toxcore:perf \
"$@"
4 changes: 2 additions & 2 deletions other/docker/tcc/run
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh

set -eux

docker build -t toxchat/c-toxcore:tcc -f other/docker/tcc/Dockerfile .
BUILD=tcc
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" .
4 changes: 3 additions & 1 deletion other/docker/tokstyle/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

docker build -f other/docker/tokstyle/Dockerfile .
set -eux
BUILD=tokstyle
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" .

0 comments on commit 80ca018

Please sign in to comment.