Skip to content

Commit

Permalink
mazda building
Browse files Browse the repository at this point in the history
    build matrix
    clang warning fixes
  • Loading branch information
jwinarske committed Oct 27, 2020
1 parent 8aee90a commit 7f73193
Show file tree
Hide file tree
Showing 12 changed files with 337 additions and 30 deletions.
12 changes: 12 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Defines the Chromium style for automatic reformatting.
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
BasedOnStyle: Chromium
# This defaults to 'Auto'. Explicitly set it for a while, so that
# 'vector<vector<int> >' in existing files gets formatted to
# 'vector<vector<int>>'. ('Auto' means that clang-format will only use
# 'int>>' if the file already contains at least one such instance.)
Standard: Cpp11
SortIncludes: true
---
Language: ObjC
ColumnLimit: 100
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
*.project
*.workspace
.idea/
CMakeLists.txt
cmake-build-debug/
mazda/installer/config/androidauto/data_persist/dev/bin/headunit
*.creator.user
bin/
*/version\.h
.vscode
build
build
third_party
56 changes: 43 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,47 @@
dist: trusty
dist: focal

addons:
apt:
packages:
- libdbus-c++-bin
- libssl-dev
- libusb-1.0-0-dev
- libgstreamer1.0-dev
- gstreamer1.0-gl
- libgstreamer-plugins-base1.0-dev
- libgstreamer-plugins-bad1.0-dev
- protobuf-compiler
- libprotobuf-dev
- libsdl1.2-dev
- libsdl2-dev
- libgtk-3-dev
- libudev-dev
- libunwind-dev
- libtool-bin
- libefl-all-dev

language: cpp
before_script: cd mazda
script: make clean release
deploy:
- provider: releases
api_key: $GITHUB_TOKEN
file: AndroidAuto_*.zip
file_glob: true
overwrite: true
skip_cleanup: true
on:
tags: true

compiler:
- gcc
- clang

arch:
- amd64
- arm64

env:
jobs:
- BUILD_TYPE=Debug CMAKE_ARGS="-DCMAKE_STAGING_PREFIX=`pwd`/staging/usr/local"
- BUILD_TYPE=Release CMAKE_ARGS="-DCMAKE_STAGING_PREFIX=`pwd`/staging/usr/local"
- BUILD_TYPE=MinSizeRel CMAKE_ARGS="-DCMAKE_STAGING_PREFIX=`pwd`/staging/usr/local"

- BUILD_TYPE=Debug CMAKE_ARGS="-DBUILD_MAZDA=ON -DCMAKE_STAGING_PREFIX=`pwd`/staging/usr/local"
- BUILD_TYPE=Release CMAKE_ARGS="-DBUILD_MAZDA=ON -DCMAKE_STAGING_PREFIX=`pwd`/staging/usr/local"
- BUILD_TYPE=MinSizeRel CMAKE_ARGS="-DBUILD_MAZDA=ON -DCMAKE_STAGING_PREFIX=`pwd`/staging/usr/local"

script:
- env
- cd ${TRAVIS_BUILD_DIR}
- mkdir build && cd build
- cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${CMAKE_ARGS}
- make install -j
118 changes: 118 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
cmake_minimum_required(VERSION 3.10.2)

if(NOT CMAKE_MODULE_PATH)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
elseif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
endif()

project(AAHU LANGUAGES CXX)

option(BUILD_MAZDA "Builds Mazda version of Android Auto" OFF)
option(BUILD_UBUNTU "Builds Ubuntu version of Android Auto" ON)
if(BUILD_MAZDA)
set(BUILD_UBUNTU OFF)
elseif(BUILD_UBUNTU)
set(BUILD_MAZDA OFF)
endif()

include(deps)

set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)

protobuf_generate_cpp(PROTO_SRC PROTO_HEADER hu/hu.proto)

set(SRC_FILES
hu/hu_aap.cpp
hu/hu_aad.cpp
hu/hu_ssl.cpp
hu/hu_usb.cpp
hu/hu_uti.cpp
hu/hu_tcp.cpp
${PROTO_HEADER} ${PROTO_SRC}

common/audio.cpp
common/command_server.cpp
common/config.cpp
common/glib_utils.cpp
common/web++/web++.cpp
)

set(MAZDA_SRC
mazda/bt/mzd_bluetooth.cpp
mazda/gps/mzd_gps.cpp
mazda/hud/hud.cpp
mazda/nm/mzd_nightmode.cpp
mazda/callbacks.cpp
mazda/outputs.cpp
mazda/main.cpp
)

set(UBUNTU_SRC
ubuntu/bt/ub_bluetooth.cpp
ubuntu/main.cpp
ubuntu/outputs.cpp
ubuntu/callbacks.cpp
)

if(BUILD_MAZDA)
list(APPEND SRC_FILES ${MAZDA_SRC})
endif()

if(BUILD_UBUNTU)
list(APPEND SRC_FILES ${UBUNTU_SRC})
endif()

add_executable(headunit ${SRC_FILES})

target_include_directories(headunit PUBLIC
hu common
${GTK3_INCLUDE_DIRS}
${USB_INCLUDE_DIRS}
${GST_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SYSROOT}/usr/include/SDL2
)

target_compile_options(headunit PUBLIC
-Wno-narrowing
-D__STDC_FORMAT_MACROS
-DDBUS_API_SUBJECT_TO_CHANGE
)

target_link_libraries(headunit PUBLIC
${GST_LIBRARIES}
${GTK3_LIBRARIES}
${X11_LIBRARIES}
${ALSA_LIBRARIES}
${Protobuf_LIBRARY}
${GLFW_STATIC_LIBRARY}
${SDL2_LIBRARIES}
${UDEV_LIBRARIES}
${USB_LIBRARIES}
${UNWIND_LIBRARIES}
OpenSSL::Crypto
OpenSSL::SSL
Threads::Threads
-v
)

if(BUILD_MAZDA)
add_dependencies(headunit dbus-cplusplus)

target_compile_options(headunit PUBLIC -static-libstdc++ -DCMU=1)

target_include_directories(headunit PUBLIC
${CMAKE_STAGING_DIR}/include
${THIRD_PARTY_DIR}/dbus-cplusplus
${CMAKE_STAGING_DIR}/include/dbus-c++-1)

target_link_libraries(headunit PUBLIC
${CMAKE_STAGING_DIR}/lib/libdbus-c++-1.a
${CMAKE_STAGING_DIR}/lib/libdbus-c++-glib-1.a
${DBUS_LIBRARIES})
endif()

install(TARGETS headunit RUNTIME DESTINATION bin)
59 changes: 59 additions & 0 deletions cmake/FindDBus.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# - Try to find DBus
# Once done, this will define
#
# DBUS_FOUND - system has DBus
# DBUS_INCLUDE_DIRS - the DBus include directories
# DBUS_LIBRARIES - link these to use DBus
#
# Copyright (C) 2012 Raphael Kubo da Costa <[email protected]>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PC_DBUS QUIET dbus-1)

FIND_LIBRARY(DBUS_LIBRARIES
NAMES dbus-1
HINTS ${PC_DBUS_LIBDIR}
${PC_DBUS_LIBRARY_DIRS}
)

FIND_PATH(DBUS_INCLUDE_DIR
NAMES dbus/dbus.h
HINTS ${PC_DBUS_INCLUDEDIR}
${PC_DBUS_INCLUDE_DIRS}
)

GET_FILENAME_COMPONENT(_DBUS_LIBRARY_DIR ${DBUS_LIBRARIES} PATH)
FIND_PATH(DBUS_ARCH_INCLUDE_DIR
NAMES dbus/dbus-arch-deps.h
HINTS ${PC_DBUS_INCLUDEDIR}
${PC_DBUS_INCLUDE_DIRS}
${_DBUS_LIBRARY_DIR}
${DBUS_INCLUDE_DIR}
PATH_SUFFIXES include
)

SET(DBUS_INCLUDE_DIRS ${DBUS_INCLUDE_DIR} ${DBUS_ARCH_INCLUDE_DIR})

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(DBUS REQUIRED_VARS DBUS_INCLUDE_DIRS DBUS_LIBRARIES)
54 changes: 54 additions & 0 deletions cmake/dbus.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
diff --git a/include/dbus-c++/dispatcher.h b/include/dbus-c++/dispatcher.h
index b5b5536..b7a4534 100644
--- a/include/dbus-c++/dispatcher.h
+++ b/include/dbus-c++/dispatcher.h
@@ -267,6 +267,18 @@ struct Threading
return new Mx;
}

+#ifndef DBUS_HAS_RECURSIVE_MUTEX
+ static bool mutex_free(Mutex *mx)
+ {
+ delete mx;
+ return false;
+ }
+ static bool mutex_lock(Mutex *mx)
+ {
+ mx->lock();
+ return false;
+ }
+#else
static void mutex_free(Mutex *mx)
{
delete mx;
@@ -276,6 +288,7 @@ struct Threading
{
mx->lock();
}
+#endif//DBUS_HAS_RECURSIVE_MUTEX

static void mutex_unlock(Mutex *mx)
{
diff --git a/src/eventloop-integration.cpp b/src/eventloop-integration.cpp
index 0cc65c3..5776971 100644
--- a/src/eventloop-integration.cpp
+++ b/src/eventloop-integration.cpp
@@ -38,6 +38,7 @@
#include <cassert>
#include <sys/poll.h>
#include <fcntl.h>
+#include <unistd.h>

using namespace DBus;
using namespace std;
diff --git a/src/pipe.cpp b/src/pipe.cpp
index 01211b3..d0572c7 100644
--- a/src/pipe.cpp
+++ b/src/pipe.cpp
@@ -83,5 +83,5 @@ ssize_t Pipe::read(void *buffer, unsigned int &nbytes)
void Pipe::signal()
{
// TODO: ignoring return of read/write generates warning; maybe relevant for eventloop work...
- ::write(_fd_write, '\0', 1);
+ ::write(_fd_write, "\0", 1);
}
32 changes: 32 additions & 0 deletions cmake/deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,35 @@ if(GIT_EXECUTABLE)

configure_file(cmake/version.in.h ${CMAKE_CURRENT_BINARY_DIR}/version.h @ONLY)
endif()

if(BUILD_MAZDA)

find_package(DBus REQUIRED)

set(THIRD_PARTY_DIR ${CMAKE_SOURCE_DIR}/third_party)

include(ExternalProject)
ExternalProject_Add(dbus-cplusplus
GIT_REPOSITORY https://github.com/GENIVI/dbus-cplusplus.git
GIT_TAG master
GIT_SHALLOW true
PATCH_COMMAND
cd ${THIRD_PARTY_DIR}/dbus-cplusplus &&
git checkout . &&
git apply ${CMAKE_CURRENT_SOURCE_DIR}/cmake/dbus.patch
SOURCE_DIR ${THIRD_PARTY_DIR}/dbus-cplusplus
BUILD_IN_SOURCE 0
WORKING_DIRECTORY ${THIRD_PARTY_DIR}/dbus-cplusplus
CONFIGURE_COMMAND ./autogen.sh --prefix=${CMAKE_STAGING_PREFIX} --disable--ecore --disable-tests --disable-examples
BUILD_COMMAND make
INSTALL_COMMAND make install
)

message(STATUS "CMAKE_CROSSCOMPILING=${CMAKE_CROSSCOMPILING}")
message(STATUS "CMAKE_CROSSCOMPILING_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}")

add_custom_command(TARGET dbus-cplusplus POST_BUILD
COMMAND ${CMAKE_STAGING_PREFIX}/bin/dbusxx-xml2cpp cmu_interfaces.xml --proxy=generated_cmu.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mazda/dbus
COMMENT "Generating generated_cmu.h")
endif()
3 changes: 2 additions & 1 deletion hu/hu_aap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,8 @@
{
logd("Got command_read_fd");
IHUAnyThreadInterface::HUThreadCommand* ptr = nullptr;
if(ptr = hu_pop_command())
ptr = hu_pop_command();
if(ptr)
{
logd("Running %p", ptr);
(*ptr)(*this);
Expand Down
2 changes: 1 addition & 1 deletion hu/hu_usb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "hu_aap.h"
#include <thread>
#include <libusb.h>
#include <libusb-1.0/libusb.h>
#include <vector>
#include <mutex>
#include <condition_variable>
Expand Down
Loading

0 comments on commit 7f73193

Please sign in to comment.