1set(_trout_VHAL_CXX_FLAGS
2    -std=c++17
3    -Wall -Werror
4    -Wno-reorder-init-list
5)
6
7include(${trout_SRC_ROOT}/cmake/fmtlib.cmake)
8include(${trout_SRC_ROOT}/cmake/android.cmake)
9include(${trout_SRC_ROOT}/cmake/default_native_vhal.cmake)
10include(${trout_SRC_ROOT}/cmake/grpc.cmake)
11include(${trout_SRC_ROOT}/cmake/jsoncpp.cmake)
12include(${trout_SRC_ROOT}/cmake/protobuf.cmake)
13include(${trout_SRC_ROOT}/cmake/utils/grpc_cpp_generator.cmake)
14
15get_filename_component(trout_VHAL_SRC_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/.. ABSOLUTE)
16set(trout_VHAL_PREBUILT_DIR ${trout_VHAL_SRC_ROOT}/agl_build/prebuilt)
17
18if (NOT trout_GENS_DIR)
19  set(trout_GENS_DIR ${PROJECT_BINARY_DIR}/gens)
20endif()
21
22
23trout_generate_grpc_cpp_from_proto(
24    INCLUDES
25    ${trout_NATIVE_VHAL_ROOT_DIR}/impl/vhal_v2_0/proto
26    SRCS
27    ${trout_NATIVE_VHAL_ROOT_DIR}/impl/vhal_v2_0/proto/VehicleHalProto.proto
28    ${trout_VHAL_SRC_ROOT}/proto/VehicleServer.proto)
29
30# ========== Protobuf generated code ==================
31
32add_library(vehicle_hal_protobuf_gen STATIC
33    ${trout_GENS_DIR}/VehicleHalProto.pb.cc
34    ${trout_GENS_DIR}/VehicleHalProto.grpc.pb.cc
35    ${trout_GENS_DIR}/VehicleServer.pb.cc
36    ${trout_GENS_DIR}/VehicleServer.grpc.pb.cc
37)
38
39target_link_libraries(vehicle_hal_protobuf_gen
40    ${trout_GRPCXX_LIBRARIES}
41)
42
43target_compile_options(vehicle_hal_protobuf_gen PRIVATE ${_trout_VHAL_CXX_FLAGS} -Wno-array-bounds)
44
45# ========== vehicle_hal_grpc_server ==============
46
47add_executable(vehicle_hal_grpc_server
48    ${trout_VHAL_SRC_ROOT}/VirtualizationGrpcServer.cpp
49    ${trout_VHAL_SRC_ROOT}/GarageModeServerSideHandler.cpp
50    ${trout_VHAL_SRC_ROOT}/GrpcVehicleServer.cpp
51    ${trout_VHAL_SRC_ROOT}/PowerStateListener.cpp
52    ${trout_VHAL_SRC_ROOT}/Utils.cpp
53
54    ${trout_NATIVE_VHAL_ROOT_DIR}/common/src/Obd2SensorStore.cpp
55    ${trout_NATIVE_VHAL_ROOT_DIR}/common/src/VehicleObjectPool.cpp
56    ${trout_NATIVE_VHAL_ROOT_DIR}/common/src/VehicleUtils.cpp
57    ${trout_NATIVE_VHAL_ROOT_DIR}/common/src/VehiclePropertyStore.cpp
58    ${trout_NATIVE_VHAL_ROOT_DIR}/impl/vhal_v2_0/VehicleHalServer.cpp
59    ${trout_NATIVE_VHAL_ROOT_DIR}/impl/vhal_v2_0/GeneratorHub.cpp
60    ${trout_NATIVE_VHAL_ROOT_DIR}/impl/vhal_v2_0/JsonFakeValueGenerator.cpp
61    ${trout_NATIVE_VHAL_ROOT_DIR}/impl/vhal_v2_0/LinearFakeValueGenerator.cpp
62    ${trout_NATIVE_VHAL_ROOT_DIR}/impl/vhal_v2_0/ProtoMessageConverter.cpp
63)
64
65target_include_directories(vehicle_hal_grpc_server
66    PRIVATE ${trout_ANDROID_INCLUDE_DIRS}
67    PRIVATE ${trout_GENS_DIR}
68    PRIVATE ${trout_JSONCPP_INCLUDE_DIRS}
69    PRIVATE ${trout_NAVTIVE_VHAL_COMMON_INCLUDE_DIRS}
70    PRIVATE ${trout_NAVTIVE_VHAL_IMPL_INCLUDE_DIRS}
71    PRIVATE ${trout_VHAL_PREBUILT_DIR}/include
72)
73
74target_link_libraries(vehicle_hal_grpc_server
75    vehicle_hal_protobuf_gen
76    ${trout_ANDROID_LIBRARIES}
77    ${trout_JSONCPP_LIBRARIES}
78)
79
80target_compile_options(vehicle_hal_grpc_server PRIVATE ${_trout_VHAL_CXX_FLAGS})
81