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 14 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
3 changes: 0 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 Down
2 changes: 2 additions & 0 deletions rd-cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
option(RD_STATIC "Compile RD as static library" OFF)

add_subdirectory(rd_core_cpp)
add_subdirectory(rd_framework_cpp)
add_subdirectory(rd_gen_cpp)
12 changes: 9 additions & 3 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,7 +36,14 @@ add_library(rd_core_cpp SHARED
util/gen_util.h util/overloaded.h
#pch
${PCH_CPP_OPT}
)
)

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 ()

include(GenerateExportHeader)
generate_export_header(rd_core_cpp
Expand Down
9 changes: 0 additions & 9 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 Down Expand Up @@ -68,9 +63,5 @@ 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


#endif // RD_CPP_CORE_LIFETIMEWRAPPER_H
11 changes: 4 additions & 7 deletions rd-cpp/src/rd_core_cpp/src/main/lifetime/LifetimeDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ bool LifetimeDefinition::is_terminated() const
return lifetime->is_terminated();
}

void LifetimeDefinition::terminate()
void LifetimeDefinition::terminate() const
{
lifetime->terminate();
}
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class RD_CORE_API LifetimeDefinition

bool is_eternal() const;

void terminate();
void terminate() const;

template <typename F>
static auto use(F&& block) -> typename util::result_of_t<F(Lifetime)>
Expand Down
9 changes: 0 additions & 9 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 Down Expand Up @@ -100,9 +95,5 @@ class RD_CORE_API LifetimeImpl final
void attach_nested(std::shared_ptr<LifetimeImpl> nested);
};
} // namespace rd
#if defined(_MSC_VER)
#pragma warning(pop)
#endif


#endif // RD_CPP_CORE_LIFETIME_H
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#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"

Expand Down Expand Up @@ -43,9 +38,5 @@ 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


#endif // RD_CPP_CORE_SEQUENTIAL_LIFETIMES_H
16 changes: 11 additions & 5 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,7 +63,15 @@ 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 ()

include(GenerateExportHeader)
generate_export_header(rd_framework_cpp
Expand All @@ -85,9 +93,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
9 changes: 0 additions & 9 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 Down Expand Up @@ -67,9 +62,5 @@ class RD_FRAMEWORK_API IProtocol : public IRdDynamic
const RName& get_location() const override;
};
} // namespace rd
#if defined(_MSC_VER)
#pragma warning(pop)
#endif


#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
{
}
}
9 changes: 0 additions & 9 deletions rd-cpp/src/rd_framework_cpp/src/main/base/ISerializersOwner.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#ifndef RD_CPP_ISERIALIZERSOWNER_H
#define RD_CPP_ISERIALIZERSOWNER_H

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

#include <unordered_set>

#include <rd_framework_export.h>
Expand All @@ -32,9 +27,5 @@ class RD_FRAMEWORK_API ISerializersOwner
virtual void registerSerializersCore(Serializers const& serializers) const = 0;
};
} // namespace rd
#if defined(_MSC_VER)
#pragma warning(pop)
#endif


#endif // RD_CPP_ISERIALIZERSOWNER_H
9 changes: 0 additions & 9 deletions rd-cpp/src/rd_framework_cpp/src/main/base/IWire.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#ifndef RD_CPP_IWIRE_H
#define RD_CPP_IWIRE_H

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

#include "reactive/base/interfaces.h"
#include "base/IRdReactive.h"
#include "reactive/Property.h"
Expand Down Expand Up @@ -48,9 +43,5 @@ class RD_FRAMEWORK_API IWire
virtual void advise(Lifetime lifetime, IRdReactive const* entity) const = 0;
};
} // namespace rd
#if defined(_MSC_VER)
#pragma warning(pop)
#endif


#endif // RD_CPP_IWIRE_H
14 changes: 7 additions & 7 deletions rd-cpp/src/rd_framework_cpp/src/main/base/RdBindableBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ bool RdBindableBase::is_bound() const
return parent != nullptr;
}

void RdBindableBase::bind(Lifetime lf, IRdDynamic const* parent, string_view name) const
void RdBindableBase::bind(Lifetime lf, IRdDynamic const* inParent, string_view name) const
{
RD_ASSERT_MSG(!is_bound(), ("Trying to bind already bound this to " + to_string(parent->get_location())));
RD_ASSERT_MSG(!is_bound(), ("Trying to bind already bound this to " + to_string(inParent->get_location())));
lf->bracket(
[this, lf, parent, &name] {
this->parent = parent;
location = parent->get_location().sub(name, ".");
[this, lf, inParent, &name] {
this->parent = inParent;
location = inParent->get_location().sub(name, ".");
this->bind_lifetime = lf;
},
[this, lf]() {
Expand Down Expand Up @@ -88,13 +88,13 @@ SerializationCtx& RdBindableBase::get_serialization_context() const
}
}

void RdBindableBase::init(Lifetime lifetime) const
void RdBindableBase::init(Lifetime inLifetime) const
{
for (const auto& it : bindable_extensions)
{
if (it.second != nullptr)
{
bindPolymorphic(*(it.second), lifetime, this, it.first);
bindPolymorphic(*(it.second), inLifetime, this, it.first);
}
}
}
Expand Down
Loading
Loading