| # Copyright 2021 The ChromiumOS Authors |
| # 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-adaptors.gni") |
| import("//common-mk/pkg_config.gni") |
| import("//common-mk/proto_library.gni") |
| |
| group("all") { |
| deps = [ |
| ":featured", |
| ":libc_fake_feature_library", |
| ":libfake_platform_features", |
| ":libfake_platform_features_pkg_config", |
| ":libfeatures", |
| ":libfeatures_c", |
| ":libstore_impl", |
| ] |
| if (use.test) { |
| deps += [ |
| ":c_fake_feature_check_example", |
| ":c_feature_check_example", |
| ":cpp_feature_check_example", |
| ":feature_library_test", |
| ":service_test", |
| ":store_impl_test", |
| ] |
| } |
| if (use.fuzzer) { |
| deps += [ ":featured_json_feature_parser_fuzzer" ] |
| } |
| } |
| |
| pkg_config("target_defaults") { |
| # NOSORT |
| pkg_deps = [ |
| "dbus-1", |
| "libbrillo", |
| "libchrome", |
| "libsession_manager-client", |
| "openssl", |
| |
| # 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", |
| "protobuf", |
| ] |
| } |
| |
| generate_dbus_adaptors("featured-adaptors") { |
| dbus_service_config = "dbus_bindings/dbus-service-config.json" |
| dbus_adaptors_out_dir = "include/featured/dbus_adaptors" |
| sources = [ "dbus_bindings/org.chromium.featured.xml" ] |
| } |
| |
| static_library("libfeatured") { |
| sources = [ "service.cc" ] |
| configs += [ ":target_defaults" ] |
| deps = [ |
| ":featured-adaptors", |
| ":libfeatures", |
| ":libstore_impl", |
| ":libtmp_storage_impl", |
| ] |
| } |
| |
| executable("featured") { |
| sources = [ "main.cc" ] |
| configs += [ ":target_defaults" ] |
| deps = [ |
| ":featured-adaptors", |
| ":libfeatured", |
| ] |
| } |
| |
| action("early_boot_state_checks") { |
| visibility = [ ":libfeatures" ] |
| script = "scripts/generate_early_boot_checks.py" |
| json_path = |
| "${sysroot}/usr/include/chromeos/dbus/featured/default_states.json" |
| inputs = [ |
| json_path, |
| "scripts/early_boot_state_checks_cc.jinja", |
| "scripts/early_boot_state_checks_h.jinja", |
| ] |
| outputs = [ |
| "$target_gen_dir/early_boot_state_checks.cc", |
| "$target_gen_dir/early_boot_state_checks.h", |
| ] |
| args = [ |
| "--default_states=${json_path}", |
| "--fileroot_output=" + rebase_path(target_gen_dir, root_build_dir) + |
| "/early_boot_state_checks", |
| "--template_folder=" + rebase_path("scripts/", root_build_dir), |
| ] |
| configs = [ ":target_defaults" ] |
| } |
| |
| # Ensure everything that uses libfeatures has access to the generated file. |
| config("early_boot_state_checks_config") { |
| include_dirs = [ root_gen_dir ] |
| } |
| |
| shared_library("libfeatures") { |
| sources = [ "feature_library.cc" ] |
| sources += get_target_outputs(":early_boot_state_checks") |
| configs += [ ":target_defaults" ] |
| all_dependent_configs = [ ":early_boot_state_checks_config" ] |
| |
| # This is load-bearing! The generated include path requires this. |
| include_dirs = [ root_gen_dir ] |
| public_deps = [ ":early_boot_state_checks" ] |
| } |
| |
| shared_library("libfeatures_c") { |
| sources = [ "c_feature_library.cc" ] |
| configs += [ ":target_defaults" ] |
| deps = [ ":libfeatures" ] |
| } |
| |
| # TODO(b/242920490): Only build fake libraries if use.test is set. |
| |
| shared_library("libfake_platform_features") { |
| sources = [ "fake_platform_features.cc" ] |
| all_dependent_configs = [ ":early_boot_state_checks_config" ] |
| configs += [ ":target_defaults" ] |
| } |
| |
| generate_pkg_config("libfake_platform_features_pkg_config") { |
| name = "libfake_platform_features" |
| description = "Fake libfeatures for tests" |
| version = "0.0" |
| libs = [ "-lfake_platform_features" ] |
| install = true |
| } |
| |
| shared_library("libc_fake_feature_library") { |
| sources = [ "c_fake_feature_library.cc" ] |
| configs += [ ":target_defaults" ] |
| deps = [ ":libfake_platform_features" ] |
| } |
| |
| static_library("libstore_impl") { |
| sources = [ "store_impl.cc" ] |
| configs += [ ":target_defaults" ] |
| libs = [ "hwsec-foundation" ] |
| } |
| |
| static_library("libtmp_storage_impl") { |
| sources = [ "tmp_storage_impl.cc" ] |
| configs += [ ":target_defaults" ] |
| } |
| |
| if (use.test) { |
| pkg_config("test_helper_config") { |
| # NOSORT |
| pkg_deps = [ |
| "libbrillo", |
| "libbrillo-test", |
| "libchrome", |
| "libchrome-test", |
| |
| # 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", |
| "protobuf", |
| ] |
| } |
| |
| executable("feature_library_test") { |
| sources = [ "feature_library_test.cc" ] |
| configs += [ |
| "//common-mk:test", |
| ":test_helper_config", |
| ] |
| deps = [ |
| ":libfeatured", |
| ":libfeatures", |
| "//common-mk/testrunner:testrunner", |
| ] |
| } |
| |
| executable("service_test") { |
| sources = [ "service_test.cc" ] |
| configs += [ |
| "//common-mk:test", |
| ":test_helper_config", |
| ":target_defaults", |
| ] |
| deps = [ |
| ":libfeatured", |
| "//common-mk/testrunner:testrunner", |
| ] |
| } |
| |
| executable("store_impl_test") { |
| sources = [ "store_impl_test.cc" ] |
| configs += [ |
| "//common-mk:test", |
| ":test_helper_config", |
| ":target_defaults", |
| ] |
| libs = [ "hwsec-foundation" ] |
| deps = [ |
| ":libstore_impl", |
| "//common-mk/testrunner:testrunner", |
| ] |
| } |
| |
| executable("c_feature_check_example") { |
| sources = [ "c_feature_check_example.c" ] |
| configs += [ "//common-mk:test" ] |
| deps = [ ":libfeatures_c" ] |
| } |
| |
| executable("c_fake_feature_check_example") { |
| sources = [ "c_fake_feature_check_example.c" ] |
| configs += [ "//common-mk:test" ] |
| deps = [ |
| ":libc_fake_feature_library", |
| ":libfeatures_c", |
| ] |
| } |
| |
| executable("cpp_feature_check_example") { |
| sources = [ "cpp_feature_check_example.cc" ] |
| configs += [ |
| "//common-mk:test", |
| ":test_helper_config", |
| ] |
| deps = [ ":libfeatures" ] |
| } |
| } |
| |
| if (use.fuzzer) { |
| executable("featured_json_feature_parser_fuzzer") { |
| sources = [ "json_feature_parser_fuzzer.cc" ] |
| configs += [ |
| "//common-mk/common_fuzzer", |
| ":target_defaults", |
| ] |
| deps = [ ":libfeatured" ] |
| } |
| } |