Compare commits

..

1 commit

Author SHA1 Message Date
6f8facf83e Update release action/workflow
All checks were successful
Build for Releases / ensure-release-exists (push) Successful in 3s
Build for Releases / assets-release-x86_64 (push) Successful in 1m8s
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 1s
Run UnitTests / build-and-run-tests (push) Successful in 3m40s
2024-07-14 11:51:47 +09:00
15 changed files with 53 additions and 222 deletions

View file

@ -1,28 +0,0 @@
name: Run UnitTests
on:
push:
branches:
- 'conan'
jobs:
build-and-run-tests:
runs-on: docker_arch
steps:
- run: pacman-key --init && pacman-key --populate
name: Init pacman keyring
- run: pacman --noconfirm --needed -Sy archlinux-keyring
name: Update pacman keyring
- run: pacman --noconfirm --needed -Su git cmake libsodium python
name: Update and get dependencies
- run: python -m venv conan_venv && source conan_venv/bin/activate && pip install conan
name: Get conan
- run: source conan_venv/bin/activate && conan profile detect --force
name: Set up conan profile
- run: git clone --depth=1 --no-single-branch https://git.seodisparate.com/stephenseo/UDPConnection.git UDPC
name: Get repository
- run: cd UDPC && git checkout $GITHUB_REF_NAME
name: Checkout git repository
- run: source conan_venv/bin/activate && conan build UDPC -of buildConan --settings=build_type=Debug --build=missing
name: Build with conan
- run: find buildConan -name UnitTest -execdir './{}' ';'
name: Test

View file

@ -23,7 +23,7 @@ jobs:
-d "{
\"name\": \"UDPC version ${GITHUB_REF_NAME}\",
\"tag_name\": \"${GITHUB_REF_NAME}\",
\"body\": \"Warning: Static libs require linking with C++ linker or linking with stdc++ (`-lstdc++`)!
\"body\": \"Warning: Static libs require linking with C++ linker or linking with stdc++ (\`-lstdc++\` on Linux, \`-llibc++\` on MacOS)!
Warning: Will need to link with libsodium!
SHA256SUMS\"

View file

@ -0,0 +1,14 @@
name: Run UnitTests
on:
push:
branches:
- '*'
jobs:
build-and-run-tests:
runs-on: any_archLinux
steps:
- run: git clone --depth=1 --no-single-branch https://git.seodisparate.com/stephenseo/UDPConnection.git UDPC
- run: cd UDPC && git checkout $GITHUB_REF_NAME
- run: cd UDPC && cmake -S . -B buildDebug -DCMAKE_BUILD_TYPE=Debug
- run: make -C UDPC/buildDebug && ./UDPC/buildDebug/UnitTest

View file

@ -1,22 +0,0 @@
name: Run UnitTests
on:
push:
branches:
- 'conan'
jobs:
build-and-run-tests:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: sudo /usr/bin/env DEBIAN_FRONTEND=noninteractive apt-get install cmake git python3
- name: Get sources
run: git clone --depth=1 --no-single-branch https://github.com/Stephen-Seo/UDPConnection.git UDPC && cd UDPC && git checkout $GITHUB_REF_NAME
- name: Get Conan
run: python -m venv venv_conan && source venv_conan/bin/activate && pip install conan
- name: Set up conan
run: source venv_conan/bin/activate && conan profile detect --force
- name: Build with conan
run: source venv_conan/bin/activate && conan build UDPC -of buildConan --settings=build_type=Debug --build=missing
- name: Run tests
run: find buildConan -name UnitTest -execdir './{}' ';'

18
.github/workflows/unittests.yml vendored Normal file
View file

@ -0,0 +1,18 @@
name: Run UnitTests
on:
push:
branches:
- '*'
jobs:
build-and-run-tests:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: sudo /usr/bin/env DEBIAN_FRONTEND=noninteractive apt-get install cmake git libsodium-dev
- name: Get sources
run: git clone --depth=1 --no-single-branch https://github.com/Stephen-Seo/UDPConnection.git UDPC && cd UDPC && git checkout $GITHUB_REF_NAME
- name: Build sources
run: cd UDPC && cmake -S . -B buildDebug -DCMAKE_BUILD_TYPE=Debug && make -C buildDebug
- name: Run tests
run: ./UDPC/buildDebug/UnitTest

2
.gitignore vendored
View file

@ -4,5 +4,3 @@ compile_commands.json
*.o
doxygen_out/
/tags
CMakeUserPresets.json

View file

@ -23,18 +23,6 @@ endif()
add_library(UDPC ${UDPC_SOURCES})
# Enforce linking with libstdc++ even with C targets.
# Doesn't affect conan, so conanfile.py was also modified for this.
if(APPLE)
set_target_properties(UDPC PROPERTIES
INTERFACE_LINK_LIBRARIES "libc++"
)
elseif(UNIX)
set_target_properties(UDPC PROPERTIES
INTERFACE_LINK_LIBRARIES "stdc++"
)
endif()
set_target_properties(UDPC PROPERTIES VERSION ${UDPC_VERSION} SOVERSION ${UDPC_SOVERSION})
target_compile_features(UDPC PUBLIC cxx_std_11)
@ -50,10 +38,26 @@ if(WIN32)
endif()
endif()
find_package(libsodium REQUIRED)
target_compile_definitions(UDPC PUBLIC UDPC_LIBSODIUM_ENABLED)
target_link_libraries(UDPC PUBLIC libsodium::libsodium)
if(UDPC_DISABLE_LIBSODIUM)
message(STATUS "libsodium disabled")
elseif(DEFINED M_LIBSODIUM_LIBRARIES AND DEFINED M_LIBSODIUM_INCLUDE_DIRS)
message(STATUS "libsodium manual paths detected, using them")
target_compile_definitions(UDPC PUBLIC UDPC_LIBSODIUM_ENABLED)
target_link_libraries(UDPC PUBLIC ${M_LIBSODIUM_LIBRARIES})
target_include_directories(UDPC PUBLIC ${M_LIBSODIUM_INCLUDE_DIRS})
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBSODIUM QUIET libsodium)
if(LIBSODIUM_FOUND)
target_compile_definitions(UDPC PUBLIC UDPC_LIBSODIUM_ENABLED)
target_link_libraries(UDPC PUBLIC ${LIBSODIUM_LIBRARIES})
target_include_directories(UDPC PUBLIC ${LIBSODIUM_INCLUDE_DIRS})
target_compile_options(UDPC PUBLIC ${LIBSODIUM_CFLAGS_OTHER})
message(STATUS "libsodium enabled")
else()
message(STATUS "libsodium not found, UDPC will be compiled without libsodium support")
endif()
endif()
if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(UDPC_UnitTest_SOURCES

View file

@ -1,25 +0,0 @@
cmake_minimum_required(VERSION 3.7)
project(UDPC_NetworkTest C)
set(UDPC_NetworkTest_SOURCES
src/UDPC_NetworkTest.c
)
add_compile_options(
-Wall -Wextra -Wpedantic -Wno-missing-braces
$<$<COMPILE_LANGUAGE:CXX>:-Weffc++>
$<$<CONFIG:DEBUG>:-Og>
)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Debug', none was specified.")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
endif()
find_package(udpc CONFIG REQUIRED)
add_executable(UDPC_NetworkTest
${UDPC_NetworkTest_SOURCES}
)
target_link_libraries(UDPC_NetworkTest PUBLIC udpc::udpc)

View file

@ -1,6 +0,0 @@
[requires]
udpc/1.2
[generators]
CMakeDeps
CMakeToolchain

View file

@ -1,17 +0,0 @@
#!/usr/bin/env bash
cd "$(dirname "$0")"
set -ve
if ! [[ -e "${HOME}/.conan2/profiles/default" ]]; then
conan profile detect
fi
if ! grep stephens_forgejo "${HOME}/.conan2/remotes.json" >&/dev/null; then
conan remote add stephens_forgejo "https://git.seodisparate.com/api/packages/stephenseo/conan"
fi
conan install . -r stephens_forgejo -r conancenter --output-folder=buildConan --build=missing
cmake -S . -B buildConan -DCMAKE_TOOLCHAIN_FILE=buildConan/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build buildConan

View file

@ -1 +0,0 @@
../../src/test/UDPC_NetworkTest.c

View file

@ -1,61 +0,0 @@
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
import os
class udpcRecipe(ConanFile):
name = "udpc"
version = "1.2"
package_type = "library"
# Optional metadata
license = "MIT"
author = "Stephen Seo stephen@seodisparate.com"
url = "https://git.seodisparate.com/stephenseo/UDPConnection"
description = "Implements a connection over UDP"
topics = ("UDPC", "UDP", "Network", "Network Connection")
# Binary configuration
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}
# Sources are located in the same place as this recipe, copy them to the recipe
exports_sources = "CMakeLists.txt", "src/*"
def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
def layout(self):
cmake_layout(self)
def requirements(self):
self.requires("libsodium/cci.20220430")
def generate(self):
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)
tc.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
cmake = CMake(self)
cmake.install()
def package_info(self):
self.cpp_info.libs.append("UDPC")
if self.settings.os == "Linux":
self.cpp_info.system_libs.append("stdc++")
elif self.settings.os == "Macos":
self.cpp_info.system_libs.append("libc++")
# TODO figure out linking static library for other OS.

View file

@ -1,7 +0,0 @@
cmake_minimum_required(VERSION 3.15)
project(PackageTest CXX)
find_package(udpc CONFIG REQUIRED)
add_executable(example src/test.cpp)
target_link_libraries(example udpc::udpc)

View file

@ -1,26 +0,0 @@
import os
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run
class udpcTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain"
def requirements(self):
self.requires(self.tested_reference_str)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def layout(self):
cmake_layout(self)
def test(self):
if can_run(self):
cmd = os.path.join(self.cpp.build.bindir, "example")
self.run(cmd, env="conanrun")

View file

@ -1,10 +0,0 @@
#include "UDPC.h"
int main() {
auto ctx = UDPC_init(UDPC_create_id_easy("127.0.0.1", 0), 1, 1);
if (UDPC_is_valid_context(ctx) == 0) {
return 1;
}
UDPC_destroy(ctx);
return 0;
}