blob: 3a47fe1946c2599aab60e3e71683f2e77ee204b1 [file] [log] [blame]
Joe Onorato1754d742016-11-21 17:51:35 -08001# Copyright (C) 2016 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15LOCAL_PATH:= $(call my-dir)
Yi Jin0a3406f2017-06-22 19:23:11 -070016
Yi Jin3c034c92017-12-22 17:36:47 -080017# proto files used in incidentd to generate cppstream proto headers.
Yi Jin1a11fa12018-02-22 16:44:10 -080018PROTO_FILES:= frameworks/base/core/proto/android/util/log.proto \
19 frameworks/base/core/proto/android/os/data.proto
Yi Jin3c034c92017-12-22 17:36:47 -080020
Yi Jin0a3406f2017-06-22 19:23:11 -070021# ========= #
22# incidentd #
23# ========= #
24
Joe Onorato1754d742016-11-21 17:51:35 -080025include $(CLEAR_VARS)
26
27LOCAL_MODULE := incidentd
28
Yi Jin4e843102018-02-14 15:36:18 -080029LOCAL_SRC_FILES := $(call all-cpp-files-under, src) \
Joe Onorato1754d742016-11-21 17:51:35 -080030
31LOCAL_CFLAGS += \
32 -Wall -Werror -Wno-missing-field-initializers -Wno-unused-variable -Wunused-parameter
33
34ifeq (debug,)
35 LOCAL_CFLAGS += \
36 -g -O0
37else
38 # optimize for size (protobuf glop can get big)
39 LOCAL_CFLAGS += \
40 -Os
41endif
42
Yi Jinf8601842017-08-15 22:01:41 -070043LOCAL_C_INCLUDES += $(LOCAL_PATH)/src
44
Joe Onorato1754d742016-11-21 17:51:35 -080045LOCAL_SHARED_LIBRARIES := \
46 libbase \
47 libbinder \
48 libcutils \
49 libincident \
50 liblog \
Yi Jin329130b2018-02-09 16:47:47 -080051 libprotobuf-cpp-lite \
Yi Jinc23fad22017-09-15 17:24:59 -070052 libprotoutil \
Joe Onorato1754d742016-11-21 17:51:35 -080053 libselinux \
54 libservices \
55 libutils
56
Yi Jinf8601842017-08-15 22:01:41 -070057LOCAL_MODULE_CLASS := EXECUTABLES
Yi Jin3c034c92017-12-22 17:36:47 -080058
Yi Jinf8601842017-08-15 22:01:41 -070059gen_src_dir := $(local-generated-sources-dir)
60
Yi Jin3c034c92017-12-22 17:36:47 -080061# generate section_list.cpp
62GEN_LIST := $(gen_src_dir)/src/section_list.cpp
63$(GEN_LIST): $(HOST_OUT_EXECUTABLES)/incident-section-gen
64$(GEN_LIST): PRIVATE_CUSTOM_TOOL = \
Yi Jinf8601842017-08-15 22:01:41 -070065 $(HOST_OUT_EXECUTABLES)/incident-section-gen incidentd > $@
Yi Jin3c034c92017-12-22 17:36:47 -080066$(GEN_LIST): $(HOST_OUT_EXECUTABLES)/incident-section-gen
Yi Jinf8601842017-08-15 22:01:41 -070067 $(transform-generated-source)
Yi Jin3c034c92017-12-22 17:36:47 -080068LOCAL_GENERATED_SOURCES += $(GEN_LIST)
69GEN_LIST:=
70
71# generate cppstream proto, add proto files to PROTO_FILES
72GEN_PROTO := $(gen_src_dir)/proto.timestamp
73$(GEN_PROTO): $(HOST_OUT_EXECUTABLES)/aprotoc $(HOST_OUT_EXECUTABLES)/protoc-gen-cppstream $(PROTO_FILES)
74$(GEN_PROTO): PRIVATE_GEN_SRC_DIR := $(gen_src_dir)
75$(GEN_PROTO): PRIVATE_CUSTOM_TOOL = \
76 $(HOST_OUT_EXECUTABLES)/aprotoc --plugin=protoc-gen-cppstream=$(HOST_OUT_EXECUTABLES)/protoc-gen-cppstream \
77 --cppstream_out=$(PRIVATE_GEN_SRC_DIR) -Iexternal/protobuf/src -I . \
78 $(PROTO_FILES) \
79 && touch $@
80$(GEN_PROTO): $(HOST_OUT_EXECUTABLES)/aprotoc
81 $(transform-generated-source)
82LOCAL_GENERATED_SOURCES += $(GEN_PROTO)
83GEN_PROTO:=
Yi Jinf8601842017-08-15 22:01:41 -070084
85gen_src_dir:=
Yi Jinf8601842017-08-15 22:01:41 -070086
Joe Onorato1754d742016-11-21 17:51:35 -080087LOCAL_INIT_RC := incidentd.rc
Joe Onorato1754d742016-11-21 17:51:35 -080088
89include $(BUILD_EXECUTABLE)
Yi Jin0a3406f2017-06-22 19:23:11 -070090
91# ============== #
92# incidentd_test #
93# ============== #
94
95include $(CLEAR_VARS)
96
97LOCAL_MODULE := incidentd_test
98LOCAL_COMPATIBILITY_SUITE := device-tests
99LOCAL_MODULE_TAGS := tests
100
101LOCAL_CFLAGS := -Werror -Wall -Wno-unused-variable -Wunused-parameter
102
103LOCAL_C_INCLUDES += $(LOCAL_PATH)/src
104
Yi Jin4e843102018-02-14 15:36:18 -0800105LOCAL_SRC_FILES := $(call all-cpp-files-under, tests) \
Yi Jinc23fad22017-09-15 17:24:59 -0700106 src/PrivacyBuffer.cpp \
Yi Jin0a3406f2017-06-22 19:23:11 -0700107 src/FdBuffer.cpp \
Yi Jin99c248f2017-08-25 18:11:58 -0700108 src/Privacy.cpp \
Yi Jin0a3406f2017-06-22 19:23:11 -0700109 src/Reporter.cpp \
110 src/Section.cpp \
Yi Jin4e843102018-02-14 15:36:18 -0800111 src/Throttler.cpp \
Yi Jinb592e3b2018-02-01 15:17:04 -0800112 src/incidentd_util.cpp \
Yi Jinadd11e92017-07-30 16:10:07 -0700113 src/report_directory.cpp \
Yi Jin0a3406f2017-06-22 19:23:11 -0700114
115LOCAL_STATIC_LIBRARIES := \
116 libgmock \
117
118LOCAL_SHARED_LIBRARIES := \
119 libbase \
120 libbinder \
121 libcutils \
122 libincident \
123 liblog \
Yi Jin437aa6e2018-01-10 11:34:26 -0800124 libprotobuf-cpp-lite \
Yi Jinc23fad22017-09-15 17:24:59 -0700125 libprotoutil \
Yi Jin0a3406f2017-06-22 19:23:11 -0700126 libselinux \
127 libservices \
128 libutils \
129
Yi Jin5e4ce2c2017-11-13 21:06:26 -0800130LOCAL_TEST_DATA := $(call find-test-data-in-subdirs, $(LOCAL_PATH), *, testdata)
Yi Jin0a3406f2017-06-22 19:23:11 -0700131
Yi Jin3c034c92017-12-22 17:36:47 -0800132LOCAL_MODULE_CLASS := NATIVE_TESTS
133gen_src_dir := $(local-generated-sources-dir)
134# generate cppstream proto for testing
Yi Jin1a11fa12018-02-22 16:44:10 -0800135GEN_PROTO := $(gen_src_dir)/test.proto.timestamp
Yi Jin3c034c92017-12-22 17:36:47 -0800136$(GEN_PROTO): $(HOST_OUT_EXECUTABLES)/aprotoc $(HOST_OUT_EXECUTABLES)/protoc-gen-cppstream $(PROTO_FILES)
137$(GEN_PROTO): PRIVATE_GEN_SRC_DIR := $(gen_src_dir)
138$(GEN_PROTO): PRIVATE_CUSTOM_TOOL = \
139 $(HOST_OUT_EXECUTABLES)/aprotoc --plugin=protoc-gen-cppstream=$(HOST_OUT_EXECUTABLES)/protoc-gen-cppstream \
140 --cppstream_out=$(PRIVATE_GEN_SRC_DIR) -Iexternal/protobuf/src -I . \
141 $(PROTO_FILES) \
142 && touch $@
143$(GEN_PROTO): $(HOST_OUT_EXECUTABLES)/aprotoc
144 $(transform-generated-source)
145LOCAL_GENERATED_SOURCES += $(GEN_PROTO)
146GEN_PROTO:=
147
148gen_src_dir:=
149
Yi Jin0a3406f2017-06-22 19:23:11 -0700150include $(BUILD_NATIVE_TEST)