| # Copyright 2023 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/deps.gni") |
| import("//common-mk/pkg_config.gni") |
| import("//common-mk/proto_library.gni") |
| |
| group("all") { |
| deps = [ |
| ":feature-protos", |
| ":feature_check", |
| ":install_libsegmentation_headers", |
| ":install_tmpfiles_config", |
| ":internal_protos", |
| ":libsegmentation", |
| ":libsegmentation-test", |
| ":libsegmentation-test_pc", |
| ":libsegmentation_pc", |
| ":libsegmentation_static", |
| ] |
| if (use.test) { |
| deps += [ ":libsegmentation_tests" ] |
| } |
| } |
| |
| default_pkg_deps = [ |
| "libbrillo", |
| "libchrome", |
| "libcrossystem", |
| "protobuf", |
| ] |
| pkg_config("target_defaults_pkg_deps") { |
| pkg_deps = default_pkg_deps |
| libs = [ "rootdev" ] |
| } |
| |
| config("target_defaults") { |
| configs = [ ":target_defaults_pkg_deps" ] |
| defines = [ "USE_FEATURE_MANAGEMENT=${use.feature_management}" ] |
| } |
| |
| proto_library("internal_protos") { |
| proto_in_dir = "./protos/" |
| proto_out_dir = "include/libsegmentation" |
| sources = [ "${proto_in_dir}/device_info.proto" ] |
| standalone = true |
| |
| # Use -fPIC so this code can be linked into a shared library. |
| use_pic = true |
| } |
| |
| # Feature configs protos. |
| proto_library("feature-protos") { |
| proto_in_dir = "${sysroot}/build/share/libsegmentation/proto/" |
| proto_out_dir = "include/proto" |
| sources = [ |
| "${proto_in_dir}/device_selection.proto", |
| "${proto_in_dir}/feature_management.proto", |
| "${proto_in_dir}/hwid_feature_requirement.proto", |
| ] |
| |
| # Use -fPIC so this code can be linked into a shared library. |
| use_pic = true |
| } |
| |
| source_set("libsegmentation_sources") { |
| sources = [ |
| "feature_management.cc", |
| "feature_management_impl.cc", |
| ] |
| deps = [ ":feature-protos" ] |
| if (use.feature_management) { |
| sources += [ |
| "feature_management_backend.cc", |
| "feature_management_hwid.cc", |
| "feature_management_util.cc", |
| ] |
| deps += [ ":internal_protos" ] |
| } |
| configs += [ |
| ":target_defaults", |
| "//common-mk:pic", |
| ] |
| include_dirs = [ |
| "./protos/", |
| "${sysroot}/usr/include/chromeos/feature-management-data", |
| ] |
| } |
| |
| static_library("libsegmentation_static") { |
| deps = [ ":libsegmentation_sources" ] |
| } |
| |
| shared_library("libsegmentation") { |
| deps = [ ":libsegmentation_sources" ] |
| install_path = "lib" |
| } |
| |
| install_config("install_libsegmentation_headers") { |
| sources = [ |
| "feature_management.h", |
| "feature_management_interface.h", |
| ] |
| install_path = "/usr/include/libsegmentation" |
| } |
| |
| generate_pkg_config("libsegmentation-test_pc") { |
| name = "libsegmentation-test" |
| output_name = "libsegmentation-test" |
| description = "libsegmentation test library" |
| version = "0.1" |
| |
| requires = [] |
| requires_private = [ "libsegmentation" ] + default_pkg_deps |
| libs = [ "-lsegmentation-test" ] |
| install = true |
| } |
| |
| shared_library("libsegmentation-test") { |
| sources = [ "feature_management_fake.cc" ] |
| configs += [ ":target_defaults" ] |
| deps = [ ":libsegmentation-test_pc" ] |
| install_path = "lib" |
| } |
| |
| generate_pkg_config("libsegmentation_pc") { |
| name = "libsegmentation" |
| output_name = "libsegmentation" |
| description = "Library to get Chromium OS system properties" |
| version = "0.1" |
| |
| requires = [] |
| requires_private = default_pkg_deps |
| libs = [ "-lsegmentation" ] |
| install = true |
| } |
| |
| pkg_config("feature_check_pkg_deps") { |
| pkg_deps = [ |
| "libbrillo", |
| "libchrome", |
| ] |
| } |
| |
| executable("feature_check") { |
| sources = [ "feature_check.cc" ] |
| configs += [ ":feature_check_pkg_deps" ] |
| deps = [ ":libsegmentation" ] |
| install_path = "sbin" |
| } |
| |
| install_config("install_tmpfiles_config") { |
| sources = [ "tmpfiles.d/libsegmentation.conf" ] |
| install_path = "/usr/lib/tmpfiles.d" |
| } |
| |
| if (use.test) { |
| executable("libsegmentation_tests") { |
| sources = [ |
| "feature_management_impl_test.cc", |
| "feature_management_test.cc", |
| ] |
| if (use.feature_management) { |
| sources += [ |
| "feature_management_hwid_test.cc", |
| "feature_management_util_test.cc", |
| ] |
| } |
| configs += [ |
| "//common-mk:test", |
| ":target_defaults", |
| ] |
| run_test = true |
| pkg_deps = [ "libcrossystem-test" ] |
| deps = [ |
| ":libsegmentation-test", |
| ":libsegmentation_static", |
| "//common-mk/testrunner", |
| ] |
| } |
| } |