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