1# Copyright (C) 2015 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 15# Default values for the USE flags. Override these USE flags from your product 16# by setting BRILLO_USE_* values. Note that we define local variables like 17# local_use_* to prevent leaking our default setting for other packages. 18local_use_dbus := $(if $(BRILLO_USE_DBUS),$(BRILLO_USE_DBUS),1) 19 20LOCAL_PATH := $(call my-dir) 21 22libbrillo_cpp_extension := .cc 23libbrillo_core_sources := \ 24 brillo/backoff_entry.cc \ 25 brillo/data_encoding.cc \ 26 brillo/errors/error.cc \ 27 brillo/errors/error_codes.cc \ 28 brillo/flag_helper.cc \ 29 brillo/key_value_store.cc \ 30 brillo/message_loops/base_message_loop.cc \ 31 brillo/message_loops/message_loop.cc \ 32 brillo/message_loops/message_loop_utils.cc \ 33 brillo/mime_utils.cc \ 34 brillo/osrelease_reader.cc \ 35 brillo/process.cc \ 36 brillo/process_information.cc \ 37 brillo/secure_blob.cc \ 38 brillo/strings/string_utils.cc \ 39 brillo/syslog_logging.cc \ 40 brillo/type_name_undecorate.cc \ 41 brillo/url_utils.cc \ 42 brillo/userdb_utils.cc \ 43 brillo/value_conversion.cc \ 44 45libbrillo_linux_sources := \ 46 brillo/asynchronous_signal_handler.cc \ 47 brillo/daemons/daemon.cc \ 48 brillo/file_utils.cc \ 49 brillo/process_reaper.cc \ 50 51libbrillo_binder_sources := \ 52 brillo/binder_watcher.cc \ 53 54libbrillo_dbus_sources := \ 55 brillo/any.cc \ 56 brillo/daemons/dbus_daemon.cc \ 57 brillo/dbus/async_event_sequencer.cc \ 58 brillo/dbus/data_serialization.cc \ 59 brillo/dbus/dbus_connection.cc \ 60 brillo/dbus/dbus_method_invoker.cc \ 61 brillo/dbus/dbus_method_response.cc \ 62 brillo/dbus/dbus_object.cc \ 63 brillo/dbus/dbus_service_watcher.cc \ 64 brillo/dbus/dbus_signal.cc \ 65 brillo/dbus/exported_object_manager.cc \ 66 brillo/dbus/exported_property_set.cc \ 67 brillo/dbus/utils.cc \ 68 69libbrillo_http_sources := \ 70 brillo/http/curl_api.cc \ 71 brillo/http/http_connection_curl.cc \ 72 brillo/http/http_form_data.cc \ 73 brillo/http/http_request.cc \ 74 brillo/http/http_transport.cc \ 75 brillo/http/http_transport_curl.cc \ 76 brillo/http/http_utils.cc \ 77 78libbrillo_policy_sources := \ 79 policy/device_policy.cc \ 80 policy/libpolicy.cc \ 81 82libbrillo_stream_sources := \ 83 brillo/streams/file_stream.cc \ 84 brillo/streams/input_stream_set.cc \ 85 brillo/streams/memory_containers.cc \ 86 brillo/streams/memory_stream.cc \ 87 brillo/streams/openssl_stream_bio.cc \ 88 brillo/streams/stream.cc \ 89 brillo/streams/stream_errors.cc \ 90 brillo/streams/stream_utils.cc \ 91 brillo/streams/tls_stream.cc \ 92 93libbrillo_test_helpers_sources := \ 94 brillo/http/http_connection_fake.cc \ 95 brillo/http/http_transport_fake.cc \ 96 brillo/message_loops/fake_message_loop.cc \ 97 brillo/streams/fake_stream.cc \ 98 99libbrillo_test_sources := \ 100 brillo/asynchronous_signal_handler_unittest.cc \ 101 brillo/backoff_entry_unittest.cc \ 102 brillo/data_encoding_unittest.cc \ 103 brillo/errors/error_codes_unittest.cc \ 104 brillo/errors/error_unittest.cc \ 105 brillo/file_utils_unittest.cc \ 106 brillo/flag_helper_unittest.cc \ 107 brillo/http/http_connection_curl_unittest.cc \ 108 brillo/http/http_form_data_unittest.cc \ 109 brillo/http/http_request_unittest.cc \ 110 brillo/http/http_transport_curl_unittest.cc \ 111 brillo/http/http_utils_unittest.cc \ 112 brillo/key_value_store_unittest.cc \ 113 brillo/map_utils_unittest.cc \ 114 brillo/message_loops/base_message_loop_unittest.cc \ 115 brillo/message_loops/fake_message_loop_unittest.cc \ 116 brillo/mime_utils_unittest.cc \ 117 brillo/osrelease_reader_unittest.cc \ 118 brillo/process_reaper_unittest.cc \ 119 brillo/process_unittest.cc \ 120 brillo/secure_blob_unittest.cc \ 121 brillo/streams/fake_stream_unittest.cc \ 122 brillo/streams/file_stream_unittest.cc \ 123 brillo/streams/input_stream_set_unittest.cc \ 124 brillo/streams/memory_containers_unittest.cc \ 125 brillo/streams/memory_stream_unittest.cc \ 126 brillo/streams/openssl_stream_bio_unittests.cc \ 127 brillo/streams/stream_unittest.cc \ 128 brillo/streams/stream_utils_unittest.cc \ 129 brillo/strings/string_utils_unittest.cc \ 130 brillo/type_name_undecorate_unittest.cc \ 131 brillo/unittest_utils.cc \ 132 brillo/url_utils_unittest.cc \ 133 brillo/value_conversion_unittest.cc \ 134 135libbrillo_dbus_test_sources := \ 136 brillo/any_unittest.cc \ 137 brillo/any_internal_impl_unittest.cc \ 138 brillo/dbus/async_event_sequencer_unittest.cc \ 139 brillo/dbus/data_serialization_unittest.cc \ 140 brillo/dbus/dbus_method_invoker_unittest.cc \ 141 brillo/dbus/dbus_object_unittest.cc \ 142 brillo/dbus/dbus_param_reader_unittest.cc \ 143 brillo/dbus/dbus_param_writer_unittest.cc \ 144 brillo/dbus/dbus_signal_handler_unittest.cc \ 145 brillo/dbus/exported_object_manager_unittest.cc \ 146 brillo/dbus/exported_property_set_unittest.cc \ 147 brillo/dbus/test.proto \ 148 brillo/variant_dictionary_unittest.cc \ 149 150libbrillo_CFLAGS := \ 151 -Wall \ 152 -Werror \ 153 -DUSE_DBUS=$(local_use_dbus) 154libbrillo_CPPFLAGS := 155libbrillo_includes := external/gtest/include 156libbrillo_shared_libraries := libchrome 157 158# Shared library for target 159# ======================================================== 160include $(CLEAR_VARS) 161LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 162LOCAL_MODULE := libbrillo 163LOCAL_SRC_FILES := $(libbrillo_core_sources) $(libbrillo_linux_sources) 164LOCAL_C_INCLUDES := $(libbrillo_includes) 165LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) 166LOCAL_STATIC_LIBRARIES := libmodpb64 167LOCAL_CFLAGS := $(libbrillo_CFLAGS) 168LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) 169LOCAL_CLANG := true 170LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 171include $(BUILD_SHARED_LIBRARY) 172 173# Shared binder library for target 174# ======================================================== 175include $(CLEAR_VARS) 176LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 177LOCAL_MODULE := libbrillo-binder 178LOCAL_SRC_FILES := $(libbrillo_binder_sources) 179LOCAL_C_INCLUDES := $(libbrillo_includes) 180LOCAL_SHARED_LIBRARIES := \ 181 $(libbrillo_shared_libraries) \ 182 libbinder \ 183 libbrillo \ 184 libutils 185LOCAL_CFLAGS := $(libbrillo_CFLAGS) 186LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) 187LOCAL_CLANG := true 188LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 189include $(BUILD_SHARED_LIBRARY) 190 191ifeq ($(local_use_dbus),1) 192 193# Shared dbus library for target 194# ======================================================== 195include $(CLEAR_VARS) 196LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 197LOCAL_MODULE := libbrillo-dbus 198LOCAL_SRC_FILES := $(libbrillo_dbus_sources) 199LOCAL_C_INCLUDES := $(libbrillo_includes) 200LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo \ 201 libchrome-dbus libdbus 202LOCAL_CFLAGS := $(libbrillo_CFLAGS) 203LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) 204LOCAL_CLANG := true 205LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) external/dbus 206include $(BUILD_SHARED_LIBRARY) 207 208endif # local_use_dbus == 1 209 210# Shared minijail library for target 211# ======================================================== 212include $(CLEAR_VARS) 213LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 214LOCAL_MODULE := libbrillo-minijail 215LOCAL_SRC_FILES := brillo/minijail/minijail.cc \ 216 217LOCAL_C_INCLUDES := $(libbrillo_includes) 218LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo \ 219 libminijail 220LOCAL_CFLAGS := $(libbrillo_CFLAGS) 221LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) 222LOCAL_CLANG := true 223LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 224include $(BUILD_SHARED_LIBRARY) 225 226# Shared stream library for target 227# ======================================================== 228include $(CLEAR_VARS) 229LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 230LOCAL_MODULE := libbrillo-stream 231LOCAL_SRC_FILES := $(libbrillo_stream_sources) 232LOCAL_C_INCLUDES := $(libbrillo_includes) 233LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo \ 234 libcrypto libssl 235LOCAL_CFLAGS := $(libbrillo_CFLAGS) 236LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) 237LOCAL_CLANG := true 238LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 239include $(BUILD_SHARED_LIBRARY) 240 241# Shared http library for target 242# ======================================================== 243include $(CLEAR_VARS) 244LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 245LOCAL_MODULE := libbrillo-http 246LOCAL_SRC_FILES := $(libbrillo_http_sources) 247LOCAL_C_INCLUDES := $(libbrillo_includes) 248LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo \ 249 libbrillo-stream libcurl 250LOCAL_CFLAGS := $(libbrillo_CFLAGS) 251LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) 252LOCAL_CLANG := true 253LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 254include $(BUILD_SHARED_LIBRARY) 255 256# Shared policy library for target 257# ======================================================== 258include $(CLEAR_VARS) 259LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 260LOCAL_MODULE := libbrillo-policy 261LOCAL_SRC_FILES := $(libbrillo_policy_sources) 262LOCAL_C_INCLUDES := $(libbrillo_includes) 263LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) 264LOCAL_CFLAGS := $(libbrillo_CFLAGS) 265LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) 266LOCAL_CLANG := true 267LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 268include $(BUILD_SHARED_LIBRARY) 269 270# Static library for target 271# ======================================================== 272include $(CLEAR_VARS) 273LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 274LOCAL_MODULE := libbrillo 275LOCAL_SRC_FILES := $(libbrillo_core_sources) $(libbrillo_linux_sources) 276LOCAL_C_INCLUDES := $(libbrillo_includes) 277LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) 278LOCAL_STATIC_LIBRARIES := libmodpb64 279LOCAL_CFLAGS := $(libbrillo_CFLAGS) 280LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) 281LOCAL_CLANG := true 282LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 283include $(BUILD_STATIC_LIBRARY) 284 285# Static test-helpers library for target 286# ======================================================== 287include $(CLEAR_VARS) 288LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 289LOCAL_MODULE := libbrillo-test-helpers 290LOCAL_SRC_FILES := $(libbrillo_test_helpers_sources) 291LOCAL_C_INCLUDES := $(libbrillo_includes) 292LOCAL_STATIC_LIBRARIES := libgtest libgmock 293LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo libcurl \ 294 libbrillo-http libbrillo-stream libcrypto 295LOCAL_CFLAGS := $(libbrillo_CFLAGS) 296LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) -Wno-sign-compare 297LOCAL_CLANG := true 298LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 299include $(BUILD_STATIC_LIBRARY) 300 301# Shared library for host 302# ======================================================== 303include $(CLEAR_VARS) 304LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 305LOCAL_MODULE := libbrillo 306LOCAL_SRC_FILES := $(libbrillo_core_sources) 307LOCAL_C_INCLUDES := $(libbrillo_includes) 308LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) 309LOCAL_STATIC_LIBRARIES := libmodpb64-host 310LOCAL_CFLAGS := $(libbrillo_CFLAGS) 311LOCAL_CPPFLAGS := \ 312 -D__ANDROID_HOST__ \ 313 $(libbrillo_CPPFLAGS) 314LOCAL_CLANG := true 315LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 316include $(BUILD_HOST_SHARED_LIBRARY) 317 318ifeq ($(HOST_OS),linux) 319 320# Shared stream library for host 321# ======================================================== 322include $(CLEAR_VARS) 323LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 324LOCAL_MODULE := libbrillo-stream 325LOCAL_SRC_FILES := $(libbrillo_stream_sources) 326LOCAL_C_INCLUDES := $(libbrillo_includes) 327LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo \ 328 libcrypto-host libssl-host 329LOCAL_CFLAGS := $(libbrillo_CFLAGS) 330LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) 331LOCAL_CLANG := true 332LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 333include $(BUILD_HOST_SHARED_LIBRARY) 334 335# Shared http library for host 336# ======================================================== 337include $(CLEAR_VARS) 338LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 339LOCAL_MODULE := libbrillo-http 340LOCAL_SRC_FILES := $(libbrillo_http_sources) 341LOCAL_C_INCLUDES := $(libbrillo_includes) 342LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo \ 343 libbrillo-stream libcurl-host 344LOCAL_CFLAGS := $(libbrillo_CFLAGS) 345LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) 346LOCAL_CLANG := true 347LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 348include $(BUILD_HOST_SHARED_LIBRARY) 349 350endif # HOST_OS == linux 351 352# Unit tests. 353# ======================================================== 354include $(CLEAR_VARS) 355LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 356LOCAL_MODULE := libbrillo_test 357LOCAL_MODULE_CLASS := EXECUTABLES 358ifdef BRILLO 359 LOCAL_MODULE_TAGS := eng 360endif 361generated_sources_dir := $(call local-generated-sources-dir) 362LOCAL_SRC_FILES := $(libbrillo_test_sources) 363LOCAL_C_INCLUDES := \ 364 $(libbrillo_includes) \ 365 $(generated_sources_dir)/proto/external/libbrillo 366LOCAL_STATIC_LIBRARIES := libgtest libchrome_test_helpers \ 367 libbrillo-test-helpers libgmock libBionicGtestMain 368LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo libcurl \ 369 libbrillo-http libbrillo-stream libcrypto libprotobuf-cpp-lite 370ifeq ($(local_use_dbus),1) 371LOCAL_SRC_FILES += $(libbrillo_dbus_test_sources) 372LOCAL_STATIC_LIBRARIES += libchrome_dbus_test_helpers 373LOCAL_SHARED_LIBRARIES += libbrillo-dbus libchrome-dbus libdbus 374endif # local_use_dbus == 1 375LOCAL_CFLAGS := $(libbrillo_CFLAGS) 376LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) -Wno-sign-compare 377LOCAL_CLANG := true 378include $(BUILD_NATIVE_TEST) 379 380# Run unit tests on target 381# ======================================================== 382# We su shell because process tests try setting "illegal" 383# uid/gids and expecting failures, but root can legally 384# set those to any value. 385runtargettests: libbrillo_test 386 adb sync 387 adb shell su shell /data/nativetest/libbrillo_test/libbrillo_test 388