Skip to content
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
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
/docs/guided_examples/*/build*
/docs/guided_examples/flake.lock

# Avoid adding symlinks
/support/ides/clion/*

# Products of SimoSim
Simo.log
statistics.yaml
Expand Down
11 changes: 8 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@
};

derivationAttributes = {
default = pkgs.clangStdenv.mkDerivation simoBaseAttributes;
clang = pkgs.clangStdenv.mkDerivation simoBaseAttributes;
gcc = pkgs.gccStdenv.mkDerivation simoBaseAttributes;
default = pkgs.clangStdenv.mkDerivation simoBaseAttributes;
clang = pkgs.clangStdenv.mkDerivation simoBaseAttributes;
gcc = pkgs.gccStdenv.mkDerivation simoBaseAttributes;
};
in
{
Expand All @@ -106,11 +106,16 @@
{
inputsFrom = [ derivationAttributes.default ];
packages = with pkgs; [
git
bashInteractive
clang-tools
ast-grep
# For llvm-cov
llvmPackages.llvm
];
shellHook = ''
export SHELL="${pkgs.bashInteractive}/bin/bash"
'';
};
}
);
Expand Down
17 changes: 17 additions & 0 deletions include/Simo/port/Port.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ class SIMO_PUBLIC OutPort : public Port {
std::abort();
}

SEND_OUTCOME send(Payload& payload) {
storage = payload;
switch (state_) {
case PORT_STATE::EMPTY:
state_ = PORT_STATE::FILLED;
return SEND_OUTCOME::NEW;
case PORT_STATE::FILLED:
state_ = PORT_STATE::FILLED;
return SEND_OUTCOME::REPLACED;
}
std::abort();
}

void clear() { state_ = PORT_STATE::EMPTY; }

PORT_STATE state() const { return state_; }
Expand Down Expand Up @@ -172,6 +185,10 @@ class SIMO_PUBLIC BidirectionalPortTyped : public Port {
return out_port.send(std::move(payload));
}

OutPort<OutPayload>::SEND_OUTCOME send_out(OutPayload& payload) {
return out_port.send(payload);
}

void clear_out() { out_port.clear(); }

void clear_in() { in_port.clear(); }
Expand Down
13 changes: 6 additions & 7 deletions support/ides/clion/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Use Nix packages in CLion

Based on [this](https://gist.github.com/pmenke-de/2fed80213c48c2fe80891678f4fa3b42),
but reworked to use flakes.
From the terminal, open a development environment with `nix develop`.

1. Run `support/ides/clion/setup-symlinks.sh` to expose some nix binaries
2. In `Settings` -> `Build, Execution, Deployment` -> `Toolchains`, create a new toolchain
3. Set CMake executable to `support/ides/clion/nix-cmake.sh` and the other elements of the
toolchain to the symlinks created in step 1.
Inside the development environment, launch CLion.

Note it is important to set the symlink of ctest to be able to run unit-tests from CLion.
On macOS, this can be done with `open -na "CLion.app"`.

One issue is that the integrated terminal may complain about `bash: bind: command not found`
and show escape symbol. The solution is to run `nix develop` in the terminal.
29 changes: 0 additions & 29 deletions support/ides/clion/nix-cmake.sh

This file was deleted.

19 changes: 0 additions & 19 deletions support/ides/clion/nix-run.sh

This file was deleted.

26 changes: 0 additions & 26 deletions support/ides/clion/setup-symlinks.sh

This file was deleted.

2 changes: 2 additions & 0 deletions tests/Simo/MainLoopTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "support/BoostInclude.h"

namespace Simo::Tests {
class TestModule : public Simo::Module {
public:
Simo::InitializationStatus initialize(Simo::Context& ctx,
Expand Down Expand Up @@ -97,3 +98,4 @@ BOOST_AUTO_TEST_CASE(InitializationFailure) {
ss << initialize_success;
BOOST_CHECK_EQUAL(ss.str(), initialization_success_str);
}
} // namespace Simo::Tests
2 changes: 2 additions & 0 deletions tests/Simo/SimulationContextTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "support/BoostInclude.h"

namespace Simo::Tests {
class InitTrackingModule final : public Simo::Module {
public:
Simo::InitializationStatus initialize(
Expand Down Expand Up @@ -263,3 +264,4 @@ BOOST_AUTO_TEST_CASE(ModuleParametersGetSubtreeHitAndMiss) {
auto missing = params.get_subtree("missing");
BOOST_CHECK_EQUAL(missing.has_value(), false);
}
} // namespace Simo::Tests
2 changes: 2 additions & 0 deletions tests/collection/CollectionTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define DYNLIB_EXT "so"
#endif

namespace Simo::Tests {
namespace {
std::filesystem::path collection_library_path() {
// Assuming tests are run from the build folder
Expand Down Expand Up @@ -264,3 +265,4 @@ BOOST_AUTO_TEST_CASE(collection_with_lib_move_assignment_and_self_move) {

BOOST_CHECK_EQUAL(destination.get_collection(), source_collection);
}
} // namespace Simo::Tests
4 changes: 3 additions & 1 deletion tests/core/RadixHeap/RadixHeapTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

#include "support/BoostInclude.h"

using Simo::Internal::RadixHeap;
namespace Simo::Tests {
using Internal::RadixHeap;

BOOST_AUTO_TEST_CASE(pushElements) {
RadixHeap heap;
Expand Down Expand Up @@ -96,3 +97,4 @@ BOOST_AUTO_TEST_CASE(pushElementReorder) {
BOOST_CHECK_EQUAL(heap.peek(), 0);
BOOST_CHECK_EQUAL(heap.size(), 1);
}
} // namespace Simo::Tests
2 changes: 2 additions & 0 deletions tests/core/TimePeriod/TimePeriodTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "Simo/Simo.h"
#include "support/BoostInclude.h"

namespace Simo::Tests {
BOOST_AUTO_TEST_CASE(TimeUnitConversions) {
using Simo::Time;

Expand Down Expand Up @@ -110,3 +111,4 @@ BOOST_AUTO_TEST_CASE(TimeJsonSerializationAndParsing) {
BOOST_CHECK(invalid_error);
BOOST_CHECK_EQUAL(unchanged.to_picoseconds(), 99U);
}
} // namespace Simo::Tests
2 changes: 2 additions & 0 deletions tests/module/ModuleTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

namespace fs = std::filesystem;

namespace Simo::Tests {
namespace {

[[nodiscard]] std::string read_file_contents(
Expand Down Expand Up @@ -121,3 +122,4 @@ BOOST_AUTO_TEST_CASE(ModuleChild) {
BOOST_CHECK_EQUAL(child_status.success(), true);
BOOST_CHECK_EQUAL(p_child.name(), "root/child");
}
} // namespace Simo::Tests
2 changes: 2 additions & 0 deletions tests/parameter/ParameterTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "support/BoostInclude.h"

namespace Simo::Tests {
BOOST_AUTO_TEST_CASE(ParameterTyped_default_constructor_and_setters) {
using Simo::Parameter::ParameterTyped;

Expand Down Expand Up @@ -172,3 +173,4 @@ BOOST_AUTO_TEST_CASE(ParameterTrie_subtrie_lookup_branches) {
BOOST_CHECK_EQUAL(nested_value, &value_param);
BOOST_CHECK_CLOSE(nested_value->value(), 3.14, 0.0001);
}
} // namespace Simo::Tests
2 changes: 2 additions & 0 deletions tests/statistics/StatisticsTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "support/BoostInclude.h"

namespace Simo::Tests {
namespace {

class NamedPort final : public Simo::Port {
Expand Down Expand Up @@ -467,3 +468,4 @@ BOOST_AUTO_TEST_CASE(CollectorInitializeFailsWithInvalidParameters) {

BOOST_CHECK_EQUAL(collector.initialize(sim_ctx, params).success(), false);
}
} // namespace Simo::Tests