summaryrefslogtreecommitdiff
path: root/android/Android.mk
diff options
context:
space:
mode:
authorNicholas Roth <nicholas@rothemail.net>2022-10-30 18:04:59 -0500
committerJacopo Mondi <jacopo@jmondi.org>2022-12-01 11:32:20 +0100
commit987d0058743cb07f29b1921ebd0c58d3aedc0963 (patch)
tree1c6bd7d87738b9541b39fa24a87c69423d6d4f5e /android/Android.mk
parent69050ca70469c40b90fad8bc2b3182ebe1ea4f5a (diff)
android: add makefiles to build inline with AOSP
Currently, while libcamera advertises Android support, there is no easy way to integrate libcamera into an Android distribution. This commit adds makefiles that allow libcamera to build inline with AOSP, with one example of how to do so documented in [0]. Note that meson_cross.mk is adapted from the Mesa project [1]. As Android support matures, it will be useful to document how to integrate libcamera for distribution owners [Bug]. [0] https://docs.google.com/document/d/1Sly_VH3w6wFIdE72WXijQegoHZh8IxEnJ9m0hH7GodU/edit [1] https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/android/mesa3d_cross.mk Bug https://bugs.libcamera.org/show_bug.cgi?id=164 Signed-off-by: Nichoals Roth <nicholas@rothemail.net>
Diffstat (limited to 'android/Android.mk')
-rw-r--r--android/Android.mk86
1 files changed, 86 insertions, 0 deletions
diff --git a/android/Android.mk b/android/Android.mk
new file mode 100644
index 00000000..ff0d1472
--- /dev/null
+++ b/android/Android.mk
@@ -0,0 +1,86 @@
+# SPDX-License-Identifier: Apache-2.0
+#
+# Copyright (C) 2021, GlobalLogic Ukraine
+# Copyright (C) 2021, Roman Stratiienko (r.stratiienko@gmail.com)
+#
+# Android.mk - Android makefile
+#
+
+ifneq ($(filter true, $(BOARD_LIBCAMERA_USES_MESON_BUILD)),)
+
+LOCAL_PATH := $(call my-dir)
+LIBCAMERA_TOP := $(dir $(LOCAL_PATH))
+LIBCAMERA_MESON_VERSION := .0.0.1
+
+include $(CLEAR_VARS)
+
+LOCAL_SHARED_LIBRARIES := libc libexif libjpeg libyuv_chromium libdl libyaml
+MESON_GEN_PKGCONFIGS := libexif libjpeg yaml-0.1 libyuv dl
+
+ifeq ($(TARGET_IS_64_BIT),true)
+LOCAL_MULTILIB := 64
+else
+LOCAL_MULTILIB := 32
+endif
+include $(LOCAL_PATH)/meson_cross.mk
+
+ifdef TARGET_2ND_ARCH
+LOCAL_MULTILIB := 32
+include $(LOCAL_PATH)/meson_cross.mk
+endif
+
+#-------------------------------------------------------------------------------
+
+define libcamera-lib
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE := $1
+LOCAL_VENDOR_MODULE := true
+LOCAL_MODULE_RELATIVE_PATH := $2
+ifdef TARGET_2ND_ARCH
+LOCAL_SRC_FILES_$(TARGET_ARCH) := $(call relative_top_path,$(LOCAL_PATH))$($3)
+LOCAL_SRC_FILES_$(TARGET_2ND_ARCH) := $(call relative_top_path,$(LOCAL_PATH))$(2ND_$3)
+LOCAL_MULTILIB := both
+else
+LOCAL_SRC_FILES := $(call relative_top_path,$(LOCAL_PATH))$($3)
+endif
+LOCAL_CHECK_ELF_FILES := false
+LOCAL_MODULE_SUFFIX := .so$(${4})
+include $(BUILD_PREBUILT)
+include $(CLEAR_VARS)
+endef
+
+__MY_SHARED_LIBRARIES := $(LOCAL_SHARED_LIBRARIES)
+include $(CLEAR_VARS)
+LOCAL_SHARED_LIBRARIES := $(__MY_SHARED_LIBRARIES)
+
+# Modules 'libcamera', produces '/vendor/lib{64}/libcamera.so'
+$(eval $(call libcamera-lib,libcamera,,LIBCAMERA_BIN,LIBCAMERA_MESON_VERSION))
+# Modules 'libcamera-base', produces '/vendor/lib{64}/libcamera-base.so'
+$(eval $(call libcamera-lib,libcamera-base,,LIBCAMERA_BASE_BIN,LIBCAMERA_MESON_VERSION))
+# Modules 'ipa_rkisp1', produces '/vendor/lib{64}/ipa_rkisp1.so'
+$(eval $(call libcamera-lib,ipa_rkisp1,,LIBCAMERA_IPA_RKISP1_BIN,))
+# Modules 'ipa_rkisp1', produces '/vendor/lib{64}/ipa_rpi.so'
+$(eval $(call libcamera-lib,ipa_rpi,,LIBCAMERA_IPA_RASPBERRYPI_BIN,))
+# Modules 'ipa_rkisp1', produces '/vendor/lib{64}/ipa_ipu3.so'
+$(eval $(call libcamera-lib,ipa_ipu3,,LIBCAMERA_IPA_IPU3_BIN,))
+# Modules 'ipa_rkisp1', produces '/vendor/lib{64}/ipa_vimc.so'
+$(eval $(call libcamera-lib,ipa_vimc,,LIBCAMERA_IPA_VIMC_BIN,))
+
+# Modules 'camera.libcamera', produces '/vendor/lib{64}/hw/camera.libcamera.so' HAL
+$(eval $(call libcamera-lib,camera.libcamera,hw,LIBCAMERA_HAL_BIN,))
+
+LOCAL_SHARED_LIBRARIES += libcamera libcamera-base ipa_rkisp1 ipa_rpi ipa_ipu3 ipa_vimc
+LOCAL_REQUIRED_MODULES := libcamera libcamera-base ipa_rkisp1 ipa_rpi ipa_ipu3 ipa_vimc
+
+$(shell mkdir -p $(TARGET_OUT_VENDOR_ETC)/rkisp1/)
+$(shell mkdir -p $(TARGET_OUT_VENDOR_ETC)/rpi/)
+$(shell mkdir -p $(TARGET_OUT_VENDOR_ETC)/ipu3/)
+$(shell mkdir -p $(TARGET_OUT_VENDOR_ETC)/vimc/)
+$(shell cp $(LIBCAMERA_IPA_RKISP1_CONFIGS)/* $(TARGET_OUT_VENDOR_ETC)/rkisp1/)
+$(shell cp $(LIBCAMERA_IPA_RASPBERRYPI_CONFIGS)/* $(TARGET_OUT_VENDOR_ETC)/rpi/)
+$(shell cp $(LIBCAMERA_IPA_IPU3_CONFIGS)/* $(TARGET_OUT_VENDOR_ETC)/ipu3/)
+$(shell cp $(LIBCAMERA_IPA_VIMC_CONFIGS)/* $(TARGET_OUT_VENDOR_ETC)/vimc/)
+
+#-------------------------------------------------------------------------------
+
+endif