Skip to content

Commit

Permalink
Replace all object libraries with static ones (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickKa authored Nov 4, 2023
2 parents 04270ab + 88f720a commit 3f4fdf5
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 29 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ endif()

# ---- Declare targets ----

add_library(Sts1CobcSw_Dummy OBJECT)
add_library(Sts1CobcSw_Edu OBJECT)
add_library(Sts1CobcSw_Dummy STATIC)
add_library(Sts1CobcSw_Edu STATIC)
add_library(Sts1CobcSw_Serial INTERFACE)
add_library(Sts1CobcSw_Utility OBJECT)
add_library(Sts1CobcSw_Utility STATIC)
add_program(HelloDummy)
# add_program(Heartbeat)

if(CMAKE_SYSTEM_NAME STREQUAL Generic)
add_library(Sts1CobcSw_FileSystem OBJECT)
add_library(Sts1CobcSw_Periphery OBJECT)
add_library(Sts1CobcSw_FileSystem STATIC)
add_library(Sts1CobcSw_Periphery STATIC)
add_library(Sts1CobcSw_Hal INTERFACE)
add_program(CobcSw)
endif()
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Structure](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1204r0.html
spell out the directory structure, e.g., `#include <Sts1CobcSw/Hal/IoNames.hpp>`.
- Also, all includes, even the "project local" ones use `<>` instead of `""`.
- Subfolders for the source code should comprise somewhat standalone "components".
- There should be an OBJECT or INTERFACE library target for each component (this should
- There should be a STATIC or INTERFACE library target for each component (this should
make linking source code dependencies for tests easier).
- Each subfolder should have its own `CMakeLists.txt`
- Rodos already provides some kind of hardware abstraction. `Hal/` should therefore
Expand Down
2 changes: 1 addition & 1 deletion Sts1CobcSw/Edu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ target_link_libraries(Sts1CobcSw_Edu PRIVATE Sts1CobcSw_Utility)

if(CMAKE_SYSTEM_NAME STREQUAL Generic)
target_sources(Sts1CobcSw_Edu PRIVATE Edu.cpp)
target_link_libraries(Sts1CobcSw_Edu PUBLIC Sts1CobcSw_Hal)
target_link_libraries(Sts1CobcSw_Edu PUBLIC Sts1CobcSw_Hal Sts1CobcSw_Periphery)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
target_sources(Sts1CobcSw_Edu PRIVATE EduMock.cpp)
Expand Down
3 changes: 2 additions & 1 deletion Sts1CobcSw/Edu/Edu.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <Sts1CobcSw/Edu/Edu.hpp>
#include <Sts1CobcSw/Edu/Names.hpp>
#include <Sts1CobcSw/Hal/Communication.hpp>
#include <Sts1CobcSw/Hal/GpioPin.hpp>
#include <Sts1CobcSw/Hal/IoNames.hpp>
#include <Sts1CobcSw/Periphery/PersistentState.hpp>
#include <Sts1CobcSw/Serial/Serial.hpp>
#include <Sts1CobcSw/Utility/Crc32.hpp>
Expand All @@ -14,7 +16,6 @@

namespace sts1cobcsw::edu
{

namespace ts = type_safe;
using ts::operator""_u16;
using ts::operator""_usize;
Expand Down
11 changes: 0 additions & 11 deletions Sts1CobcSw/Edu/Edu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,15 @@

#include <Sts1CobcSw/Edu/Enums.hpp>
#include <Sts1CobcSw/Edu/Structs.hpp>
#include <Sts1CobcSw/Hal/GpioPin.hpp>
#include <Sts1CobcSw/Hal/IoNames.hpp>
#include <Sts1CobcSw/Serial/Byte.hpp>

#include <rodos_no_using_namespace.h>

#include <cstdint>
#include <span>


namespace sts1cobcsw::edu
{


// TODO: Think about const-correctness and whether to make uart_ mutable or not
//
// TODO: There is no reason for this to be a class (there is no class invariant), so this being a
// class just unnecessarily exposes the private members and functions to the user which makes
// mocking harder.

auto Initialize() -> void;
auto TurnOn() -> void;
auto TurnOff() -> void;
Expand Down
1 change: 0 additions & 1 deletion Sts1CobcSw/Periphery/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
target_link_libraries(Sts1CobcSw_Periphery PUBLIC rodos::rodos type_safe Sts1CobcSw_Serial)
target_link_libraries(Sts1CobcSw_Periphery PRIVATE Sts1CobcSw_Utility)

if(CMAKE_SYSTEM_NAME STREQUAL Generic)
target_sources(Sts1CobcSw_Periphery PRIVATE PersistentState.cpp Flash.cpp Fram.cpp)
Expand Down
9 changes: 4 additions & 5 deletions Tests/HardwareTests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
add_subdirectory(EduCommandTests)
add_subdirectory(ThreadTests)

add_library(Sts1CobcSwTests_Utility OBJECT Utility.cpp)
add_library(Sts1CobcSwTests_Utility STATIC Utility.cpp)
target_link_libraries(Sts1CobcSwTests_Utility PRIVATE rodos::rodos)
target_include_directories(
Sts1CobcSwTests_Utility PUBLIC ${warning_guard} "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>"
Expand All @@ -13,19 +13,18 @@ target_link_libraries(Sts1CobcSwTests_Crc32 PRIVATE rodos::rodos)
add_program(FileSystem FileSystem.test.cpp)
target_link_libraries(
Sts1CobcSwTests_FileSystem PRIVATE rodos::rodos littlefs::littlefs Sts1CobcSw_FileSystem
Sts1CobcSw_Periphery Sts1CobcSw_Utility
)

add_program(Flash Flash.test.cpp)
target_link_libraries(
Sts1CobcSwTests_Flash PRIVATE rodos::rodos Sts1CobcSw_Periphery Sts1CobcSw_Serial
Sts1CobcSwTests_Utility Sts1CobcSw_Utility
Sts1CobcSwTests_Utility
)

add_program(Fram Fram.test.cpp)
target_link_libraries(
Sts1CobcSwTests_Fram PRIVATE rodos::rodos Sts1CobcSw_Periphery Sts1CobcSwTests_Utility
Sts1CobcSw_Utility
Sts1CobcSwTests_Fram PRIVATE rodos::rodos Sts1CobcSw_Periphery Sts1CobcSw_Serial
Sts1CobcSwTests_Utility
)

add_program(Gpio Gpio.test.cpp)
Expand Down
2 changes: 1 addition & 1 deletion Tests/HardwareTests/EduCommandTests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
add_program(EduCommands EduCommands.test.cpp)
target_link_libraries(
Sts1CobcSwTests_EduCommands PUBLIC rodos::rodos Sts1CobcSw_Utility Sts1CobcSw_Serial
Sts1CobcSw_Periphery Sts1CobcSw_Hal Sts1CobcSw_Edu
Sts1CobcSw_Hal Sts1CobcSw_Edu
)

get_property(
Expand Down
3 changes: 1 addition & 2 deletions Tests/HardwareTests/ThreadTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ target_sources(
${source_directory}/EduHeartbeatThread.cpp ${source_directory}/TopicsAndSubscribers.cpp
)
target_link_libraries(
Sts1CobcSwTests_EduPowerManagement PRIVATE rodos::rodos type_safe Sts1CobcSw_Periphery
Sts1CobcSw_Hal Sts1CobcSw_Utility Sts1CobcSw_Edu
Sts1CobcSwTests_EduPowerManagement PRIVATE rodos::rodos Sts1CobcSw_Hal Sts1CobcSw_Edu
)

get_property(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <Sts1CobcSw/Edu/Edu.hpp>
#include <Sts1CobcSw/Hal/Communication.hpp>
#include <Sts1CobcSw/Hal/GpioPin.hpp>
#include <Sts1CobcSw/Hal/PinNames.hpp>
#include <Sts1CobcSw/Hal/IoNames.hpp>
#include <Sts1CobcSw/TopicsAndSubscribers.hpp>

#include <rodos_no_using_namespace.h>
Expand Down

0 comments on commit 3f4fdf5

Please sign in to comment.