| # Copyright 2018 The Chromium OS 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("//common-mk/generate-dbus-proxies.gni") |
| import("//common-mk/pkg_config.gni") |
| |
| group("all") { |
| deps = [ |
| ":backlight_tool", |
| ":check_powerd_config", |
| ":cpufreq_config", |
| ":dump_power_status", |
| ":inject_powerd_input_event", |
| ":libpolicy", |
| ":libpolicy_stub", |
| ":libpowerd", |
| ":libsystem", |
| ":libsystem_stub", |
| ":libutil", |
| ":memory_suspend_test", |
| ":power_supply_info", |
| ":powerd", |
| ":powerd_dbus_suspend", |
| ":powerd_setuid_helper", |
| ":send_debug_power_status", |
| ":set_cellular_transmit_power", |
| ":set_power_policy", |
| ":set_wifi_transmit_power", |
| ":suspend_delay_sample", |
| ] |
| if (use.buffet) { |
| deps += [ ":buffet_command_handlers" ] |
| } |
| if (use.cellular) { |
| deps += [ ":generate_modemmanager_proxies" ] |
| } |
| if (use.test) { |
| deps += [ |
| ":libutil_test", |
| ":power_manager_daemon_test", |
| ":power_manager_policy_test", |
| ":power_manager_system_test", |
| ":power_manager_util_test", |
| ] |
| } |
| if (use.amd64) { |
| deps += [ ":dump_intel_rapl_consumption" ] |
| } |
| if (use.fuzzer) { |
| deps += [ |
| ":ambient_light_handler_fuzzer", |
| ":internal_backlight_controller_fuzzer", |
| ":powerd_als_fuzzer", |
| ] |
| } |
| |
| # TODO(b/188798246) Remove this once qc-netmgr is merged back into modemmanager |
| if (use.qrtr) { |
| deps += [ ":generate_upstart_proxies" ] |
| } |
| } |
| |
| # TODO(b/188798246) Remove this once qc-netmgr is merged back into modemmanager |
| if (use.qrtr) { |
| generate_dbus_proxies("generate_upstart_proxies") { |
| upstart_in_dir = "${sysroot}/usr/share/dbus-1/interfaces/" |
| proxy_output_file = "include/upstart/dbus-proxies.h" |
| sources = [ "${upstart_in_dir}/com.ubuntu.Upstart.xml" ] |
| } |
| } |
| |
| if (use.cellular) { |
| generate_dbus_proxies("generate_modemmanager_proxies") { |
| modemmanager_in_dir = "${sysroot}/usr/share/dbus-1/interfaces/" |
| proxy_output_file = "include/modemmanager/dbus-proxies.h" |
| sources = [ |
| "${modemmanager_in_dir}/org.freedesktop.ModemManager1.Modem.Sar.xml", |
| "${modemmanager_in_dir}/org.freedesktop.ModemManager1.Modem.xml", |
| "${modemmanager_in_dir}/org.freedesktop.ModemManager1.xml", |
| "dbus_bindings/dbus-objectmanager.dbus-xml", |
| ] |
| } |
| } |
| |
| pkg_config("target_defaults") { |
| defines = [ |
| "USE_BUFFET=${use.buffet}", |
| "USE_CELLULAR=${use.cellular}", |
| "USE_IIOSERVICE=${use.iioservice}", |
| "USE_QRTR=${use.qrtr}", |
| ] |
| |
| # NOSORT |
| pkg_deps = [ |
| "libbrillo", |
| "libchrome", |
| "libcros_config", |
| "libec", |
| "libmojo", |
| "libudev", |
| "re2", |
| |
| # system_api depends on protobuf (or protobuf-lite). It must appear |
| # before protobuf here or the linker flags won't be in the right |
| # order. |
| "system_api", |
| ] |
| if (use.fuzzer) { |
| pkg_deps += [ "protobuf" ] |
| } else { |
| pkg_deps += [ "protobuf-lite" ] |
| } |
| |
| # TODO(b/188798246) Remove this once qc-netmgr is merged back into modemmanager. |
| if (use.qrtr) { |
| pkg_deps += [ |
| "gio-2.0", |
| "gio-unix-2.0", |
| "glib-2.0", |
| "gthread-2.0", |
| ] |
| libs = [ "qrtr" ] |
| } |
| } |
| |
| pkg_config("libchrome_test_config") { |
| pkg_deps = [ "libchrome-test" ] |
| } |
| |
| pkg_config("libutil_dependent_config") { |
| pkg_deps = [ "libmetrics" ] |
| } |
| |
| static_library("libutil") { |
| sources = [ |
| "common/activity_logger.cc", |
| "common/battery_percentage_converter.cc", |
| "common/clock.cc", |
| "common/cros_config_prefs_source.cc", |
| "common/file_prefs_store.cc", |
| "common/metrics_constants.cc", |
| "common/metrics_sender.cc", |
| "common/power_constants.cc", |
| "common/prefs.cc", |
| "common/util.cc", |
| ] |
| configs += [ ":target_defaults" ] |
| all_dependent_configs = [ ":libutil_dependent_config" ] |
| } |
| |
| static_library("libsystem") { |
| sources = [ |
| "powerd/system/acpi_wakeup_helper.cc", |
| "powerd/system/ambient_light_sensor.cc", |
| "powerd/system/ambient_light_sensor_delegate.cc", |
| "powerd/system/ambient_light_sensor_delegate_file.cc", |
| "powerd/system/ambient_light_sensor_delegate_mojo.cc", |
| "powerd/system/ambient_light_sensor_info.cc", |
| "powerd/system/ambient_light_sensor_manager_file.cc", |
| "powerd/system/ambient_light_sensor_manager_mojo.cc", |
| "powerd/system/ambient_light_sensor_watcher.cc", |
| "powerd/system/arc_timer_manager.cc", |
| "powerd/system/async_file_reader.cc", |
| "powerd/system/audio_client.cc", |
| "powerd/system/bluez_battery_provider.cc", |
| "powerd/system/cros_ec_device_event.cc", |
| "powerd/system/cros_ec_helper.cc", |
| "powerd/system/dark_resume.cc", |
| "powerd/system/dbus_wrapper.cc", |
| "powerd/system/display/display_info.cc", |
| "powerd/system/display/display_power_setter.cc", |
| "powerd/system/display/display_watcher.cc", |
| "powerd/system/display/external_display.cc", |
| "powerd/system/event_device.cc", |
| "powerd/system/external_ambient_light_sensor_factory_file.cc", |
| "powerd/system/input_watcher.cc", |
| "powerd/system/internal_backlight.cc", |
| "powerd/system/lockfile_checker.cc", |
| "powerd/system/peripheral_battery_watcher.cc", |
| "powerd/system/pluggable_internal_backlight.cc", |
| "powerd/system/power_supply.cc", |
| "powerd/system/rolling_average.cc", |
| "powerd/system/smart_discharge_configurator.cc", |
| "powerd/system/suspend_configurator.cc", |
| "powerd/system/suspend_freezer.cc", |
| "powerd/system/tagged_device.cc", |
| "powerd/system/thermal/cooling_device.cc", |
| "powerd/system/thermal/device_thermal_state.cc", |
| "powerd/system/thermal/thermal_device.cc", |
| "powerd/system/thermal/thermal_device_factory.cc", |
| "powerd/system/udev.cc", |
| "powerd/system/user_proximity_watcher.cc", |
| "powerd/system/wake_on_dp_configurator.cc", |
| "powerd/system/wakeup_device.cc", |
| "powerd/system/wakeup_source_identifier.cc", |
| "powerd/system/wilco_charge_controller_helper.cc", |
| ] |
| configs += [ ":target_defaults" ] |
| libs = [ "rt" ] |
| deps = [ |
| "//iioservice/libiioservice_ipc:libiioservice_ipc", |
| "//iioservice/libiioservice_ipc:libiioservice_ipc_mojom", |
| ] |
| if (use.cellular) { |
| sources += [ "powerd/system/dbus_objectmanager_wrapper.cc" ] |
| deps += [ ":generate_modemmanager_proxies" ] |
| } |
| } |
| |
| pkg_config("libsystem_stub_dependent_config") { |
| pkg_deps = [ "dbus-1" ] |
| } |
| |
| static_library("libsystem_stub") { |
| sources = [ |
| "powerd/system/acpi_wakeup_helper_stub.cc", |
| "powerd/system/ambient_light_sensor_manager_stub.cc", |
| "powerd/system/ambient_light_sensor_stub.cc", |
| "powerd/system/ambient_light_sensor_watcher_stub.cc", |
| "powerd/system/audio_client_stub.cc", |
| "powerd/system/backlight_stub.cc", |
| "powerd/system/charge_controller_helper_stub.cc", |
| "powerd/system/cros_ec_helper_stub.cc", |
| "powerd/system/dark_resume_stub.cc", |
| "powerd/system/dbus_wrapper_stub.cc", |
| "powerd/system/display/display_power_setter_stub.cc", |
| "powerd/system/display/display_watcher_stub.cc", |
| "powerd/system/event_device_stub.cc", |
| "powerd/system/external_ambient_light_sensor_factory_stub.cc", |
| "powerd/system/input_watcher_stub.cc", |
| "powerd/system/lockfile_checker_stub.cc", |
| "powerd/system/power_supply_stub.cc", |
| "powerd/system/thermal/thermal_device_stub.cc", |
| "powerd/system/udev_stub.cc", |
| "powerd/system/user_proximity_watcher_stub.cc", |
| "powerd/system/wakeup_source_identifier_stub.cc", |
| ] |
| configs += [ ":target_defaults" ] |
| all_dependent_configs = [ ":libsystem_stub_dependent_config" ] |
| } |
| |
| static_library("libpolicy") { |
| sources = [ |
| "powerd/policy/ambient_light_handler.cc", |
| "powerd/policy/backlight_controller.cc", |
| "powerd/policy/cellular_controller.cc", |
| "powerd/policy/charge_controller.cc", |
| "powerd/policy/external_ambient_light_handler.cc", |
| "powerd/policy/external_backlight_controller.cc", |
| "powerd/policy/input_device_controller.cc", |
| "powerd/policy/input_event_handler.cc", |
| "powerd/policy/internal_backlight_controller.cc", |
| "powerd/policy/keyboard_backlight_controller.cc", |
| "powerd/policy/shutdown_from_suspend.cc", |
| "powerd/policy/smart_dim_requestor.cc", |
| "powerd/policy/state_controller.cc", |
| "powerd/policy/suspend_delay_controller.cc", |
| "powerd/policy/suspender.cc", |
| "powerd/policy/thermal_event_handler.cc", |
| "powerd/policy/user_proximity_handler.cc", |
| "powerd/policy/user_proximity_voting.cc", |
| "powerd/policy/wifi_controller.cc", |
| ] |
| configs += [ ":target_defaults" ] |
| libs = [ "m" ] |
| if (use.cellular) { |
| deps = [ ":generate_modemmanager_proxies" ] |
| } |
| if (use.qrtr) { |
| deps += [ ":generate_upstart_proxies" ] |
| } |
| } |
| |
| static_library("libpolicy_stub") { |
| sources = [ |
| "powerd/policy/backlight_controller_observer_stub.cc", |
| "powerd/policy/backlight_controller_stub.cc", |
| ] |
| configs += [ ":target_defaults" ] |
| } |
| |
| pkg_config("libpowerd_dependent_config") { |
| # NOSORT |
| pkg_deps = [ |
| "libmetrics", |
| "libtpm_manager-client", |
| |
| # system_api depends on protobuf. It must appear before protobuf here so the |
| # linker flags are in the right order. |
| "system_api", |
| "protobuf", |
| ] |
| } |
| |
| static_library("libpowerd") { |
| sources = [ |
| "powerd/daemon.cc", |
| "powerd/metrics_collector.cc", |
| ] |
| configs += [ ":target_defaults" ] |
| all_dependent_configs = [ ":libpowerd_dependent_config" ] |
| deps = [ |
| ":libpolicy", |
| ":libsystem", |
| ":libutil", |
| ] |
| |
| if (use.buffet) { |
| deps += [ ":buffet_command_handlers" ] |
| } |
| } |
| |
| executable("powerd") { |
| sources = [ "powerd/main.cc" ] |
| configs += [ ":target_defaults" ] |
| deps = [ ":libpowerd" ] |
| } |
| |
| executable("powerd_setuid_helper") { |
| sources = [ "powerd/powerd_setuid_helper.cc" ] |
| configs += [ ":target_defaults" ] |
| } |
| |
| executable("set_cellular_transmit_power") { |
| sources = [ "powerd/set_cellular_transmit_power.cc" ] |
| configs += [ ":target_defaults" ] |
| } |
| |
| pkg_config("set_wifi_transmit_power_config") { |
| pkg_deps = [ "libnl-genl-3.0" ] |
| } |
| |
| executable("set_wifi_transmit_power") { |
| sources = [ "powerd/set_wifi_transmit_power.cc" ] |
| configs += [ |
| ":set_wifi_transmit_power_config", |
| ":target_defaults", |
| ] |
| } |
| |
| executable("backlight_tool") { |
| sources = [ "tools/backlight_tool.cc" ] |
| configs += [ ":target_defaults" ] |
| deps = [ |
| ":libpolicy", |
| ":libsystem", |
| ":libsystem_stub", |
| ":libutil", |
| ] |
| } |
| |
| executable("check_powerd_config") { |
| sources = [ "tools/check_powerd_config.cc" ] |
| configs += [ ":target_defaults" ] |
| deps = [ ":libutil" ] |
| } |
| |
| executable("cpufreq_config") { |
| sources = [ "tools/cpufreq_config.cc" ] |
| configs += [ ":target_defaults" ] |
| deps = [ |
| ":libsystem", |
| ":libsystem_stub", |
| ":libutil", |
| ] |
| } |
| |
| executable("inject_powerd_input_event") { |
| sources = [ "tools/inject_powerd_input_event.cc" ] |
| configs += [ ":target_defaults" ] |
| } |
| |
| executable("memory_suspend_test") { |
| sources = [ "tools/memory_suspend_test.cc" ] |
| configs += [ ":target_defaults" ] |
| } |
| |
| executable("powerd_dbus_suspend") { |
| sources = [ "tools/powerd_dbus_suspend.cc" ] |
| configs += [ ":target_defaults" ] |
| deps = [ ":libutil" ] |
| } |
| |
| executable("power_supply_info") { |
| sources = [ "tools/power_supply_info.cc" ] |
| configs += [ ":target_defaults" ] |
| deps = [ |
| ":libsystem", |
| ":libsystem_stub", |
| ":libutil", |
| ] |
| } |
| |
| executable("dump_power_status") { |
| sources = [ "tools/dump_power_status.cc" ] |
| configs += [ ":target_defaults" ] |
| deps = [ |
| ":libsystem", |
| ":libsystem_stub", |
| ":libutil", |
| ] |
| } |
| |
| executable("send_debug_power_status") { |
| sources = [ "tools/send_debug_power_status.cc" ] |
| configs += [ ":target_defaults" ] |
| } |
| |
| executable("set_power_policy") { |
| sources = [ "tools/set_power_policy.cc" ] |
| configs += [ ":target_defaults" ] |
| } |
| |
| executable("suspend_delay_sample") { |
| sources = [ "tools/suspend_delay_sample.cc" ] |
| configs += [ ":target_defaults" ] |
| } |
| |
| if (use.buffet) { |
| generate_dbus_proxies("generate_buffet_proxies") { |
| dbus_service_config = "../buffet/dbus_bindings/dbus-service-config.json" |
| proxy_output_file = "include/buffet/dbus-proxies.h" |
| sources = [ "../buffet/dbus_bindings/org.chromium.Buffet.Command.xml" ] |
| } |
| static_library("buffet_command_handlers") { |
| sources = [ "powerd/buffet/command_handlers.cc" ] |
| configs += [ ":target_defaults" ] |
| deps = [ ":generate_buffet_proxies" ] |
| } |
| } |
| |
| if (use.fuzzer || use.test) { |
| static_library("libutil_test") { |
| sources = [ |
| "common/action_recorder.cc", |
| "common/battery_percentage_converter.cc", |
| "common/fake_prefs.cc", |
| "common/metrics_sender_stub.cc", |
| "common/test_main_loop_runner.cc", |
| ] |
| configs += [ ":target_defaults" ] |
| } |
| } |
| |
| if (use.test) { |
| executable("power_manager_util_test") { |
| sources = [ |
| "common/activity_logger_test.cc", |
| "common/battery_percentage_converter_test.cc", |
| "common/prefs_test.cc", |
| "common/testrunner.cc", |
| "common/util_test.cc", |
| ] |
| configs += [ |
| "//common-mk:test", |
| ":target_defaults", |
| ":libchrome_test_config", |
| ] |
| deps = [ |
| ":libutil", |
| ":libutil_test", |
| ] |
| } |
| |
| pkg_config("power_manager_system_test_config") { |
| # For base::MockTimer. |
| pkg_deps = [ "libchrome-test" ] |
| } |
| |
| executable("power_manager_system_test") { |
| sources = [ |
| "common/testrunner.cc", |
| "powerd/system/acpi_wakeup_helper_test.cc", |
| "powerd/system/ambient_light_sensor_delegate_file_test.cc", |
| "powerd/system/ambient_light_sensor_delegate_mojo_test.cc", |
| "powerd/system/ambient_light_sensor_delegate_test.cc", |
| "powerd/system/ambient_light_sensor_manager_file_test.cc", |
| "powerd/system/ambient_light_sensor_manager_mojo_test.cc", |
| "powerd/system/ambient_light_sensor_test.cc", |
| "powerd/system/ambient_light_sensor_watcher_test.cc", |
| "powerd/system/arc_timer_manager_test.cc", |
| "powerd/system/async_file_reader_test.cc", |
| "powerd/system/audio_client_test.cc", |
| "powerd/system/bluez_battery_provider_test.cc", |
| "powerd/system/cros_ec_ioctl_test.cc", |
| "powerd/system/display/display_watcher_test.cc", |
| "powerd/system/display/external_display_test.cc", |
| "powerd/system/fake_sensor_device.cc", |
| "powerd/system/fake_sensor_service.cc", |
| "powerd/system/input_watcher_test.cc", |
| "powerd/system/internal_backlight_test.cc", |
| "powerd/system/lockfile_checker_test.cc", |
| "powerd/system/peripheral_battery_watcher_test.cc", |
| "powerd/system/pluggable_internal_backlight_test.cc", |
| "powerd/system/power_supply_test.cc", |
| "powerd/system/rolling_average_test.cc", |
| "powerd/system/suspend_configurator_test.cc", |
| "powerd/system/suspend_freezer_test.cc", |
| "powerd/system/tagged_device_test.cc", |
| "powerd/system/thermal/cooling_device_test.cc", |
| "powerd/system/thermal/thermal_device_factory_test.cc", |
| "powerd/system/user_proximity_watcher_test.cc", |
| "powerd/system/wakeup_device_test.cc", |
| "powerd/system/wakeup_source_identifier_test.cc", |
| ] |
| configs += [ |
| "//common-mk:test", |
| ":power_manager_system_test_config", |
| ":target_defaults", |
| ":libchrome_test_config", |
| ] |
| deps = [ |
| ":libsystem", |
| ":libsystem_stub", |
| ":libutil", |
| ":libutil_test", |
| ] |
| } |
| |
| executable("power_manager_policy_test") { |
| sources = [ |
| "common/testrunner.cc", |
| "powerd/policy/ambient_light_handler_test.cc", |
| "powerd/policy/backlight_controller_test_util.cc", |
| "powerd/policy/cellular_controller_test.cc", |
| "powerd/policy/charge_controller_test.cc", |
| "powerd/policy/external_backlight_controller_test.cc", |
| "powerd/policy/input_device_controller_test.cc", |
| "powerd/policy/input_event_handler_test.cc", |
| "powerd/policy/internal_backlight_controller_test.cc", |
| "powerd/policy/keyboard_backlight_controller_test.cc", |
| "powerd/policy/shutdown_from_suspend_test.cc", |
| "powerd/policy/state_controller_test.cc", |
| "powerd/policy/suspend_delay_controller_test.cc", |
| "powerd/policy/suspender_test.cc", |
| "powerd/policy/thermal_event_handler_test.cc", |
| "powerd/policy/user_proximity_handler_test.cc", |
| "powerd/policy/user_proximity_voting_test.cc", |
| "powerd/policy/wifi_controller_test.cc", |
| ] |
| configs += [ |
| "//common-mk:test", |
| ":target_defaults", |
| ":libchrome_test_config", |
| ] |
| deps = [ |
| ":libpolicy", |
| ":libpolicy_stub", |
| ":libsystem", |
| ":libsystem_stub", |
| ":libutil", |
| ":libutil_test", |
| ] |
| } |
| |
| executable("power_manager_daemon_test") { |
| sources = [ |
| "common/testrunner.cc", |
| "powerd/daemon_test.cc", |
| "powerd/metrics_collector_test.cc", |
| ] |
| configs += [ |
| "//common-mk:test", |
| ":target_defaults", |
| ":libchrome_test_config", |
| ] |
| deps = [ |
| ":libpolicy", |
| ":libpolicy_stub", |
| ":libpowerd", |
| ":libsystem", |
| ":libsystem_stub", |
| ":libutil", |
| ":libutil_test", |
| ] |
| } |
| } |
| |
| if (use.amd64) { |
| executable("dump_intel_rapl_consumption") { |
| sources = [ "tools/dump_intel_rapl_consumption.cc" ] |
| configs += [ ":target_defaults" ] |
| deps = [ ":libutil" ] |
| } |
| } |
| |
| if (use.fuzzer) { |
| static_library("libpolicy_test") { |
| sources = [ "powerd/policy/ambient_light_pref_fuzz_util.cc" ] |
| configs += [ ":target_defaults" ] |
| } |
| executable("ambient_light_handler_fuzzer") { |
| sources = [ "powerd/policy/ambient_light_handler_fuzzer.cc" ] |
| configs += [ |
| "//common-mk/common_fuzzer", |
| ":target_defaults", |
| ] |
| deps = [ |
| ":libpolicy_test", |
| ":libpowerd", |
| ":libsystem_stub", |
| ] |
| } |
| executable("internal_backlight_controller_fuzzer") { |
| sources = [ "powerd/policy/internal_backlight_controller_fuzzer.cc" ] |
| configs += [ |
| "//common-mk/common_fuzzer", |
| ":target_defaults", |
| ] |
| deps = [ |
| ":libpolicy_test", |
| ":libpowerd", |
| ":libsystem_stub", |
| ":libutil_test", |
| ] |
| } |
| } |
| |
| # Fuzzer target. |
| if (use.fuzzer) { |
| pkg_config("fuzzer_config") { |
| pkg_deps = [ |
| "libbrillo-test", |
| "libchrome-test", |
| ] |
| } |
| executable("powerd_als_fuzzer") { |
| sources = [ "powerd/system/fuzzers/powerd_als_fuzzer.cc" ] |
| configs += [ |
| "//common-mk/common_fuzzer:common_fuzzer", |
| "//common-mk:test", |
| ":fuzzer_config", |
| ":target_defaults", |
| ] |
| deps = [ |
| ":libsystem", |
| ":libutil", |
| ] |
| } |
| } |