Skip to content

Commit

Permalink
More work to make code more platform independent
Browse files Browse the repository at this point in the history
  • Loading branch information
silverchris committed Aug 7, 2022
1 parent ae23c3c commit bd48c15
Show file tree
Hide file tree
Showing 15 changed files with 365 additions and 235 deletions.
266 changes: 144 additions & 122 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${base_directory}/bin)
set(EXECUTABLE_OUTPUT_PATH ${base_directory}/bin)
file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})

SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
SET(BUILD_SHARED_LIBS OFF)
set(CMAKE_LINK_SEARCH_START_STATIC ON)
set(OPENSSL_USE_STATIC_LIBS TRUE) #Statically link openssl for Mazda target
set(Protobuf_USE_STATIC_LIBS ON) #Statically link protobuf for Mazda target
if (NOT DEFINED BUILD_RPI)
set(BUILD_MAZDA ON)
endif ()

if (DEFINED BUILD_MAZDA)
message("BUILD_MAZDA")
add_compile_definitions(BUILD_MAZDA)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
SET(BUILD_SHARED_LIBS OFF)
set(CMAKE_LINK_SEARCH_START_STATIC ON)
set(OPENSSL_USE_STATIC_LIBS TRUE) #Statically link openssl for Mazda target
set(Protobuf_USE_STATIC_LIBS ON) #Statically link protobuf for Mazda target
endif ()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules/")
SET(CMAKE_CXX_STANDARD 17)
Expand All @@ -32,27 +40,32 @@ find_package(ALSA REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(asio REQUIRED)
find_package(fdk-aac REQUIRED)
pkg_check_modules(DBUS REQUIRED "dbus-cxx-2.0")
pkg_check_modules(SIGC++ REQUIRED sigc++-3.0)
find_package(libusb-1.0 REQUIRED)
pkg_check_modules(LIBEVDEV REQUIRED libevdev)

if (DEFINED BUILD_MAZDA)
pkg_check_modules(DBUS REQUIRED "dbus-cxx-2.0")
endif ()

SET(AASDK_BUILD_STATIC ON CACHE BOOL "Build Static AASDK")
SET(AASDK_BUILD_SHARED OFF CACHE BOOL "Don't Build Shared AASDK")
SET(AASDK_TEST OFF CACHE BOOL "Don't Test AASDK")
add_subdirectory(external/aasdk)

SET(USE_STANDALONE_ASIO ON CACHE BOOL "use standalone Asio")
SET(USE_OPENSSL OFF CACHE BOOL "Don't need SSL in our webserver")
add_subdirectory(external/Simple-Web-Server)
if (DEFINED BUILD_MAZDA)
SET(USE_STANDALONE_ASIO ON CACHE BOOL "use standalone Asio")
SET(USE_OPENSSL OFF CACHE BOOL "Don't need SSL in our webserver")
add_subdirectory(external/Simple-Web-Server)

set(JSON_BuildTests OFF CACHE INTERNAL "")
set(JSON_Install OFF CACHE INTERNAL "")
add_subdirectory(external/json)
set(JSON_BuildTests OFF CACHE INTERNAL "")
set(JSON_Install OFF CACHE INTERNAL "")
add_subdirectory(external/json)

set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "")
set(BUILD_TESTS OFF CACHE INTERNAL "")
add_subdirectory(external/tinyxml2)
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "")
set(BUILD_TESTS OFF CACHE INTERNAL "")
add_subdirectory(external/tinyxml2)
endif ()

add_compile_definitions(ELPP_THREAD_SAFE)
add_compile_definitions(ELPP_STL_LOGGING)
Expand Down Expand Up @@ -99,8 +112,12 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}
${ALSA_INCLUDE_DIRS}
${SIGC++_INCLUDE_DIRS}
${ASIO_INCLUDE_DIRS}
${LIBEVDEV_INCLUDE_DIRS}
${DBUS_INCLUDE_DIRS})
${LIBEVDEV_INCLUDE_DIRS})

if (DEFINED BUILD_MAZDA)
include_directories(${DBUS_INCLUDE_DIRS})
endif ()


link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})

Expand All @@ -112,141 +129,146 @@ add_executable(autoapp ${autoapp_source_files})
target_include_directories(autoapp PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/generated/)
target_include_directories(autoapp PRIVATE ${include_directory})

add_subdirectory(src/Mazda/Dbus/com.jci.bca)
target_link_libraries(autoapp com.jci.bca)
if (DEFINED BUILD_MAZDA)
add_subdirectory(src/Mazda/Dbus/com.jci.bca)
target_link_libraries(autoapp com.jci.bca)

add_subdirectory(src/Mazda/Dbus/com.jci.bucpsa)
target_link_libraries(autoapp com.jci.bucpsa)
add_subdirectory(src/Mazda/Dbus/com.jci.bucpsa)
target_link_libraries(autoapp com.jci.bucpsa)

add_subdirectory(src/Mazda/Dbus/com.jci.nativeguictrl)
target_link_libraries(autoapp com.jci.nativeguictrl)
add_subdirectory(src/Mazda/Dbus/com.jci.nativeguictrl)
target_link_libraries(autoapp com.jci.nativeguictrl)

add_subdirectory(src/Mazda/Dbus/com.jci.aapa)
target_link_libraries(autoapp com.jci.aapa)
add_subdirectory(src/Mazda/Dbus/com.jci.aapa)
target_link_libraries(autoapp com.jci.aapa)

add_subdirectory(src/Mazda/Dbus/com.jci.lds.control)
target_link_libraries(autoapp com.jci.lds.control)
add_subdirectory(src/Mazda/Dbus/com.jci.lds.control)
target_link_libraries(autoapp com.jci.lds.control)

add_subdirectory(src/Mazda/Dbus/com.jci.lds.data)
target_link_libraries(autoapp com.jci.lds.data)
add_subdirectory(src/Mazda/Dbus/com.jci.lds.data)
target_link_libraries(autoapp com.jci.lds.data)

add_subdirectory(src/Mazda/Dbus/com.xsembedded.ServiceProvider)
target_link_libraries(autoapp com.xsembedded.ServiceProvider)
add_subdirectory(src/Mazda/Dbus/com.xsembedded.ServiceProvider)
target_link_libraries(autoapp com.xsembedded.ServiceProvider)

add_subdirectory(src/Mazda/Dbus/com.jci.navi2IHU.HUDSettings)
target_link_libraries(autoapp com.jci.navi2IHU.HUDSettings)
add_subdirectory(src/Mazda/Dbus/com.jci.navi2IHU.HUDSettings)
target_link_libraries(autoapp com.jci.navi2IHU.HUDSettings)

add_subdirectory(src/Mazda/Dbus/com.jci.vbs.navi.tmc)
target_link_libraries(autoapp com.jci.vbs.navi.tmc)
add_subdirectory(src/Mazda/Dbus/com.jci.vbs.navi.tmc)
target_link_libraries(autoapp com.jci.vbs.navi.tmc)

add_subdirectory(src/Mazda/Dbus/com.jci.vbs.navi)
target_link_libraries(autoapp com.jci.vbs.navi)
add_subdirectory(src/Mazda/Dbus/com.jci.vbs.navi)
target_link_libraries(autoapp com.jci.vbs.navi)
endif ()

target_compile_options(autoapp PUBLIC "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.")

target_link_libraries(autoapp aasdk_static)
target_link_libraries(autoapp aasdk_proto_static)
target_link_libraries(autoapp libusb)

target_include_directories(autoapp PRIVATE external/mINI/src/mini)

if (DEFINED BUILD_MAZDA)
target_include_directories(autoapp PRIVATE external/mINI/src/mini)
target_link_libraries(autoapp simple-web-server)
target_link_libraries(autoapp nlohmann_json::nlohmann_json)
target_link_libraries(autoapp tinyxml2)
target_link_libraries(autoapp ${DBUS_LIBRARIES})
endif ()

target_link_libraries(autoapp
${SIGC++_LIBRARIES}
${ALSA_LIBRARIES}
${Protobuf_LIBRARIES}
${OPENSSL_LIBRARIES}
${LIBEVDEV_LIBRARIES}
${DBUS_LIBRARIES}
fdk-aac
simple-web-server
nlohmann_json::nlohmann_json
easylogging++
toml++
tinyxml2
-static
-static-libstdc++
-static-libgcc
-pthread
)

add_custom_command(
TARGET autoapp
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug autoapp autoapp.debug
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
)
add_custom_command(
TARGET autoapp
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} --strip-all autoapp
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
)
add_custom_command(
TARGET autoapp
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=autoapp.debug autoapp
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
)


file(MAKE_DIRECTORY ${base_directory}/install/mnt/data_persist/dev/bin/)
add_custom_command(
TARGET autoapp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${EXECUTABLE_OUTPUT_PATH}/autoapp
${base_directory}/install/mnt/data_persist/dev/bin/)


set(installer_sources_directory ${sources_directory}/installer)
set(installer_include_directory)
file(GLOB_RECURSE installer_source_files ${installer_sources_directory}/*.cpp)

add_executable(aa_installer
${installer_source_files})
target_include_directories(aa_installer PRIVATE ${include_directories})
target_include_directories(aa_installer PRIVATE external/mINI/src/mini)
target_include_directories(aa_installer PRIVATE ${include_directory})

target_link_libraries(aa_installer
nlohmann_json::nlohmann_json
easylogging++
toml++
tinyxml2
-static
-static-libstdc++
-static-libgcc
-pthread
)
if (DEFINED BUILD_MAZDA)
add_custom_command(
TARGET autoapp
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug autoapp autoapp.debug
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
)
add_custom_command(
TARGET autoapp
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} --strip-all autoapp
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
)
add_custom_command(
TARGET autoapp
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=autoapp.debug autoapp
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
)


file(MAKE_DIRECTORY ${base_directory}/install/mnt/data_persist/dev/bin/)
add_custom_command(
TARGET autoapp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${EXECUTABLE_OUTPUT_PATH}/autoapp
${base_directory}/install/mnt/data_persist/dev/bin/)


set(installer_sources_directory ${sources_directory}/installer)
set(installer_include_directory)
file(GLOB_RECURSE installer_source_files ${installer_sources_directory}/*.cpp)

add_executable(aa_installer
${installer_source_files})
target_include_directories(aa_installer PRIVATE ${include_directories})
target_include_directories(aa_installer PRIVATE external/mINI/src/mini)
target_include_directories(aa_installer PRIVATE ${include_directory})

target_link_libraries(aa_installer
nlohmann_json::nlohmann_json
easylogging++
toml++
tinyxml2
-static
-static-libstdc++
-static-libgcc
-pthread
)

add_custom_command(
TARGET aa_installer
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug aa_installer aa_installer.debug
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
)
add_custom_command(
TARGET aa_installer
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} --strip-all aa_installer
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
)
add_custom_command(
TARGET aa_installer
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=aa_installer.debug aa_installer
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
)

add_custom_command(
TARGET aa_installer POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${EXECUTABLE_OUTPUT_PATH}/aa_installer
${base_directory}/install/mnt/data_persist/dev/bin/)


add_custom_command(
TARGET aa_installer
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug aa_installer aa_installer.debug
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
)
add_custom_command(
TARGET aa_installer
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} --strip-all aa_installer
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
)
add_custom_command(
TARGET aa_installer
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=aa_installer.debug aa_installer
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
)

add_custom_command(
TARGET aa_installer POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${EXECUTABLE_OUTPUT_PATH}/aa_installer
${base_directory}/install/mnt/data_persist/dev/bin/)


add_custom_target(create_tar ALL COMMAND
external/makeself.sh --target / --notemp --keep-umask --nochown install installer/openauto_installer.run openauto /mnt/data_persist/dev/bin/aa_installer
WORKING_DIRECTORY ${base_directory})
add_dependencies(create_tar autoapp)
add_dependencies(create_tar aa_installer)
add_custom_target(create_tar ALL COMMAND
external/makeself.sh --target / --notemp --keep-umask --nochown install installer/openauto_installer.run openauto /mnt/data_persist/dev/bin/aa_installer
WORKING_DIRECTORY ${base_directory})
add_dependencies(create_tar autoapp)
add_dependencies(create_tar aa_installer)
endif ()
13 changes: 10 additions & 3 deletions include/autoapp/Managers/BluetoothManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@

#include <com_jci_bca_objectProxy.h>

class BluetoothManager {
#include <autoapp/Managers/IBluetoothManager.hpp>

class BluetoothManager : public IBluetoothManager {
public:
explicit BluetoothManager(autoapp::configuration::IConfiguration::Pointer configuration,
const std::shared_ptr<DBus::Connection> &session_connection);
~BluetoothManager();
std::shared_ptr<DBus::Connection> session_connection);
~BluetoothManager() override;

void start() override;
void stop() override;

private:
autoapp::configuration::IConfiguration::Pointer configuration_;
std::shared_ptr<DBus::Connection> dbusConnection;
bool bdsconfigured = false;
uint32_t serviceId = 0;
std::shared_ptr<com_jci_bca_objectProxy> bcaClient;
Expand Down
16 changes: 16 additions & 0 deletions include/autoapp/Managers/IBluetoothManager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <autoapp/Managers/IManager.hpp>

class IBluetoothManager: public IManager{
public:
using Pointer = std::shared_ptr<IBluetoothManager>;

public:
IBluetoothManager() = default;
virtual ~IBluetoothManager() = default;

virtual void start() = 0;
virtual void stop() = 0;

};
15 changes: 15 additions & 0 deletions include/autoapp/Platform/IPlatform.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include "autoapp/Signals/Signals.hpp"

class IPlatform {
public:
using Pointer = std::shared_ptr<IPlatform>;

IPlatform() = default;
virtual ~IPlatform() = default;

Signals::Pointer signals;


};
Loading

0 comments on commit bd48c15

Please sign in to comment.