Skip to content

Commit

Permalink
Merge branch 'dev' into Handler/Network
Browse files Browse the repository at this point in the history
  • Loading branch information
kachsheev committed Sep 12, 2024
2 parents 475470c + 4f42715 commit 57636fd
Show file tree
Hide file tree
Showing 33 changed files with 684 additions and 448 deletions.
101 changes: 101 additions & 0 deletions .github/workflows/build-libraries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: 'Build libraries'

on:
push:
branches:
- '**'
paths:
- '.github/workflows/**'
- 'cmake/**'
- 'include/**'
- 'src/**'
- 'tests/**'
- '**/CMakeLists.txt'
- '**/*.pro'
pull_request:
branches:
- '**'
paths:
- '.github/workflows/**'
- 'cmake/**'
- 'include/**'
- 'src/**'
- 'tests/**'
- '**/CMakeLists.txt'
- '**/*.pro'

defaults:
run:
shell: pwsh

jobs:
build-libraries:
name: 'Build libraries'

strategy:
matrix:
include:
- { system: windows-latest, config: Debug, cc: cl, cpp: cl }
- { system: windows-latest, config: Release, cc: cl, cpp: cl }
- { system: windows-latest, config: Debug, cc: gcc, cpp: g++ }
- { system: windows-latest, config: Release, cc: gcc, cpp: g++ }
- { system: ubuntu-latest, config: Debug, cc: gcc-11, cpp: g++-11 }
- { system: ubuntu-latest, config: Release, cc: gcc-11, cpp: g++-11}
- { system: ubuntu-latest, config: Debug, cc: clang-14, cpp: clang++-14 }
- { system: ubuntu-latest, config: Release, cc: clang-14, cpp: clang++-14 }
fail-fast: false

runs-on: ${{ matrix.system }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Visual Studio Build Tools
uses: ilammy/msvc-dev-cmd@v1
if: ${{ runner.os == 'Windows' && matrix.cc == 'cl' }}

- name: Setup MSYS2
uses: msys2/setup-msys2@v2
if: ${{ runner.os == 'Windows' && matrix.cc == 'gcc' }}
with:
msystem: UCRT64
update: true
install: mingw-w64-ucrt-x86_64-gcc

- name: Setup GCC and Clang
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt update && `
sudo apt install -y `
gcc-11 `
g++-11 `
clang-14
- name: Setup Ninja
uses: imesense/[email protected]

- name: Configure project
run: |
cmake `
-S . `
-B build `
-G "Ninja" `
-DCMAKE_C_COMPILER=${{ matrix.cc }} `
-DCMAKE_CXX_COMPILER=${{ matrix.cpp }} `
-DFLAME_CONAN_SUPPORT=OFF `
-DCMAKE_BUILD_TYPE=${{ matrix.config }}
- name: Build project
run: |
cmake `
--build build `
--config ${{ matrix.config }}
- name: Run tests
run: |
cmake `
--build build `
--target test
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ flame_resolver_settings(
PROJECT_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}
LOCAL_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/install
)
if(FLAME_TESTING)
message(STATUS "Tests enabled")
enable_testing()
endif()

add_subdirectory(${FLAME_INCLUDE_SUBMODLUES_PATH})
add_subdirectory(${FLAME_SOURCE_SUBMODLUES_PATH})
Expand Down
19 changes: 19 additions & 0 deletions bitbucket-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
image:
name: debian:bookworm-slim

clone:
depth: 1

pipelines:
default:
- step:
name: Install toolchain
script:
- apt update
- apt install -y g++ cmake ninja-build git
- mkdir build
- cd build
- cmake -S .. -B . -GNinja -DFLAME_CONAN_SUPPORT=OFF -DCMAKE_BUILD_TYPE=Release
- cmake --build .
# artifacts:
# - build/**
2 changes: 1 addition & 1 deletion include/FlameIDE/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set(HEADER_MODULES
${FLAME_INCLUDE_SUBMODLUES_PATH}/Handler
${FLAME_INCLUDE_SUBMODLUES_PATH}/Os
${FLAME_INCLUDE_SUBMODLUES_PATH}/Others
${FLAME_INCLUDE_SUBMODLUES_PATH}/Streams
# ${FLAME_INCLUDE_SUBMODLUES_PATH}/Streams
${FLAME_INCLUDE_SUBMODLUES_PATH}/Templates
${FLAME_INCLUDE_SUBMODLUES_PATH}/Ubjson
)
Expand Down
12 changes: 12 additions & 0 deletions include/FlameIDE/Common/Traits/Defaults.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,18 @@ using AddVolatileType = typename AddVolatileTrait<T>::Type;
///
class Empty {};

///
/// Make VoidType
///
template<typename ...Args>
struct VoidMaker
{
using Type = void;
};

template<typename ...Args>
using VoidType = typename VoidMaker<Args ...>::Type;

}

#endif // FLAMEIDE_COMMON_TRAITS_DEFAULTS_HPP
2 changes: 1 addition & 1 deletion include/FlameIDE/Common/Traits/Numbers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ constexpr auto IsUnsignedValue = IsUnsignedTrait<T>::VALUE;
///
template<typename T>
struct IsIntegralTrait: public IntegralConstant<
bool, IsPrimitiveValue<T> && !IsFloatValue<T>
bool, IsPrimitiveTrait<T>::VALUE && !IsFloatTrait<T>::VALUE
>
{};

Expand Down
44 changes: 21 additions & 23 deletions include/FlameIDE/Common/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,17 @@ template<typename Container> inline
typename Container::ConstReverseIterator crend(const Container &container);

template<typename T, typename Tt = T&&>
Tt __implementation_decval__(int) noexcept;
Tt declareValueImpl(int) noexcept;

template<typename T>
T __implementation_decval__(long) noexcept;
T declareValueImpl(long) noexcept;

///
/// @brief declareValue
/// @tparam First param.
///
template<typename Type>
decltype(__implementation_decval__<Type>) declareValue() noexcept;

decltype(declareValueImpl<Type>(0)) declareValue() noexcept;

///
/// @brief alignedPointer
Expand Down Expand Up @@ -236,19 +235,19 @@ void copy(T &src, const U &dest, Types::size_t size);
template<typename T>
Types::size_t length(const T *array);

template<
typename T1, typename T2
, typename = typename EnableType<IsIntegralValue<T1>, T1>::Type
, typename = typename EnableType<IsIntegralValue<T2>, T2>::Type
>
constexpr decltype(T1{} + T2{}) max(T1 value1, T2 value2) noexcept;
// template<
// typename T1, typename T2
// , typename = typename EnableType<IsIntegralValue<T1>, T1>::Type
// , typename = typename EnableType<IsIntegralValue<T2>, T2>::Type
// >
// constexpr auto max(T1 value1, T2 value2) noexcept -> decltype(operator+(declareValue<T1>() + declareValue<T2>()));

template<
typename T1, typename T2
, typename = typename EnableType<IsIntegralValue<T1>, T1>::Type
, typename = typename EnableType<IsIntegralValue<T2>, T2>::Type
>
constexpr decltype(T1{} + T2{}) min(T1 value1, T2 value2) noexcept;
// template<
// typename T1, typename T2
// , typename = typename EnableType<IsIntegralValue<T1>, T1>::Type
// , typename = typename EnableType<IsIntegralValue<T2>, T2>::Type
// >
// constexpr auto min(T1 value1, T2 value2) noexcept -> decltype(operator+(declareValue<T1>() + declareValue<T2>()));

template<typename ...Args>
void unused(Args &&...);
Expand Down Expand Up @@ -481,10 +480,9 @@ typename Container::SizeType size(const Container &container)
}

template<typename Type>
decltype(__implementation_decval__<Type>) declareValue() noexcept
decltype(declareValueImpl<Type>(0)) declareValue() noexcept
{
static_assert(FalseType::VALUE, "It can't ba called");
return __implementation_decval__<Type>(0);
return declareValueImpl<Type>(0);
}

template<typename T, typename U>
Expand Down Expand Up @@ -561,16 +559,16 @@ Types::size_t length(const T *array)
return length;
}

template<typename T1, typename T2, typename, typename>
constexpr decltype(T1{} + T2{}) max(T1 value1, T2 value2) noexcept
template<typename T>
T maximum(T value1, T value2) noexcept
{
if (value1 > value2)
return value1;
return value2;
}

template<typename T1, typename T2, typename, typename>
constexpr decltype(T1{} + T2{}) min(T1 value1, T2 value2) noexcept
template<typename T>
T minimum(T value1, T value2) noexcept
{
if (value2 > value1)
return value1;
Expand Down
2 changes: 1 addition & 1 deletion include/FlameIDE/Os/Windows/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ struct OsThreadTaskTrait: public NonCreational
{
using Return = DWORD;
using Argument = LPVOID;
using Task = Return(*)(Argument);
using Task = Return(WINAPI *)(Argument);
};

struct OsMutexContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ template<typename T>
typename ValueInfo<T>::Iterator
SpecializedValue<ByteOrder::LITTLE_ENDIAN_ORDER, T>::begin()
{
return makeByteRange(getValue()).begin()
return makeByteRange(getValue()).begin()
+ sizeof(getValue()) - getSize() - getOffset();
}

Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(SOURCE_MODULES
${FLAME_SOURCE_SUBMODLUES_PATH}/Crypto
${FLAME_SOURCE_SUBMODLUES_PATH}/Handler
${FLAME_SOURCE_SUBMODLUES_PATH}/Os
${FLAME_SOURCE_SUBMODLUES_PATH}/Streams
# ${FLAME_SOURCE_SUBMODLUES_PATH}/Streams
${FLAME_SOURCE_SUBMODLUES_PATH}/Ubjson
)
foreach(module ${SOURCE_MODULES})
Expand Down
2 changes: 2 additions & 0 deletions src/Common/Tests/Sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ set (SOURCE_LIST
${CMAKE_CURRENT_SOURCE_DIR}/TestAggregator.hpp
${CMAKE_CURRENT_SOURCE_DIR}/UtilsTest.cpp
${CMAKE_CURRENT_SOURCE_DIR}/UtilsTest.hpp
${CMAKE_CURRENT_SOURCE_DIR}/VoidTypeTest.cpp
${CMAKE_CURRENT_SOURCE_DIR}/VoidTypeTest.hpp
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
)
2 changes: 2 additions & 0 deletions src/Common/Tests/TestAggregator.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <FlameIDE/../../src/Common/Tests/UtilsTest.hpp>
#include <FlameIDE/../../src/Common/Tests/ExpectedTest.hpp>
#include <FlameIDE/../../src/Common/Tests/VoidTypeTest.hpp>

#include <FlameIDE/../../src/Common/Tests/TestAggregator.hpp>

Expand All @@ -12,6 +13,7 @@ TestAggregator::TestAggregator() : ::TestAggregator("Common")
{
pushBackTest(std::make_shared<UtilsTest>());
pushBackTest(std::make_shared<ExpectedTest>());
pushBackTest(std::make_shared<VoidTypeTest>());
}

}}} // namespace flame_ide::common::tests
35 changes: 35 additions & 0 deletions src/Common/Tests/VoidTypeTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <FlameIDE/../../src/Common/Tests/VoidTypeTest.hpp>

namespace flame_ide
{namespace common
{namespace tests
{

struct ExistMember
{
int member = 0;
};

struct NotExistMember
{};

template<class T, class = VoidType<>>
struct HasMemember: public FalseType
{};

template<class T>
struct HasMemember<T, VoidType<decltype(&T::member)>>: public TrueType
{};

VoidTypeTest::VoidTypeTest() : AbstractTest("VoidType")
{}

VoidTypeTest::~VoidTypeTest() = default;

int VoidTypeTest::vStart()
{
IN_CASE_CHECK(HasMemember<ExistMember>::VALUE == TrueType::VALUE);
IN_CASE_CHECK_END(HasMemember<NotExistMember>::VALUE == FalseType::VALUE);
}

}}} // flame_ide::common::tests
25 changes: 25 additions & 0 deletions src/Common/Tests/VoidTypeTest.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef FLAMEIDE_COMMON_TESTS_VOIDTYPETEST_HPP
#define FLAMEIDE_COMMON_TESTS_VOIDTYPETEST_HPP

#include <FlameIDE/Common/Traits/Defaults.hpp>

#include <tests/Test.hpp>

namespace flame_ide
{namespace common
{namespace tests
{

class VoidTypeTest: public AbstractTest
{
public:
VoidTypeTest();
virtual ~VoidTypeTest();

private:
virtual int vStart();
};

}}} // flame_ide::common::tests

#endif // FLAMEIDE_COMMON_TESTS_VOIDTYPETEST_HPP
5 changes: 3 additions & 2 deletions src/Crypto/Pkcs11/Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ if(FLAME_TESTING)
NO_RTTI
EXCEPTIONS

TEST
TEST_ARGUMENTS ""
# TODO: need Resolver fix
#TEST
#TEST_ARGUMENTS ""
)
endif()

Expand Down
2 changes: 1 addition & 1 deletion src/Os/Async/Network/Config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct Config: public flame_ide::NonCreational
# define SOMAXCONN1_STR(VALUE) #VALUE
# define SOMAXCONN_STR(VALUE) SOMAXCONN1_STR(VALUE)
static_assert(
TCP_SERVER_BACKLOG < flame_ide::os::SOCKET_TCP_MAX_CLIENTS
TCP_SERVER_BACKLOG <= flame_ide::os::SOCKET_TCP_MAX_CLIENTS
, "Generated server backlog more than SOMAXCONN = " SOMAXCONN_STR(SOMAXCONN)
);
# undef SOMAXCONN_STR
Expand Down
Loading

0 comments on commit 57636fd

Please sign in to comment.