blob: 750c3ae035b1dc0dd5d77aa5403f1960882eb03f [file] [log] [blame] [edit]
# 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("//camera/build/cc_embed_data.gni")
import("//common-mk/install_seccomp_policy.gni")
import("//common-mk/mojom_bindings_generator.gni")
import("//common-mk/pkg_config.gni")
group("all") {
deps = [
":install_camera_hal_dispatcher_mojo",
":install_dbus_cros_camera_algo_conf",
":install_gen_include_iioservice_mojo",
":install_include_cros_camera",
":install_jpeg_accelerator_mojo",
":install_libcamera_connector_so",
":libcros_camera",
":libcros_camera_device_config",
":libcros_camera_device_config_pkg_config",
":libcros_camera_pkg_config",
]
if (use.cros_camera_algo) {
deps += [
":cros_camera_algo",
":install_cros_camera_algo_conf",
":install_cros_camera_algo_policy",
":install_minijail_algo_conf",
]
if (use.ipu6se || use.ipu6epadln || use.ipu6epmtl || use.qualcomm_camx) {
deps += [
":install_cros_camera_gpu_algo_conf",
":install_cros_camera_gpu_algo_policy",
":install_minijail_gpu_algo_conf",
]
}
}
if (use.test) {
deps += [
":camera_buffer_pool_test",
":camera_face_detection_test",
":camera_hal3_helpers_test",
":capture_result_sequencer_test",
":cbm_test",
":embed_file_toc_test",
":future_test",
":relative_fov_test",
":stream_manipulator_helper_test",
":stream_manipulator_manager_test",
# TODO(b/262337896): Change back to use
# //camera/features/zsl:zsl_helper_test and
# //camera/features:feature_profile_test after the issue is
# resolved.
":feature_profile_test",
":zsl_helper_test",
]
}
if (use.fuzzer) {
deps += [ ":camera_still_capture_processor_impl_fuzzer" ]
}
}
pkg_config("target_defaults") {
defines = [ "USE_LIBCAMERA=${use.libcamera}" ]
configs = [ "//camera/build:cros_camera_common" ]
pkg_deps = [
"libcros_camera_android_deps",
"libdrm",
]
}
generate_mojom_bindings("libcros_camera_mojom") {
install_path = "lib"
deps = [ "//iioservice/libiioservice_ipc:libiioservice_ipc_mojom" ]
sources = [
"//camera/mojo/algorithm/camera_algorithm.mojom",
"//camera/mojo/camera3.mojom",
"//camera/mojo/camera_common.mojom",
"//camera/mojo/camera_diagnostics.mojom",
"//camera/mojo/camera_features.mojom",
"//camera/mojo/camera_metadata.mojom",
"//camera/mojo/camera_metadata_tags.mojom",
"//camera/mojo/cros_camera_enum.mojom",
"//camera/mojo/cros_camera_service.mojom",
"//camera/mojo/effects/effects_pipeline.mojom",
"//camera/mojo/file_path.mojom",
"//camera/mojo/gpu/dmabuf.mojom",
"//camera/mojo/gpu/jpeg_accelerator.mojom",
"//camera/mojo/gpu/jpeg_encode_accelerator.mojom",
"//camera/mojo/gpu/mjpeg_decode_accelerator.mojom",
"//camera/mojo/unguessable_token.mojom",
]
mojo_root = "${platform2_root}"
use_pic = true
install_package = "cros-camera/mojo"
enabled_features = [ "file_path_is_string" ]
}
pkg_config("pkg_config_base") {
pkg_deps = [
"gbm",
"libbrillo",
"libcros_config",
"libexif",
"libsync",
"libudev",
"libyuv",
]
}
shared_library("libcros_camera_device_config") {
output_name = "libcros_camera_device_config"
sources = [ "//camera/common/device_config.cc" ]
configs += [
":target_defaults",
":pkg_config_base",
]
install_path = "lib"
}
generate_pkg_config("libcros_camera_device_config_pkg_config") {
name = "libcros_camera_device_config"
description = "cros-camera device config library"
version = getenv("PV")
requires_private = [ "libchrome" ]
libs = [ "-lcros_camera_device_config" ]
install = true
}
source_set("base") {
sources = [
"//camera/common/camera_buffer_manager_impl.cc",
"//camera/common/camera_buffer_pool.cc",
"//camera/common/camera_buffer_utils.cc",
"//camera/common/camera_hal3_helpers.cc",
"//camera/common/camera_metadata_inspector.cc",
"//camera/common/camera_metadata_string_utils.cc",
"//camera/common/embed_file_toc.cc",
"//camera/common/exif_utils.cc",
"//camera/common/future.cc",
"//camera/common/ipc_util.cc",
"//camera/common/metadata_logger.cc",
"//camera/common/relative_fov.cc",
"//camera/common/reloadable_config_file.cc",
"//camera/common/resizable_cpu_buffer.cc",
"//camera/common/timezone.cc",
"//camera/common/udev_watcher.cc",
"//camera/common/utils/camera_config_impl.cc",
"//camera/common/vendor_tag_manager.cc",
]
public_configs = [
":pkg_config_base",
":target_defaults",
]
pkg_deps = [ "re2" ]
deps = [
":tracing",
"//camera/hardware_buffer",
]
# -fPIC needed by the libcros_camera.so shared library.
configs += [ "//common-mk:pic" ]
}
source_set("tracing") {
sources = [ "//camera/common/tracing.cc" ]
public_configs = [ ":target_defaults" ]
# -fPIC needed by the libcros_camera.so shared library.
configs += [ "//common-mk:pic" ]
}
pkg_config("pkg_config_mojo_base") {
pkg_deps = [
"libmetrics",
"libmojo",
"mojo_service_manager",
]
}
source_set("mojo_base") {
sources = [
"//camera/common/camera_metrics_impl.cc",
"//camera/common/camera_mojo_channel_manager_impl.cc",
"//camera/common/sensor_hal_client_impl.cc",
"//camera/common/sensor_reader.cc",
]
public_configs = [
":pkg_config_mojo_base",
":target_defaults",
]
# -fPIC needed by the libcros_camera.so shared library.
configs += [ "//common-mk:pic" ]
public_deps = [
":base",
":libcros_camera_mojom",
]
}
source_set("privacy_shutter") {
sources = [ "//camera/common/privacy_shutter_detector_impl.cc" ]
public_configs = [ ":target_defaults" ]
# -fPIC needed by the libcros_camera.so shared library.
configs += [ "//common-mk:pic" ]
public_deps = [ ":base" ]
}
source_set("camera_algo_bridge") {
sources = [
"//camera/common/camera_algorithm_bridge_impl.cc",
"//camera/common/camera_algorithm_callback_ops_impl.cc",
]
public_configs = [ ":target_defaults" ]
# -fPIC needed by the libcros_camera.so shared library.
configs += [ "//common-mk:pic" ]
public_deps = [
":base",
":mojo_base",
]
}
source_set("defect_detector") {
sources = [ "//camera/common/defect_detector_impl.cc" ]
public_configs = [ ":target_defaults" ]
# -fPIC needed by the libcros_camera.so shared library.
configs += [ "//common-mk:pic" ]
public_deps = [ ":base" ]
}
source_set("face_detection") {
sources = [ "//camera/common/camera_face_detection.cc" ]
libs = [ "facessd_cros" ]
public_configs = [ ":target_defaults" ]
# -fPIC needed by the libcros_camera.so shared library.
configs += [ "//common-mk:pic" ]
public_deps = [ ":base" ]
}
source_set("jpeg") {
sources = [
"//camera/common/jpeg/jpeg_decode_accelerator_impl.cc",
"//camera/common/jpeg/jpeg_encode_accelerator_impl.cc",
"//camera/common/jpeg_compressor_impl.cc",
]
libs = [ "jpeg" ]
public_configs = [ ":target_defaults" ]
# -fPIC needed by the libcros_camera.so shared library.
configs += [ "//common-mk:pic" ]
public_deps = [
":base",
":mojo_base",
]
}
source_set("camera_connector") {
sources = [
"//camera/common/libcamera_connector/camera_client.cc",
"//camera/common/libcamera_connector/camera_client_ops.cc",
"//camera/common/libcamera_connector/camera_metadata_utils.cc",
"//camera/common/libcamera_connector/camera_module_callbacks.cc",
"//camera/common/libcamera_connector/camera_service_connector.cc",
"//camera/common/libcamera_connector/camera_service_connector_impl.cc",
"//camera/common/libcamera_connector/stream_buffer_manager.cc",
"//camera/common/libcamera_connector/supported_formats.cc",
]
public_configs = [ ":target_defaults" ]
# -fPIC needed by the libcros_camera.so shared library.
configs += [ "//common-mk:pic" ]
public_deps = [
":base",
":mojo_base",
]
}
source_set("v4l2_device") {
sources = [
"//camera/common/v4l2_device/v4l2_device.cc",
"//camera/common/v4l2_device/v4l2_subdevice.cc",
"//camera/common/v4l2_device/v4l2_video_node.cc",
]
public_configs = [ ":target_defaults" ]
# -fPIC needed by the libcros_camera.so shared library.
configs += [ "//common-mk:pic" ]
public_deps = [ ":base" ]
}
source_set("stream_manipulator") {
sources = [
"//camera/common/buffer_dumper_stream_manipulator.cc",
"//camera/common/capture_result_sequencer.cc",
"//camera/common/framing_stream_manipulator.cc",
"//camera/common/still_capture_processor_impl.cc",
"//camera/common/stream_manipulator.cc",
"//camera/common/stream_manipulator_helper.cc",
"//camera/common/stream_manipulator_manager.cc",
"//camera/common/sw_privacy_switch_stream_manipulator.cc",
]
if (use.camera_diagnostics) {
sources += [ "//camera/common/diagnostics_stream_manipulator.cc" ]
}
public_configs = [ ":target_defaults" ]
# -fPIC needed by the libcros_camera.so shared library.
configs += [ "//common-mk:pic" ]
public_deps = [
":base",
":mojo_base",
]
deps = [
":jpeg",
"//camera/gpu:gpu_resources",
]
if (use.camera_feature_auto_framing) {
deps += [ "//camera/features/auto_framing" ]
}
if (use.camera_feature_face_detection) {
deps += [ "//camera/features/face_detection" ]
}
if (use.camera_feature_frame_annotator) {
deps += [ "//camera/features/frame_annotator" ]
}
if (use.camera_feature_hdrnet) {
deps += [
"//camera/features/gcam_ae",
"//camera/features/hdrnet",
]
}
if (use.camera_feature_portrait_mode) {
deps += [ "//camera/features/portrait_mode" ]
}
if (use.camera_feature_super_res) {
deps += [ "//camera/features/super_resolution" ]
}
}
shared_library("libcros_camera") {
output_name = "libcros_camera"
configs += [ ":target_defaults" ]
install_path = "lib"
deps = [
":base",
":camera_algo_bridge",
":camera_connector",
":defect_detector",
":face_detection",
":jpeg",
":libcros_camera_device_config",
":mojo_base",
":privacy_shutter",
":stream_manipulator",
":tracing",
":v4l2_device",
"//camera/features",
"//camera/features/rotate_and_crop",
"//camera/features/zsl",
]
if (use.camera_feature_effects) {
deps += [ "//camera/features/effects" ]
}
}
generate_pkg_config("libcros_camera_pkg_config") {
name = "libcros_camera"
description = "cros-camera common libraries"
version = getenv("PV")
requires_private = [ "libchrome" ]
requires = [ "libmojo" ]
cflags = [ "-I/usr/include/cros-camera/mojo" ]
libs = [
"-lcros_camera",
"-lcros_camera_mojom",
]
install = true
}
executable("cros_camera_algo") {
sources = [
"//camera/common/camera_algorithm_adapter.cc",
"//camera/common/camera_algorithm_adapter_libcamera.cc",
"//camera/common/camera_algorithm_main.cc",
"//camera/common/camera_algorithm_ops_impl.cc",
"//camera/common/ipc_util.cc",
]
configs += [ ":target_defaults" ]
libs = [ "dl" ]
install_path = "bin"
pkg_deps = [
"libbrillo",
"libmojo",
]
deps = [
":libcros_camera",
# We only need //camera/mojo/algorithm/camera_algorithm.mojom,
# libcros_camera_mojom provides a superset mojom library containing it.
":libcros_camera_mojom",
]
}
# Build configs for unit tests.
pkg_config("target_defaults_test") {
configs = [
"//common-mk:test",
":target_defaults",
]
pkg_deps = [ "libchrome-test" ]
}
if (use.test) {
executable("camera_buffer_pool_test") {
sources = [
"//camera/common/camera_buffer_pool.cc",
"//camera/common/camera_buffer_pool_test.cc",
]
configs += [ ":target_defaults_test" ]
run_test = true
}
executable("camera_face_detection_test") {
sources = [
"//camera/common/camera_face_detection.cc",
"//camera/common/camera_face_detection_test.cc",
]
configs += [ ":target_defaults_test" ]
run_test = true
}
executable("camera_hal3_helpers_test") {
sources = [
"//camera/common/camera_hal3_helpers.cc",
"//camera/common/camera_hal3_helpers_test.cc",
]
configs += [ ":target_defaults_test" ]
deps = [ ":tracing" ]
run_test = true
}
executable("capture_result_sequencer_test") {
sources = [
"//camera/common/camera_hal3_helpers.cc",
"//camera/common/capture_result_sequencer.cc",
"//camera/common/capture_result_sequencer_test.cc",
]
configs += [ ":target_defaults_test" ]
deps = [
":libcros_camera_mojom",
":tracing",
]
run_test = true
}
executable("cbm_test") {
sources = [
"//camera/common/camera_buffer_manager_impl.cc",
"//camera/common/camera_buffer_manager_impl_test.cc",
]
configs += [ ":target_defaults_test" ]
run_test = true
}
executable("future_test") {
sources = [
"//camera/common/future.cc",
"//camera/common/future_test.cc",
]
configs += [ ":target_defaults_test" ]
run_test = true
}
cc_embed_data("embed_file_toc_test_files") {
sources = [
"//camera/common/embed_file_toc.cc",
"//camera/common/embed_file_toc.h",
]
}
executable("embed_file_toc_test") {
sources = [
"//camera/common/embed_file_toc.cc",
"//camera/common/embed_file_toc_test.cc",
]
configs += [ ":target_defaults_test" ]
run_test = true
deps = [ ":embed_file_toc_test_files" ]
}
executable("relative_fov_test") {
sources = [ "//camera/common/relative_fov_test.cc" ]
configs += [ ":target_defaults_test" ]
run_test = true
deps = [ ":base" ]
}
executable("stream_manipulator_helper_test") {
sources = [
"//camera/common/camera_buffer_pool.cc",
"//camera/common/camera_hal3_helpers.cc",
"//camera/common/capture_result_sequencer.cc",
"//camera/common/relative_fov.cc",
"//camera/common/stream_manipulator_helper.cc",
"//camera/common/stream_manipulator_helper_test.cc",
]
configs += [ ":target_defaults_test" ]
run_test = true
deps = [
":libcros_camera_mojom",
":tracing",
"//camera/common/test_support",
]
}
executable("stream_manipulator_manager_test") {
sources = [ "//camera/common/stream_manipulator_manager_test.cc" ]
configs += [ ":target_defaults_test" ]
run_test = true
deps = [ ":stream_manipulator" ]
}
executable("zsl_helper_test") {
sources = [
"//camera/features/zsl/zsl_helper.cc",
"//camera/features/zsl/zsl_helper_test.cc",
]
configs += [
"//common-mk:test",
"//camera/features/zsl:target_defaults",
]
run_test = true
pkg_deps = [
"gbm",
"libdrm",
]
deps = [ "//camera/common:base" ]
}
executable("feature_profile_test") {
sources = [
"//camera/features/feature_profile.cc",
"//camera/features/feature_profile_test.cc",
]
configs += [ "//camera/features:test_target_defaults" ]
run_test = true
deps = [
"//camera/common:base",
"//camera/common:libcros_camera_device_config",
]
}
}
if (use.fuzzer) {
executable("camera_still_capture_processor_impl_fuzzer") {
sources = [ "//camera/common/still_capture_processor_impl_fuzzer.cc" ]
configs += [
"//common-mk/common_fuzzer",
":target_defaults",
]
deps = [
":libcros_camera_device_config",
":stream_manipulator",
"//camera/features",
"//camera/features/rotate_and_crop",
"//camera/features/zsl",
]
}
}
install_config("install_cros_camera_algo_conf") {
sources = [ "init/cros-camera-algo.conf" ]
install_path = "upstart"
}
install_config("install_dbus_cros_camera_algo_conf") {
sources = [ "dbus/CrosCameraAlgo.conf" ]
install_path = "dbus_system_d"
}
install_seccomp_policy("install_cros_camera_algo_policy") {
arch = getenv("ARCH")
sources = [ "seccomp_filter/cros-camera-algo-${arch}.policy" ]
outputs = [ "cros-camera-algo-seccomp.policy" ]
install_path = "seccomp_policy"
}
# The sandboxed GPU service is used by Portrait Mode feature, IPU6SE
# and Qualcomm Camx camera HAL.
if (use.ipu6se || use.ipu6epadln || use.ipu6epmtl || use.qualcomm_camx) {
install_config("install_cros_camera_gpu_algo_conf") {
sources = [ "init/cros-camera-gpu-algo.conf" ]
install_path = "upstart"
}
install_seccomp_policy("install_cros_camera_gpu_algo_policy") {
arch = getenv("ARCH")
sources = [ "seccomp_filter/cros-camera-gpu-algo-${arch}.policy" ]
outputs = [ "cros-camera-gpu-algo-seccomp.policy" ]
install_path = "seccomp_policy"
}
}
# Install libcros_camera required by the camera HAL implementations.
install_config("install_include_cros_camera") {
sources = [ "../include/cros-camera" ]
recursive = true
install_path = "/usr/include/"
}
install_config("install_gen_include_iioservice_mojo") {
sources = [ "${root_gen_dir}/include/iioservice/mojo" ]
recursive = true
install_path = "/usr/include/cros-camera/mojo/iioservice"
deps = [ "//iioservice/libiioservice_ipc:libiioservice_ipc_mojom" ]
}
# Project Pita libraries need libcamera_connector.so to run.
install_config("install_libcamera_connector_so") {
sources = [ "${libdir}/libcros_camera.so" ]
install_path = "${libdir}"
symlinks = [ "libcamera_connector.so" ]
deps = [ ":libcros_camera" ]
}
install_config("install_minijail_algo_conf") {
sources = [ "minijail/cros-camera-algo.conf" ]
install_path = "minijail_conf"
}
install_config("install_minijail_gpu_algo_conf") {
sources = [ "minijail/cros-camera-gpu-algo.conf" ]
install_path = "minijail_conf"
}
install_config("install_camera_hal_dispatcher_mojo") {
sources = [ "//camera/common/camera_hal_dispatcher_mojo_policy.jsonc" ]
install_path = "/etc/mojo/service_manager/policy"
}
install_config("install_jpeg_accelerator_mojo") {
sources = [ "//camera/common/jpeg/jpeg_accelerator_mojo_policy.jsonc" ]
install_path = "/etc/mojo/service_manager/policy"
}