Skip to content

Commit d284be1

Browse files
committed
mazda building
build matrix clang warning fixes
1 parent 8aee90a commit d284be1

12 files changed

+341
-30
lines changed

.clang-format

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Defines the Chromium style for automatic reformatting.
2+
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
3+
BasedOnStyle: Chromium
4+
# This defaults to 'Auto'. Explicitly set it for a while, so that
5+
# 'vector<vector<int> >' in existing files gets formatted to
6+
# 'vector<vector<int>>'. ('Auto' means that clang-format will only use
7+
# 'int>>' if the file already contains at least one such instance.)
8+
Standard: Cpp11
9+
SortIncludes: true
10+
---
11+
Language: ObjC
12+
ColumnLimit: 100

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
*.project
55
*.workspace
66
.idea/
7-
CMakeLists.txt
87
cmake-build-debug/
98
mazda/installer/config/androidauto/data_persist/dev/bin/headunit
109
*.creator.user
1110
bin/
1211
*/version\.h
1312
.vscode
14-
build
13+
build
14+
third_party

.travis.yml

+43-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,47 @@
1-
dist: trusty
1+
dist: focal
2+
23
addons:
34
apt:
45
packages:
5-
- libdbus-c++-bin
6+
- libssl-dev
7+
- libusb-1.0-0-dev
8+
- libgstreamer1.0-dev
9+
- gstreamer1.0-gl
10+
- libgstreamer-plugins-base1.0-dev
11+
- libgstreamer-plugins-bad1.0-dev
12+
- protobuf-compiler
13+
- libprotobuf-dev
14+
- libsdl1.2-dev
15+
- libsdl2-dev
16+
- libgtk-3-dev
17+
- libudev-dev
18+
- libunwind-dev
19+
- libtool-bin
20+
- libefl-all-dev
21+
622
language: cpp
7-
before_script: cd mazda
8-
script: make clean release
9-
deploy:
10-
- provider: releases
11-
api_key: $GITHUB_TOKEN
12-
file: AndroidAuto_*.zip
13-
file_glob: true
14-
overwrite: true
15-
skip_cleanup: true
16-
on:
17-
tags: true
23+
24+
compiler:
25+
- gcc
26+
- clang
27+
28+
arch:
29+
- amd64
30+
- arm64
31+
32+
env:
33+
jobs:
34+
- BUILD_TYPE=Debug CMAKE_ARGS="-DCMAKE_STAGING_PREFIX=`pwd`/staging/usr/local"
35+
- BUILD_TYPE=Release CMAKE_ARGS="-DCMAKE_STAGING_PREFIX=`pwd`/staging/usr/local"
36+
- BUILD_TYPE=MinSizeRel CMAKE_ARGS="-DCMAKE_STAGING_PREFIX=`pwd`/staging/usr/local"
37+
38+
- BUILD_TYPE=Debug CMAKE_ARGS="-DBUILD_MAZDA=ON -DCMAKE_STAGING_PREFIX=`pwd`/staging/usr/local"
39+
- BUILD_TYPE=Release CMAKE_ARGS="-DBUILD_MAZDA=ON -DCMAKE_STAGING_PREFIX=`pwd`/staging/usr/local"
40+
- BUILD_TYPE=MinSizeRel CMAKE_ARGS="-DBUILD_MAZDA=ON -DCMAKE_STAGING_PREFIX=`pwd`/staging/usr/local"
41+
42+
script:
43+
- env
44+
- cd ${TRAVIS_BUILD_DIR}
45+
- mkdir build && cd build
46+
- cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${CMAKE_ARGS}
47+
- make install -j

CMakeLists.txt

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
cmake_minimum_required(VERSION 3.10.2)
2+
3+
if(NOT CMAKE_MODULE_PATH)
4+
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
5+
elseif()
6+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
7+
endif()
8+
9+
project(AAHU LANGUAGES CXX)
10+
11+
option(BUILD_MAZDA "Builds Mazda version of Android Auto" OFF)
12+
option(BUILD_UBUNTU "Builds Ubuntu version of Android Auto" ON)
13+
if(BUILD_MAZDA)
14+
set(BUILD_UBUNTU OFF)
15+
elseif(BUILD_UBUNTU)
16+
set(BUILD_MAZDA OFF)
17+
endif()
18+
19+
include(deps)
20+
21+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
22+
set(CMAKE_CXX_STANDARD 11)
23+
set(CMAKE_CXX_EXTENSIONS OFF)
24+
25+
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER hu/hu.proto)
26+
27+
set(SRC_FILES
28+
hu/hu_aap.cpp
29+
hu/hu_aad.cpp
30+
hu/hu_ssl.cpp
31+
hu/hu_usb.cpp
32+
hu/hu_uti.cpp
33+
hu/hu_tcp.cpp
34+
${PROTO_HEADER} ${PROTO_SRC}
35+
36+
common/audio.cpp
37+
common/command_server.cpp
38+
common/config.cpp
39+
common/glib_utils.cpp
40+
common/web++/web++.cpp
41+
)
42+
43+
set(MAZDA_SRC
44+
mazda/bt/mzd_bluetooth.cpp
45+
mazda/gps/mzd_gps.cpp
46+
mazda/hud/hud.cpp
47+
mazda/nm/mzd_nightmode.cpp
48+
mazda/callbacks.cpp
49+
mazda/outputs.cpp
50+
mazda/main.cpp
51+
)
52+
53+
set(UBUNTU_SRC
54+
ubuntu/bt/ub_bluetooth.cpp
55+
ubuntu/main.cpp
56+
ubuntu/outputs.cpp
57+
ubuntu/callbacks.cpp
58+
)
59+
60+
if(BUILD_MAZDA)
61+
list(APPEND SRC_FILES ${MAZDA_SRC})
62+
endif()
63+
64+
if(BUILD_UBUNTU)
65+
list(APPEND SRC_FILES ${UBUNTU_SRC})
66+
endif()
67+
68+
add_executable(headunit ${SRC_FILES})
69+
70+
target_include_directories(headunit PUBLIC
71+
hu common
72+
${GTK3_INCLUDE_DIRS}
73+
${USB_INCLUDE_DIRS}
74+
${GST_INCLUDE_DIRS}
75+
${CMAKE_CURRENT_BINARY_DIR}
76+
${CMAKE_SYSROOT}/usr/include/SDL2
77+
)
78+
79+
target_compile_options(headunit PUBLIC
80+
-Wno-narrowing
81+
-D__STDC_FORMAT_MACROS
82+
-DDBUS_API_SUBJECT_TO_CHANGE
83+
)
84+
85+
target_link_libraries(headunit PUBLIC
86+
${GST_LIBRARIES}
87+
${GTK3_LIBRARIES}
88+
${X11_LIBRARIES}
89+
${ALSA_LIBRARIES}
90+
${Protobuf_LIBRARY}
91+
${GLFW_STATIC_LIBRARY}
92+
${SDL2_LIBRARIES}
93+
${UDEV_LIBRARIES}
94+
${USB_LIBRARIES}
95+
${UNWIND_LIBRARIES}
96+
OpenSSL::Crypto
97+
OpenSSL::SSL
98+
Threads::Threads
99+
-v
100+
)
101+
102+
if(BUILD_MAZDA)
103+
add_dependencies(headunit dbus-cplusplus)
104+
105+
target_compile_options(headunit PUBLIC -static-libstdc++ -DCMU=1)
106+
107+
target_include_directories(headunit PUBLIC
108+
${CMAKE_STAGING_PREFIX}/include
109+
${THIRD_PARTY_DIR}/dbus-cplusplus
110+
${CMAKE_STAGING_PREFIX}/include/dbus-c++-1)
111+
112+
target_link_libraries(headunit PUBLIC
113+
${CMAKE_STAGING_PREFIX}/lib/libdbus-c++-1.a
114+
${CMAKE_STAGING_PREFIX}/lib/libdbus-c++-glib-1.a
115+
${DBUS_LIBRARIES})
116+
endif()
117+
118+
install(TARGETS headunit RUNTIME DESTINATION bin)

cmake/FindDBus.cmake

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# - Try to find DBus
2+
# Once done, this will define
3+
#
4+
# DBUS_FOUND - system has DBus
5+
# DBUS_INCLUDE_DIRS - the DBus include directories
6+
# DBUS_LIBRARIES - link these to use DBus
7+
#
8+
# Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
9+
#
10+
# Redistribution and use in source and binary forms, with or without
11+
# modification, are permitted provided that the following conditions
12+
# are met:
13+
# 1. Redistributions of source code must retain the above copyright
14+
# notice, this list of conditions and the following disclaimer.
15+
# 2. Redistributions in binary form must reproduce the above copyright
16+
# notice, this list of conditions and the following disclaimer in the
17+
# documentation and/or other materials provided with the distribution.
18+
#
19+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
20+
# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
23+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26+
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28+
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
FIND_PACKAGE(PkgConfig)
32+
PKG_CHECK_MODULES(PC_DBUS QUIET dbus-1)
33+
34+
FIND_LIBRARY(DBUS_LIBRARIES
35+
NAMES dbus-1
36+
HINTS ${PC_DBUS_LIBDIR}
37+
${PC_DBUS_LIBRARY_DIRS}
38+
)
39+
40+
FIND_PATH(DBUS_INCLUDE_DIR
41+
NAMES dbus/dbus.h
42+
HINTS ${PC_DBUS_INCLUDEDIR}
43+
${PC_DBUS_INCLUDE_DIRS}
44+
)
45+
46+
GET_FILENAME_COMPONENT(_DBUS_LIBRARY_DIR ${DBUS_LIBRARIES} PATH)
47+
FIND_PATH(DBUS_ARCH_INCLUDE_DIR
48+
NAMES dbus/dbus-arch-deps.h
49+
HINTS ${PC_DBUS_INCLUDEDIR}
50+
${PC_DBUS_INCLUDE_DIRS}
51+
${_DBUS_LIBRARY_DIR}
52+
${DBUS_INCLUDE_DIR}
53+
PATH_SUFFIXES include
54+
)
55+
56+
SET(DBUS_INCLUDE_DIRS ${DBUS_INCLUDE_DIR} ${DBUS_ARCH_INCLUDE_DIR})
57+
58+
INCLUDE(FindPackageHandleStandardArgs)
59+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(DBUS REQUIRED_VARS DBUS_INCLUDE_DIRS DBUS_LIBRARIES)

cmake/dbus.patch

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
diff --git a/include/dbus-c++/dispatcher.h b/include/dbus-c++/dispatcher.h
2+
index b5b5536..b7a4534 100644
3+
--- a/include/dbus-c++/dispatcher.h
4+
+++ b/include/dbus-c++/dispatcher.h
5+
@@ -267,6 +267,18 @@ struct Threading
6+
return new Mx;
7+
}
8+
9+
+#ifndef DBUS_HAS_RECURSIVE_MUTEX
10+
+ static bool mutex_free(Mutex *mx)
11+
+ {
12+
+ delete mx;
13+
+ return false;
14+
+ }
15+
+ static bool mutex_lock(Mutex *mx)
16+
+ {
17+
+ mx->lock();
18+
+ return false;
19+
+ }
20+
+#else
21+
static void mutex_free(Mutex *mx)
22+
{
23+
delete mx;
24+
@@ -276,6 +288,7 @@ struct Threading
25+
{
26+
mx->lock();
27+
}
28+
+#endif//DBUS_HAS_RECURSIVE_MUTEX
29+
30+
static void mutex_unlock(Mutex *mx)
31+
{
32+
diff --git a/src/eventloop-integration.cpp b/src/eventloop-integration.cpp
33+
index 0cc65c3..5776971 100644
34+
--- a/src/eventloop-integration.cpp
35+
+++ b/src/eventloop-integration.cpp
36+
@@ -38,6 +38,7 @@
37+
#include <cassert>
38+
#include <sys/poll.h>
39+
#include <fcntl.h>
40+
+#include <unistd.h>
41+
42+
using namespace DBus;
43+
using namespace std;
44+
diff --git a/src/pipe.cpp b/src/pipe.cpp
45+
index 01211b3..d0572c7 100644
46+
--- a/src/pipe.cpp
47+
+++ b/src/pipe.cpp
48+
@@ -83,5 +83,5 @@ ssize_t Pipe::read(void *buffer, unsigned int &nbytes)
49+
void Pipe::signal()
50+
{
51+
// TODO: ignoring return of read/write generates warning; maybe relevant for eventloop work...
52+
- ::write(_fd_write, '\0', 1);
53+
+ ::write(_fd_write, "\0", 1);
54+
}

cmake/deps.cmake

+36
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,39 @@ if(GIT_EXECUTABLE)
5252

5353
configure_file(cmake/version.in.h ${CMAKE_CURRENT_BINARY_DIR}/version.h @ONLY)
5454
endif()
55+
56+
if(BUILD_MAZDA)
57+
58+
find_package(DBus REQUIRED)
59+
60+
set(THIRD_PARTY_DIR ${CMAKE_SOURCE_DIR}/third_party)
61+
62+
include(ExternalProject)
63+
ExternalProject_Add(dbus-cplusplus
64+
GIT_REPOSITORY https://github.com/GENIVI/dbus-cplusplus.git
65+
GIT_TAG master
66+
GIT_SHALLOW true
67+
PATCH_COMMAND
68+
cd ${THIRD_PARTY_DIR}/dbus-cplusplus &&
69+
git checkout . &&
70+
git apply ${CMAKE_CURRENT_SOURCE_DIR}/cmake/dbus.patch
71+
SOURCE_DIR ${THIRD_PARTY_DIR}/dbus-cplusplus
72+
BUILD_IN_SOURCE 0
73+
WORKING_DIRECTORY ${THIRD_PARTY_DIR}/dbus-cplusplus
74+
CONFIGURE_COMMAND ./autogen.sh --prefix=${CMAKE_STAGING_PREFIX} --disable--ecore --disable-tests --disable-examples
75+
BUILD_COMMAND make
76+
INSTALL_COMMAND make install
77+
)
78+
79+
if(NOT CMAKE_CROSSCOMPILING)
80+
set(GEN_DBUS_HEADER_COMMAND ${CMAKE_STAGING_PREFIX}/bin/dbusxx-xml2cpp)
81+
else() # TODO - expect cross compile host to be x86-64
82+
set(GEN_DBUS_HEADER_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/mazda/dbus/dbusxx-xml2cpp)
83+
endif()
84+
85+
add_custom_command(TARGET dbus-cplusplus POST_BUILD
86+
COMMAND ${GEN_DBUS_HEADER_COMMAND} cmu_interfaces.xml --proxy=generated_cmu.h
87+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mazda/dbus
88+
COMMENT "Generating generated_cmu.h")
89+
90+
endif()

hu/hu_aap.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,8 @@
12861286
{
12871287
logd("Got command_read_fd");
12881288
IHUAnyThreadInterface::HUThreadCommand* ptr = nullptr;
1289-
if(ptr = hu_pop_command())
1289+
ptr = hu_pop_command();
1290+
if(ptr)
12901291
{
12911292
logd("Running %p", ptr);
12921293
(*ptr)(*this);

hu/hu_usb.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "hu_aap.h"
22
#include <thread>
3-
#include <libusb.h>
3+
#include <libusb-1.0/libusb.h>
44
#include <vector>
55
#include <mutex>
66
#include <condition_variable>

0 commit comments

Comments
 (0)