blob: 3fd3371d6dc7185895e66c4862d68fe37e190e78 [file] [log] [blame]
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/util/process_version.gni")
import("//chromecast/chromecast.gni")
import("//testing/test.gni")
if (is_android) {
import("//build/config/android/rules.gni")
}
declare_args() {
# Denotes the type of Cast product. This is #defined as CAST_PRODUCT_TYPE in
# version.h. See //third_party/metrics_proto/cast_logs.proto for valid values.
if (is_android_arc) {
cast_product_type = 7 # CAST_PRODUCT_TYPE_CHROME_OS
} else if (is_android) {
if (is_android_things) {
cast_product_type = 6 # CAST_PRODUCT_TYPE_ANDROID_THINGS
} else {
cast_product_type = 4 # CAST_PRODUCT_TYPE_ANDROID_TV
}
} else {
cast_product_type = 0 # CAST_PRODUCT_TYPE_UNKNOWN
}
}
if (is_android_arc) {
assert(cast_product_type == 7)
} else if (is_android) {
assert(cast_product_type == 4 || cast_product_type == 6)
} else {
assert(cast_product_type >= 0 && cast_product_type <= 7 &&
cast_product_type != 4 && cast_product_type != 6 &&
cast_product_type != 7)
}
cast_source_set("base") {
sources = [
"alarm_manager.cc",
"alarm_manager.h",
"android/dumpstate_writer.cc",
"android/dumpstate_writer.h",
"android/system_time_change_notifier_android.cc",
"android/system_time_change_notifier_android.h",
"bind_to_task_runner.h",
"bitstream_audio_codecs.cc",
"bitstream_audio_codecs.h",
"cast_constants.cc",
"cast_constants.h",
"cast_features.cc",
"cast_features.h",
"cast_paths.cc",
"cast_paths.h",
"cast_resource.cc",
"cast_resource.h",
"device_capabilities.h",
"device_capabilities_impl.cc",
"device_capabilities_impl.h",
"error_codes.cc",
"error_codes.h",
"observer.h",
"path_utils.cc",
"path_utils.h",
"pref_names.cc",
"pref_names.h",
"process_utils.cc",
"process_utils.h",
"serializers.cc",
"serializers.h",
"statistics/weighted_mean.cc",
"statistics/weighted_mean.h",
"statistics/weighted_moving_average.cc",
"statistics/weighted_moving_average.h",
"statistics/weighted_moving_linear_regression.cc",
"statistics/weighted_moving_linear_regression.h",
"system_time_change_notifier.cc",
"system_time_change_notifier.h",
"task_runner_impl.cc",
"task_runner_impl.h",
]
public_deps = [
":chromecast_switches",
":init_shlib",
"//chromecast/base/metrics",
"//chromecast/public",
]
deps = [
"//base",
"//chromecast:chromecast_buildflags",
]
if (is_android) {
deps += [ ":jni_headers" ]
}
if (chromecast_branding == "public") {
sources += [ "cast_features_internal.cc" ]
} else {
deps += [ "//chromecast/internal/base:cast_internal_features" ]
}
if (is_android) {
sources += [ "chromecast_config_android.h" ]
if (chromecast_branding == "public") {
sources += [ "chromecast_config_android_dummy.cc" ]
} else {
sources +=
[ "//chromecast/internal/base/chromecast_config_android_internal.cc" ]
deps +=
[ "//chromecast/internal/base:chromecast_config_android_jni_headers" ]
}
}
}
# chromecast related switch values
# b/30398176 components that depend on switch values should depend on
# this target directly instead of depend on //chromecast/base to avoid
# unnecessary size increase.
cast_source_set("chromecast_switches") {
sources = [
"chromecast_switches.cc",
"chromecast_switches.h",
]
deps = [
"//base",
]
}
# command line initialization code for shared libs
# b/30398176 shared libs that depend on InitCommandLineShlib() only should
# use this target instead of //chromecast/base
cast_source_set("init_shlib") {
sources = [
"init_command_line_shlib.cc",
"init_command_line_shlib.h",
]
deps = [
"//base",
"//chromecast:chromecast_buildflags",
]
}
cast_source_set("test_support") {
sources = [
"scoped_temp_file.cc",
"scoped_temp_file.h",
]
public_deps = [
":base",
"//base",
]
}
test("cast_base_unittests") {
sources = [
"alarm_manager_unittest.cc",
"bind_to_task_runner_unittest.cc",
"cast_features_unittest.cc",
"device_capabilities_impl_unittest.cc",
"error_codes_unittest.cc",
"metrics/cast_metrics_helper_unittest.cc",
"observer_unittest.cc",
"path_utils_unittest.cc",
"process_utils_unittest.cc",
"serializers_unittest.cc",
"statistics/weighted_moving_average_unittest.cc",
"statistics/weighted_moving_linear_regression_unittest.cc",
"system_time_change_notifier_unittest.cc",
"thread_health_checker_unittest.cc",
]
deps = [
":test_support",
":thread_health_checker",
"//base/test:run_all_unittests",
"//base/test:test_support",
"//testing/gmock",
"//testing/gtest",
]
}
if (build_for_android_things_n) {
config("absence-no-function-error") {
# for n build doesn't use all functions
cflags = [ "-Wno-unused-function" ]
}
}
# Declares CreateSysInfo() without defining the implementation (see below).
cast_source_set("cast_sys_info_util") {
public = [
"cast_sys_info_util.h",
]
}
# Defines a CastSysInfoDummy suitable for use in tests, and public builds.
cast_source_set("dummy_cast_sys_info") {
sources = [
"cast_sys_info_dummy.cc",
"cast_sys_info_dummy.h",
]
deps = [
"//base",
"//chromecast/public",
]
}
# Links a CreateSysInfo() implementation that returns CastSysInfoDummy.
cast_source_set("dummy_create_sys_info") {
sources = [
"cast_sys_info_util_simple.cc",
]
deps = [
":dummy_cast_sys_info",
]
public_deps = [
":cast_sys_info_util",
]
}
# Links the default CreateSysInfo() implementation for Android.
if (is_android) {
cast_source_set("android_create_sys_info") {
deps = [
":cast_version",
"//base",
"//chromecast:chromecast_buildflags",
"//chromecast/browser:jni_headers",
"//chromecast/public",
]
public_deps = [
":cast_sys_info_util",
]
sources = [
"cast_sys_info_android.cc",
"cast_sys_info_android.h",
"cast_sys_info_android_factory.cc",
]
if (is_android_things) {
sources += [
"cast_sys_info_android_things.cc",
"cast_sys_info_android_things.h",
]
if (build_for_android_things_n) {
configs += [ ":absence-no-function-error" ]
}
}
}
} else { # !is_android
# Target for OEM partners to override sys_info shared library, i.e.
# libcast_sys_info_1.0.so.
cast_shared_library("libcast_sys_info_1.0") {
sources = [
"cast_sys_info_shlib.cc",
]
deps = [
":cast_sys_info_util",
":dummy_cast_sys_info",
"//chromecast/public",
]
}
# Links a CreateSysInfo() that loads libcast_sys_info_1.0.so.
cast_source_set("shlib_create_sys_info") {
sources = [
"cast_sys_info_util_shlib.cc",
]
deps = [
":libcast_sys_info_1.0",
"//base",
"//chromecast/public",
]
public_deps = [
":cast_sys_info_util",
]
}
} # is_android
# Links the default CreateSysInfo() for this build configuration.
group("default_create_sys_info") {
if (is_android) {
public_deps = [
":android_create_sys_info",
]
} else if (chromecast_branding == "public" || is_fuchsia) {
public_deps = [
":dummy_create_sys_info",
]
} else {
public_deps = [
":shlib_create_sys_info",
]
}
}
# TODO(b/130731732): Remove these targets once dependents are all migrated.
group("cast_sys_info") {
public_deps = [
":default_create_sys_info",
":dummy_cast_sys_info",
]
}
group("cast_sys_info_shlib") {
if (!is_android) {
deps = [
":shlib_create_sys_info",
]
public_deps = [
":dummy_cast_sys_info",
]
}
}
cast_source_set("thread_health_checker") {
sources = [
"thread_health_checker.cc",
"thread_health_checker.h",
]
deps = [
":base",
"//base",
]
}
process_version("cast_version") {
template_file = "version.h.in"
output = "$target_gen_dir/version.h"
sources = [
"//chrome/VERSION",
]
extra_args = [
"-e",
"VERSION_FULL=\"%s.%s.%s.%s\"%(MAJOR,MINOR,BUILD,PATCH)",
"-e",
"CAST_BUILD_RELEASE=\"$cast_build_release\"",
"-e",
"CAST_BUILD_INCREMENTAL=\"$cast_build_incremental\"",
"-e",
"CAST_PRODUCT_TYPE=$cast_product_type",
]
if (cast_is_debug) {
extra_args += [
"-e",
"CAST_IS_DEBUG_BUILD=1",
]
} else {
extra_args += [
"-e",
"CAST_IS_DEBUG_BUILD=0",
]
}
}
if (is_android) {
generate_jni("jni_headers") {
sources = [
"java/src/org/chromium/chromecast/base/DumpstateWriter.java",
"java/src/org/chromium/chromecast/base/SystemTimeChangeNotifierAndroid.java",
]
jni_package = "chromecast"
}
android_library("base_java") {
java_src_dir = "//chromecast/base/java/src"
java_files = [
"$java_src_dir/org/chromium/chromecast/base/BiConsumer.java",
"$java_src_dir/org/chromium/chromecast/base/BiFunction.java",
"$java_src_dir/org/chromium/chromecast/base/BiPredicate.java",
"$java_src_dir/org/chromium/chromecast/base/Both.java",
"$java_src_dir/org/chromium/chromecast/base/Controller.java",
"$java_src_dir/org/chromium/chromecast/base/Consumer.java",
"$java_src_dir/org/chromium/chromecast/base/Function.java",
"$java_src_dir/org/chromium/chromecast/base/Itertools.java",
"$java_src_dir/org/chromium/chromecast/base/Observable.java",
"$java_src_dir/org/chromium/chromecast/base/Observer.java",
"$java_src_dir/org/chromium/chromecast/base/Observers.java",
"$java_src_dir/org/chromium/chromecast/base/Scope.java",
"$java_src_dir/org/chromium/chromecast/base/Scopes.java",
"$java_src_dir/org/chromium/chromecast/base/Predicate.java",
"$java_src_dir/org/chromium/chromecast/base/Subscription.java",
"$java_src_dir/org/chromium/chromecast/base/Sequencer.java",
"$java_src_dir/org/chromium/chromecast/base/Supplier.java",
"$java_src_dir/org/chromium/chromecast/base/Unit.java",
# TODO(sanfin): Move these files to another target.
"$java_src_dir/org/chromium/chromecast/base/CastSettingsManager.java",
"$java_src_dir/org/chromium/chromecast/base/CastSwitches.java",
"$java_src_dir/org/chromium/chromecast/base/DumpstateWriter.java",
"$java_src_dir/org/chromium/chromecast/base/SystemTimeChangeNotifierAndroid.java",
]
deps = [
"//base:base_java",
]
}
android_library("cast_base_test_utils_java") {
java_test_dir = "//chromecast/base/java/test"
testonly = true
java_files = [
"$java_test_dir/org/chromium/chromecast/base/Inheritance.java",
"$java_test_dir/org/chromium/chromecast/base/ReactiveRecorder.java",
]
deps = [
":base_java",
"//third_party/hamcrest:hamcrest_java",
"//third_party/junit",
]
}
junit_binary("cast_base_junit_tests") {
java_test_dir = "//chromecast/base/java/test"
java_files = [
"$java_test_dir/org/chromium/chromecast/base/BothTest.java",
"$java_test_dir/org/chromium/chromecast/base/ControllerTest.java",
"$java_test_dir/org/chromium/chromecast/base/ItertoolsTest.java",
"$java_test_dir/org/chromium/chromecast/base/ObservableAndTest.java",
"$java_test_dir/org/chromium/chromecast/base/ObservableAndThenTest.java",
"$java_test_dir/org/chromium/chromecast/base/ObservableFilterTest.java",
"$java_test_dir/org/chromium/chromecast/base/ObservableMapTest.java",
"$java_test_dir/org/chromium/chromecast/base/ObservableMiscellaneousTest.java",
"$java_test_dir/org/chromium/chromecast/base/ObservableNotTest.java",
"$java_test_dir/org/chromium/chromecast/base/ReactiveRecorderTest.java",
"$java_test_dir/org/chromium/chromecast/base/ObserversTest.java",
"$java_test_dir/org/chromium/chromecast/base/SequencerTest.java",
"$java_test_dir/org/chromium/chromecast/base/UnitTest.java",
]
deps = [
":base_java",
":cast_base_test_utils_java",
"//third_party/hamcrest:hamcrest_java",
]
}
}