Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix c++ tests, enable C++ tests in CI, added rdact (act wrapper) for running GitHub actions locallyAb fix tests #455

Merged
merged 15 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 38 additions & 7 deletions .github/workflows/build-rd-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
env:
working-dir: ${{ github.workspace}}${{ matrix.config.SEP }}rd-cpp
artifact: ${{ matrix.config.artifact }}${{ github.run_number }}.zip
GRADLE_USER_HOME: ${{ github.workspace }}/.github/gradle
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
Expand Down Expand Up @@ -46,14 +47,14 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Cache submodules
uses: actions/cache@v3
id: cache-submodules
with:
path: |
rd-cpp/thirdparty/spdlog
rd-cpp/thirdparty/googletest
rd-cpp/googletest
key: ${{ matrix.config.os }}-submodules-${{ hashFiles('.gitmodules') }}

- name: Get submodules
Expand All @@ -65,7 +66,29 @@ jobs:
uses: nuget/setup-nuget@v1
with:
nuget-version: '5.x'


- name: Gradle JVM Cache
uses: actions/cache@v3
with:
path: ~/.local/share/gradle-jvm
key: ${{ runner.os }}.gradle-jvm-cache.${{ hashFiles('gradle/**') }}

- name: Gradle Wrapper Cache
uses: actions/cache@v3
with:
path: ${{ env.GRADLE_USER_HOME }}/wrapper
key: ${{ runner.os }}.gradle-wrapper.${{ hashFiles('gradle/**') }}

- name: Gradle Cache
uses: actions/cache@v3
with:
path: ${{ env.GRADLE_USER_HOME }}/caches/modules-2
key: ${{ runner.os }}.gradle.${{ hashFiles('**/*.gradle.kts') }}

- name: Generate everything
working-directory: ${{ env.working-dir }}/..
run: ./gradlew generateEverything

- name: Cache Ninja
uses: actions/cache@v3
id: cache-ninja
Expand All @@ -74,7 +97,7 @@ jobs:
rd-cpp/ninja
rd-cpp/ninja.exe
key: ${{ matrix.config.os }}-Ninja-${{ env.NINJA_VERSION }}

- name: Download Ninja
if: steps.cache-ninja.outputs.cache-hit != 'true'
id: download_ninja
Expand Down Expand Up @@ -104,7 +127,7 @@ jobs:

if (NOT "${{ runner.os }}" STREQUAL "Windows")
execute_process(COMMAND chmod +x ninja)
endif()
endif()

- name: Configure
working-directory: ${{ env.working-dir }}
Expand Down Expand Up @@ -143,7 +166,7 @@ jobs:
COMMAND ${CMAKE_COMMAND}
-S .
-B build
-DENABLE_TESTS_OPTION:BOOL=OFF
-DENABLE_TESTS_OPTION:BOOL=ON
-DCMAKE_BUILD_TYPE=$ENV{BUILD_TYPE}
-G Ninja
-DCMAKE_MAKE_PROGRAM=${CMAKE_CURRENT_SOURCE_DIR}/ninja
Expand Down Expand Up @@ -191,10 +214,18 @@ jobs:
message(FATAL_ERROR "Bad exit status")
endif()

- name: Run core tests
working-directory: ${{ env.working-dir }}
run: build/src/rd_core_cpp/src/test/rd_core_cpp_test

- name: Run framework tests
working-directory: ${{ env.working-dir }}
run: build/src/rd_framework_cpp/src/test/rd_framework_cpp_test

- name: Install Strip
working-directory: ${{ env.working-dir }}
run: cd build && cmake --config ${{ env.BUILD_TYPE }} -P cmake_install.cmake

- name: Pack
working-directory: ${{ env.working-dir }}
run: cd export && cmake -E tar "cfv" ../${{ env.artifact }} --format=zip include libs
Expand Down
5 changes: 2 additions & 3 deletions rd-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ elseif (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_compile_options(
/wd4996 # POSIX name is deprecated
/wd4250 # method inheritance via dominance
/wd4251
/wd4275
)
endif ()

Expand All @@ -68,6 +65,8 @@ else ()
set(PCH_CPP_OPT "")
endif ()

option(RD_STATIC "Compile RD as static library" OFF)

add_subdirectory(thirdparty)
add_subdirectory(src)

Expand Down
19 changes: 15 additions & 4 deletions rd-cpp/src/rd_core_cpp/src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#lib

add_library(rd_core_cpp SHARED
set(RD_CORE_CPP_SOURCES
#lifetime
lifetime/LifetimeImpl.cpp lifetime/LifetimeImpl.h
lifetime/Lifetime.cpp lifetime/Lifetime.h
Expand Down Expand Up @@ -37,12 +36,24 @@ add_library(rd_core_cpp SHARED
util/gen_util.h util/overloaded.h
#pch
${PCH_CPP_OPT}
)
util/export_api_helper.h
)

if (RD_STATIC)
add_library(rd_core_cpp STATIC ${RD_CORE_CPP_SOURCES})
target_compile_definitions(rd_core_cpp PUBLIC RD_CORE_STATIC_DEFINE)
else ()
add_library(rd_core_cpp SHARED ${RD_CORE_CPP_SOURCES})
endif ()

set(RD_CORE_EXPORT_HEADER_CUSTOM_CONTENT "#include \"util/export_api_helper.h\"")

include(GenerateExportHeader)
generate_export_header(rd_core_cpp
BASE_NAME rd_core
EXPORT_MACRO_NAME RD_CORE_API)
EXPORT_MACRO_NAME RD_CORE_API
CUSTOM_CONTENT_FROM_VARIABLE RD_CORE_EXPORT_HEADER_CUSTOM_CONTENT
)

message(STATUS "Using pch by rd_core: '${ENABLE_PCH_HEADERS}'")

Expand Down
11 changes: 3 additions & 8 deletions rd-cpp/src/rd_core_cpp/src/main/lifetime/Lifetime.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#ifndef RD_CPP_CORE_LIFETIMEWRAPPER_H
#define RD_CPP_CORE_LIFETIMEWRAPPER_H

#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4251)
#endif

#include "LifetimeImpl.h"

#include <std/hash.h>
Expand All @@ -14,6 +9,8 @@

#include <rd_core_export.h>

RD_PUSH_STL_EXPORTS_WARNINGS

namespace rd
{
class Lifetime;
Expand Down Expand Up @@ -68,9 +65,7 @@ inline size_t hash<Lifetime>::operator()(const Lifetime& value) const noexcept
return hash<std::shared_ptr<LifetimeImpl> >()(value.ptr);
}
} // namespace rd
#if defined(_MSC_VER)
#pragma warning(pop)
#endif

RD_POP_STL_EXPORTS_WARNINGS

#endif // RD_CPP_CORE_LIFETIMEWRAPPER_H
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,11 @@ bool LifetimeDefinition::is_eternal() const
return lifetime->is_eternal();
}

namespace
{
LifetimeDefinition ETERNAL(true);
}

std::shared_ptr<LifetimeDefinition> LifetimeDefinition::get_shared_eternal()
{
return std::shared_ptr<LifetimeDefinition>(&ETERNAL, [](LifetimeDefinition* /*ld*/) {});
static LifetimeDefinition ETERNAL(true);

return {&ETERNAL, [](LifetimeDefinition* /*ld*/) {}};
}

LifetimeDefinition::~LifetimeDefinition()
Expand Down
4 changes: 4 additions & 0 deletions rd-cpp/src/rd_core_cpp/src/main/lifetime/LifetimeDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#include <rd_core_export.h>

RD_PUSH_STL_EXPORTS_WARNINGS

namespace rd
{
class RD_CORE_API LifetimeDefinition
Expand Down Expand Up @@ -56,4 +58,6 @@ class RD_CORE_API LifetimeDefinition
};
} // namespace rd

RD_POP_STL_EXPORTS_WARNINGS

#endif // RD_CPP_CORE_LIFETIME_DEFINITION_H
11 changes: 3 additions & 8 deletions rd-cpp/src/rd_core_cpp/src/main/lifetime/LifetimeImpl.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#ifndef RD_CPP_CORE_LIFETIME_H
#define RD_CPP_CORE_LIFETIME_H

#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4251)
#endif

#include <std/hash.h>

#include <functional>
Expand All @@ -19,6 +14,8 @@

#include <rd_core_export.h>

RD_PUSH_STL_EXPORTS_WARNINGS

namespace rd
{
class RD_CORE_API LifetimeImpl final
Expand Down Expand Up @@ -100,9 +97,7 @@ class RD_CORE_API LifetimeImpl final
void attach_nested(std::shared_ptr<LifetimeImpl> nested);
};
} // namespace rd
#if defined(_MSC_VER)
#pragma warning(pop)
#endif

RD_POP_STL_EXPORTS_WARNINGS

#endif // RD_CPP_CORE_LIFETIME_H
11 changes: 3 additions & 8 deletions rd-cpp/src/rd_core_cpp/src/main/lifetime/SequentialLifetimes.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
#ifndef RD_CPP_CORE_SEQUENTIAL_LIFETIMES_H
#define RD_CPP_CORE_SEQUENTIAL_LIFETIMES_H

#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4251)
#endif

#include "LifetimeDefinition.h"
#include "Lifetime.h"

#include <rd_core_export.h>

RD_PUSH_STL_EXPORTS_WARNINGS

namespace rd
{
class RD_CORE_API SequentialLifetimes
Expand Down Expand Up @@ -43,9 +40,7 @@ class RD_CORE_API SequentialLifetimes
void set_current_lifetime(std::shared_ptr<LifetimeDefinition> new_def);
};
} // namespace rd
#if defined(_MSC_VER)
#pragma warning(pop)
#endif

RD_POP_STL_EXPORTS_WARNINGS

#endif // RD_CPP_CORE_SEQUENTIAL_LIFETIMES_H
15 changes: 15 additions & 0 deletions rd-cpp/src/rd_core_cpp/src/main/util/export_api_helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef EXPORT_API_HELPER_H
#define EXPORT_API_HELPER_H

#if defined(_MSC_VER)
#define RD_PUSH_STL_EXPORTS_WARNINGS \
_Pragma("warning(push)") \
_Pragma("warning(disable:4251)")
#define RD_POP_STL_EXPORTS_WARNINGS \
_Pragma("warning(pop)")
#else
#define RD_PUSH_STL_EXPORTS_WARNINGS
#define RD_POP_STL_EXPORTS_WARNINGS
#endif

#endif //EXPORT_API_HELPER_H
22 changes: 16 additions & 6 deletions rd-cpp/src/rd_framework_cpp/src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#lib
add_library(rd_framework_cpp SHARED
set(RD_FRAMEWORK_CPP_SOURCES
#base
base/IRdBindable.h
base/IRdReactive.h
Expand Down Expand Up @@ -63,12 +63,24 @@ add_library(rd_framework_cpp SHARED
protocol/Protocol.cpp protocol/Protocol.h
protocol/MessageBroker.cpp protocol/MessageBroker.h
#pch
${PCH_CPP_OPT})
${PCH_CPP_OPT}
)

if (RD_STATIC)
add_library(rd_framework_cpp STATIC ${RD_FRAMEWORK_CPP_SOURCES})
target_compile_definitions(rd_core_cpp PUBLIC RD_FRAMEWORK_STATIC_DEFINE)
else ()
add_library(rd_framework_cpp SHARED ${RD_FRAMEWORK_CPP_SOURCES})
endif ()

set(RD_FRAMEWORK_EXPORT_HEADER_CUSTOM_CONTENT "#include \"util/export_api_helper.h\"")

include(GenerateExportHeader)
generate_export_header(rd_framework_cpp
BASE_NAME rd_framework
EXPORT_MACRO_NAME RD_FRAMEWORK_API)
EXPORT_MACRO_NAME RD_FRAMEWORK_API
CUSTOM_CONTENT_FROM_VARIABLE RD_FRAMEWORK_EXPORT_HEADER_CUSTOM_CONTENT
)

message(STATUS "Using pch by rd_framework: '${ENABLE_PCH_HEADERS}'")

Expand All @@ -85,9 +97,7 @@ target_include_directories(rd_framework_cpp
${CMAKE_CURRENT_BINARY_DIR}
)

target_link_libraries(rd_framework_cpp
PUBLIC rd_core_cpp rd_framework_cpp_util rd_gen_cpp
)
target_link_libraries(rd_framework_cpp PUBLIC rd_core_cpp rd_framework_cpp_util)

find_package(Threads REQUIRED)
target_link_libraries(rd_framework_cpp PRIVATE Threads::Threads clsocket)
Expand Down
11 changes: 3 additions & 8 deletions rd-cpp/src/rd_framework_cpp/src/main/base/IProtocol.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#ifndef RD_CPP_IPROTOCOL_H
#define RD_CPP_IPROTOCOL_H

#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4251)
#endif

#include "IRdDynamic.h"
#include "serialization/Serializers.h"
#include "protocol/Identities.h"
Expand All @@ -16,6 +11,8 @@

#include <rd_framework_export.h>

RD_PUSH_STL_EXPORTS_WARNINGS

namespace rd
{
// region predeclared
Expand Down Expand Up @@ -67,9 +64,7 @@ class RD_FRAMEWORK_API IProtocol : public IRdDynamic
const RName& get_location() const override;
};
} // namespace rd
#if defined(_MSC_VER)
#pragma warning(pop)
#endif

RD_POP_STL_EXPORTS_WARNINGS

#endif // RD_CPP_IPROTOCOL_H
2 changes: 1 addition & 1 deletion rd-cpp/src/rd_framework_cpp/src/main/base/IRdWireable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

namespace rd
{
}
}
Loading
Loading