-
Notifications
You must be signed in to change notification settings - Fork 0
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
Make DCCEXProtocol cross platform #14
Conversation
As discussion on discord this PR got extended with
clang-format integrationI've added a .clang-format file. So far this file formats to the basic LLVM style. Feel free to modify it to your liking. I have not run the formatter on the code inside Unit test integrationI've added a I've written a simple test fixture for the DCCEXProtocol class class DCCEXProtocolTest : public Test {
public:
DCCEXProtocolTest();
virtual ~DCCEXProtocolTest();
protected:
DCCEXProtocol _dccexProtocol;
DCCEXProtocolDelegateMock _delegate;
StreamMock _stream;
}; This class contains an instance of Lets look at the TEST_F(DCCEXProtocolTest, allTracksOff) {
_stream << "<p0>";
EXPECT_CALL(_delegate, receivedTrackPower(TrackPower::PowerOff))
.Times(Exactly(1));
_dccexProtocol.check();
} So far so good. I also wanted to enable sanitizers to detect certain memory bugs. This made me realize that the string handling code needs work. There are numerous memory leaks because the code allocates multiple times but never frees memory. The address sanitizer further more detected a heap buffer overflow inside For the sake of this PR I've not default enabled sanitizers yet. To do so one must pass GitHub actionFinally I've added a GitHub action called |
I've deleted the commit which changed the included header files. The necessary # Create Arduino.h header
file(
WRITE ${arduinocore-api_BINARY_DIR}/Arduino.h #
"#ifndef Arduino_h\n" #
"#define Arduino_h\n" #
"#include \"ArduinoAPI.h\"\n" #
"#endif" #
) |
An upstream problem prevents compilation on case insensitive operating systems. Workaround for Windows:
|
This PR introduces rudimentary CMake support for non-Arduino targets. The CMakeLists.txt file creates a static library target called DCCEXProtocol (aliased as DCCEX::Protocol).
To get this to work the hardware independent ArduinoCore-API gets included as dependency. I've removed direct dependencies to the<Arduino.h>
header (which isn't available in the Core-API) in all files and instead included the necessary interfaces (e.g.Stream.h
,Print.h
, ...).The ArduinoCore-API has no CMake support so a
Find<PackageName>.cmake
file had to be written. A common convention is to place such files in a cmake subfolder.With those changes in place the DCCEXProtocol library can be compiled on any platform.