1#!/bin/bash
2
3# Copyright (C) 2020 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18set -e
19
20build_common() {
21    local current_dir=`pwd`
22    local bash_src_dir=$(realpath $(dirname ${BASH_SOURCE[0]}))
23    local build_type=$1
24    local cmake_options=""
25    shift
26    if [[ ${build_type} == "agl" ]]; then
27        cmake_options="${cmake_options} -DCMAKE_TOOLCHAIN_FILE=${bash_src_dir}/toolchain/agl_toolchain.cmake"
28    fi
29
30    mkdir -p ${TROUT_SRC_ROOT:-${bash_src_dir}}/out/${build_type}_build && cd $_
31    cmake -G Ninja ${cmake_options} ../..
32    ninja $@
33    cd ${current_dir}
34}
35
36build_host_tools() {
37    build_common host $@
38}
39
40build_agl_service() {
41    build_common agl $@
42}
43
44if [[ ! $(which aprotoc) && ! $(which protoc-gen-grpc-cpp-plugin) ]]; then
45    build_host_tools protoc grpc_cpp_plugin
46fi
47
48build_agl_service android_audio_controller
49build_agl_service dumpstate_grpc_server
50build_agl_service garage_mode_helper
51build_agl_service vehicle_hal_grpc_server
52build_agl_service watchdog_test_service
53