forked from GloDroid/aospext
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaospext_gen_targets.mk
71 lines (59 loc) · 2.79 KB
/
aospext_gen_targets.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# SPDX-License-Identifier: Apache-2.0
#
# AOSPEXT project (https://github.com/GloDroid/aospext)
#
# Copyright (C) 2021 GlobalLogic Ukraine
# Copyright (C) 2021-2022 Roman Stratiienko ([email protected])
# Inputs:
# AOSPEXT_GEN_TARGETS array
# AOSPEXT_TARGETS_SO_DEPS array
# AOSPEXT_INTERNAL_BUILD_TARGET
# AOSPEXT_EXPORT_INSTALLED_INCLUDE_DIRS (optional)
# AOSPEXT_EXTRA_DEPS (optional)
__TMP_AOSPEXT_PROJECT_INSTALL_DIR := $(dir $(AOSPEXT_INTERNAL_BUILD_TARGET))/install
__TMP_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
__TMP_C_INCLUDE_DIRS += $(foreach dir,$(AOSPEXT_EXPORT_INSTALLED_INCLUDE_DIRS), $(__TMP_AOSPEXT_PROJECT_INSTALL_DIR)/$(dir))
__TMP_MULTILIB := $(LOCAL_MULTILIB)
__TMP_SHARED_LIBRARIES := $(LOCAL_SHARED_LIBRARIES)
__TMP_CLASSES_bin := EXECUTABLES
__TMP_CLASSES_lib := SHARED_LIBRARIES
__TMP_CLASSES_libetc := ETC
__TMP_CLASSES_etc := ETC
__TMP_SUFFIX_bin :=
__TMP_SUFFIX_lib := .so
__TMP_SUFFIX_libetc :=
__TMP_SUFFIX_etc :=
__TMP_DIR_bin := vendor/bin
__TMP_DIR_lib := vendor/lib$(if $(TARGET_IS_64_BIT),$(if $(filter 64 first,$(LOCAL_MULTILIB)),64))
__TMP_DIR_libetc := vendor/lib$(if $(TARGET_IS_64_BIT),$(if $(filter 64 first,$(LOCAL_MULTILIB)),64))
__TMP_DIR_etc := vendor/etc
define unwrap_target
__TYPE := $(word 1,$1)
__PATHNAME = $(word 2,$1)
__SUBDIR := $(word 3,$1)
__PATH_OVERRIDE := $(if $(filter libetc,$(word 1,$1)),$(PRODUCT_OUT)/system/$(__TMP_DIR_libetc))
__MODULE := $(word 4,$1)
__SYMLINK_SUFFIX := $(word 5,$1)
__SKIP := $(if $(filter lib first,$(__TMP_MULTILIB) $(word 1,$1)),,true)
endef
define gen_module_for_target
# Target should be already created after $(AOSPEXT_INTERNAL_BUILD_TARGET) finished.
# So just define a target for KATI + update timestamp
$(__TMP_AOSPEXT_PROJECT_INSTALL_DIR)/$(__TMP_DIR_$(__TYPE))/$(__PATHNAME): $(AOSPEXT_INTERNAL_BUILD_TARGET) $(AOSPEXT_EXTRA_DEPS)
touch -ch $$@
include $(CLEAR_VARS)
LOCAL_MODULE_CLASS := $(__TMP_CLASSES_$(__TYPE))
LOCAL_MODULE_SUFFIX := $(__TMP_SUFFIX_$(__TYPE))
LOCAL_MODULE := $(__MODULE)
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_PATH := $(__PATH_OVERRIDE)
LOCAL_MODULE_RELATIVE_PATH := $(__SUBDIR)
LOCAL_PREBUILT_MODULE_FILE := $(__TMP_AOSPEXT_PROJECT_INSTALL_DIR)/$(__TMP_DIR_$(__TYPE))/$(__PATHNAME)
LOCAL_MULTILIB := $(__TMP_MULTILIB)
LOCAL_CHECK_ELF_FILES := false
LOCAL_MODULE_SYMLINKS := $(if $(__SYMLINK_SUFFIX),$(__MODULE)$(__SYMLINK_SUFFIX))
LOCAL_SHARED_LIBRARIES := $(__TMP_SHARED_LIBRARIES) $(foreach dep,$(AOSPEXT_TARGETS_SO_DEPS),$(if $(filter $(word 1,$(subst =, ,$(dep))),$(__MODULE)), $(subst :, ,$(word 2,$(subst =, ,$(dep))))))
LOCAL_EXPORT_C_INCLUDE_DIRS := $(__TMP_C_INCLUDE_DIRS)
include $(BUILD_PREBUILT)
endef
$(foreach target,$(AOSPEXT_GEN_TARGETS),$(eval $(call unwrap_target,$(subst $(space)$(space),$(space)$$(empty)$(space),$(subst :, ,$(target)))))$(if $(__SKIP),,$(eval $(call gen_module_for_target))))