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_STATIC_LIBRARIES := $(libbrillo_shared_libraries) libmodpb64 278LOCAL_EXPORT_STATIC_LIBRARY_HEADERS := $(LOCAL_STATIC_LIBRARIES) 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 stream library for target 286# ======================================================== 287include $(CLEAR_VARS) 288LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 289LOCAL_MODULE := libbrillo-stream 290LOCAL_SRC_FILES := $(libbrillo_stream_sources) 291LOCAL_C_INCLUDES := $(libbrillo_includes) 292LOCAL_STATIC_LIBRARIES := $(libbrillo_shared_libraries) libbrillo \ 293 libcrypto_static libssl_static 294LOCAL_EXPORT_STATIC_LIBRARY_HEADERS := $(LOCAL_STATIC_LIBRARIES) 295LOCAL_CFLAGS := $(libbrillo_CFLAGS) 296LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) 297LOCAL_CLANG := true 298LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 299include $(BUILD_STATIC_LIBRARY) 300 301# Static test-helpers library for target 302# ======================================================== 303include $(CLEAR_VARS) 304LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 305LOCAL_MODULE := libbrillo-test-helpers 306LOCAL_SRC_FILES := $(libbrillo_test_helpers_sources) 307LOCAL_C_INCLUDES := $(libbrillo_includes) 308LOCAL_STATIC_LIBRARIES := libgtest libgmock 309LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo libcurl \ 310 libbrillo-http libbrillo-stream libcrypto 311LOCAL_CFLAGS := $(libbrillo_CFLAGS) 312LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) -Wno-sign-compare 313LOCAL_CLANG := true 314LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 315include $(BUILD_STATIC_LIBRARY) 316 317# Shared library for host 318# ======================================================== 319include $(CLEAR_VARS) 320LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 321LOCAL_MODULE := libbrillo 322LOCAL_SRC_FILES := $(libbrillo_core_sources) 323LOCAL_C_INCLUDES := $(libbrillo_includes) 324LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) 325LOCAL_STATIC_LIBRARIES := libmodpb64-host 326LOCAL_CFLAGS := $(libbrillo_CFLAGS) 327LOCAL_CPPFLAGS := \ 328 -D__ANDROID_HOST__ \ 329 $(libbrillo_CPPFLAGS) 330LOCAL_CLANG := true 331LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 332include $(BUILD_HOST_SHARED_LIBRARY) 333 334ifeq ($(HOST_OS),linux) 335 336# Shared stream library for host 337# ======================================================== 338include $(CLEAR_VARS) 339LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 340LOCAL_MODULE := libbrillo-stream 341LOCAL_SRC_FILES := $(libbrillo_stream_sources) 342LOCAL_C_INCLUDES := $(libbrillo_includes) 343LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo \ 344 libcrypto-host libssl-host 345LOCAL_CFLAGS := $(libbrillo_CFLAGS) 346LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) 347LOCAL_CLANG := true 348LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 349include $(BUILD_HOST_SHARED_LIBRARY) 350 351# Shared http library for host 352# ======================================================== 353include $(CLEAR_VARS) 354LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 355LOCAL_MODULE := libbrillo-http 356LOCAL_SRC_FILES := $(libbrillo_http_sources) 357LOCAL_C_INCLUDES := $(libbrillo_includes) 358LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo \ 359 libbrillo-stream libcurl-host 360LOCAL_CFLAGS := $(libbrillo_CFLAGS) 361LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) 362LOCAL_CLANG := true 363LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 364include $(BUILD_HOST_SHARED_LIBRARY) 365 366endif # HOST_OS == linux 367 368# Unit tests. 369# ======================================================== 370include $(CLEAR_VARS) 371LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension) 372LOCAL_MODULE := libbrillo_test 373LOCAL_MODULE_CLASS := EXECUTABLES 374ifdef BRILLO 375 LOCAL_MODULE_TAGS := eng 376endif 377generated_sources_dir := $(call local-generated-sources-dir) 378LOCAL_SRC_FILES := $(libbrillo_test_sources) 379LOCAL_C_INCLUDES := \ 380 $(libbrillo_includes) \ 381 $(generated_sources_dir)/proto/external/libbrillo 382LOCAL_STATIC_LIBRARIES := libgtest libchrome_test_helpers \ 383 libbrillo-test-helpers libgmock libBionicGtestMain 384LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo libcurl \ 385 libbrillo-http libbrillo-stream libcrypto libprotobuf-cpp-lite 386ifeq ($(local_use_dbus),1) 387LOCAL_SRC_FILES += $(libbrillo_dbus_test_sources) 388LOCAL_STATIC_LIBRARIES += libchrome_dbus_test_helpers 389LOCAL_SHARED_LIBRARIES += libbrillo-dbus libchrome-dbus libdbus 390endif # local_use_dbus == 1 391LOCAL_CFLAGS := $(libbrillo_CFLAGS) 392LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) -Wno-sign-compare 393LOCAL_CLANG := true 394include $(BUILD_NATIVE_TEST) 395 396# Run unit tests on target 397# ======================================================== 398# We su shell because process tests try setting "illegal" 399# uid/gids and expecting failures, but root can legally 400# set those to any value. 401runtargettests: libbrillo_test 402 adb sync 403 adb shell su shell /data/nativetest/libbrillo_test/libbrillo_test 404