• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Native prebuilt coming from Soong.
2# Extra inputs:
3# LOCAL_SOONG_UNSTRIPPED_BINARY
4
5ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
6  $(call pretty-error,soong_rust_prebuilt.mk may only be used from Soong)
7endif
8
9ifdef LOCAL_IS_HOST_MODULE
10  ifneq ($(HOST_OS),$(LOCAL_MODULE_HOST_OS))
11    my_prefix := HOST_CROSS_
12    LOCAL_HOST_PREFIX := $(my_prefix)
13  else
14    my_prefix := HOST_
15    LOCAL_HOST_PREFIX :=
16  endif
17else
18  my_prefix := TARGET_
19endif
20
21ifeq ($($(my_prefix)ARCH),$(LOCAL_MODULE_$(my_prefix)ARCH))
22  # primary arch
23  LOCAL_2ND_ARCH_VAR_PREFIX :=
24else ifeq ($($(my_prefix)2ND_ARCH),$(LOCAL_MODULE_$(my_prefix)ARCH))
25  # secondary arch
26  LOCAL_2ND_ARCH_VAR_PREFIX := $($(my_prefix)2ND_ARCH_VAR_PREFIX)
27else
28  $(call pretty-error,Unsupported LOCAL_MODULE_$(my_prefix)ARCH=$(LOCAL_MODULE_$(my_prefix)ARCH))
29endif
30
31# Don't install static/rlib/proc_macro libraries.
32ifndef LOCAL_UNINSTALLABLE_MODULE
33  ifneq ($(filter STATIC_LIBRARIES RLIB_LIBRARIES PROC_MACRO_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
34    LOCAL_UNINSTALLABLE_MODULE := true
35  endif
36endif
37
38
39#######################################
40include $(BUILD_SYSTEM)/base_rules.mk
41#######################################
42
43ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES RLIB_LIBRARIES DYLIB_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
44  # Soong module is a static or shared library
45  EXPORTS_LIST += $(intermediates)
46  EXPORTS.$(intermediates).FLAGS := $(LOCAL_EXPORT_CFLAGS)
47  EXPORTS.$(intermediates).DEPS := $(LOCAL_EXPORT_C_INCLUDE_DEPS)
48
49  SOONG_ALREADY_CONV += $(LOCAL_MODULE)
50
51  my_link_type := $(LOCAL_SOONG_LINK_TYPE)
52  my_warn_types :=
53  my_allowed_types :=
54  my_link_deps :=
55  my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
56  my_common :=
57  include $(BUILD_SYSTEM)/link_type.mk
58endif
59
60
61ifdef LOCAL_USE_VNDK
62  ifneq ($(LOCAL_VNDK_DEPEND_ON_CORE_VARIANT),true)
63    name_without_suffix := $(patsubst %.vendor,%,$(LOCAL_MODULE))
64    ifneq ($(name_without_suffix),$(LOCAL_MODULE))
65      SPLIT_VENDOR.$(LOCAL_MODULE_CLASS).$(name_without_suffix) := 1
66    else
67      name_without_suffix := $(patsubst %.product,%,$(LOCAL_MODULE))
68      ifneq ($(name_without_suffix),$(LOCAL_MODULE))
69        SPLIT_PRODUCT.$(LOCAL_MODULE_CLASS).$(name_without_suffix) := 1
70      endif
71    endif
72    name_without_suffix :=
73  endif
74endif
75
76# The real dependency will be added after all Android.mks are loaded and the install paths
77# of the shared libraries are determined.
78ifdef LOCAL_INSTALLED_MODULE
79  ifdef LOCAL_SHARED_LIBRARIES
80    my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
81    ifdef LOCAL_USE_VNDK
82      my_shared_libraries := $(foreach l,$(my_shared_libraries),\
83        $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
84    endif
85    $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
86      $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries))
87  endif
88  ifdef LOCAL_DYLIB_LIBRARIES
89    my_dylibs := $(LOCAL_DYLIB_LIBRARIES)
90    # Treat these as shared library dependencies for installation purposes.
91    ifdef LOCAL_USE_VNDK
92      my_dylibs := $(foreach l,$(my_dylibs),\
93        $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
94    endif
95    $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
96      $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_dylibs))
97  endif
98endif
99
100$(LOCAL_BUILT_MODULE): $(LOCAL_PREBUILT_MODULE_FILE)
101ifeq ($(LOCAL_IS_HOST_MODULE) $(if $(filter EXECUTABLES SHARED_LIBRARIES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),true,),true true)
102	$(copy-or-link-prebuilt-to-target)
103  ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
104	[ -x $@ ] || ( $(call echo-error,$@,Target of symlink is not executable); false )
105  endif
106else
107	$(transform-prebuilt-to-target)
108  ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
109	$(hide) chmod +x $@
110  endif
111endif
112
113ifndef LOCAL_IS_HOST_MODULE
114  ifdef LOCAL_SOONG_UNSTRIPPED_BINARY
115    my_symbol_path := $(if $(LOCAL_SOONG_SYMBOL_PATH),$(LOCAL_SOONG_SYMBOL_PATH),$(my_module_path))
116    # Store a copy with symbols for symbolic debugging
117    my_unstripped_path := $(TARGET_OUT_UNSTRIPPED)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_symbol_path))
118    # drop /root as /root is mounted as /
119    my_unstripped_path := $(patsubst $(TARGET_OUT_UNSTRIPPED)/root/%,$(TARGET_OUT_UNSTRIPPED)/%, $(my_unstripped_path))
120    symbolic_output := $(my_unstripped_path)/$(my_installed_module_stem)
121    $(eval $(call copy-one-file,$(LOCAL_SOONG_UNSTRIPPED_BINARY),$(symbolic_output)))
122    $(LOCAL_BUILT_MODULE): | $(symbolic_output)
123  endif
124endif
125
126create_coverage_zip :=
127
128ifeq ($(NATIVE_COVERAGE),true)
129   create_coverage_zip := true
130endif
131
132# Until Rust supports LLVM coverage, Soong assumes GCOV coverage in both cases.
133# Therefore we should create the coverage zip with the gcno files in this case as well.
134ifeq ($(CLANG_COVERAGE),true)
135   create_coverage_zip := true
136endif
137
138ifdef create_coverage_zip
139  ifneq (,$(strip $(LOCAL_PREBUILT_COVERAGE_ARCHIVE)))
140    $(eval $(call copy-one-file,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(intermediates)/$(LOCAL_MODULE).zip))
141    ifneq ($(LOCAL_UNINSTALLABLE_MODULE),true)
142      ifdef LOCAL_IS_HOST_MODULE
143        my_coverage_path := $($(my_prefix)OUT_COVERAGE)/$(patsubst $($(my_prefix)OUT)/%,%,$(my_module_path))
144      else
145        my_coverage_path := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
146      endif
147      my_coverage_path := $(my_coverage_path)/$(patsubst %.so,%,$(my_installed_module_stem)).zip
148      $(eval $(call copy-one-file,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(my_coverage_path)))
149      $(LOCAL_BUILT_MODULE): $(my_coverage_path)
150    endif
151  endif
152endif
153
154# A product may be configured to strip everything in some build variants.
155# We do the stripping as a post-install command so that LOCAL_BUILT_MODULE
156# is still with the symbols and we don't need to clean it (and relink) when
157# you switch build variant.
158ifneq ($(filter $(STRIP_EVERYTHING_BUILD_VARIANTS),$(TARGET_BUILD_VARIANT)),)
159$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := \
160  $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP) --strip-all $(LOCAL_INSTALLED_MODULE)
161endif
162
163$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES)
164
165# We don't care about installed rlib/static libraries, since the libraries have
166# already been linked into the module at that point. We do, however, care
167# about the NOTICE files for any rlib/static libraries that we use.
168# (see notice_files.mk)
169#
170# Filter out some NDK libraries that are not being exported.
171my_static_libraries := \
172    $(filter-out ndk_libc++_static ndk_libc++abi ndk_libandroid_support ndk_libunwind \
173      ndk_libc++_static.native_bridge ndk_libc++abi.native_bridge \
174      ndk_libandroid_support.native_bridge ndk_libunwind.native_bridge, \
175      $(LOCAL_STATIC_LIBRARIES))
176installed_static_library_notice_file_targets := \
177    $(foreach lib,$(my_static_libraries), \
178      NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST$(if $(my_host_cross),_CROSS,),TARGET)-STATIC_LIBRARIES-$(lib))
179installed_static_library_notice_file_targets += \
180    $(foreach lib,$(LOCAL_RLIB_LIBRARIES), \
181      NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST$(if $(my_host_cross),_CROSS,),TARGET)-RLIB_LIBRARIES-$(lib))
182
183$(notice_target): | $(installed_static_library_notice_file_targets)
184$(LOCAL_INSTALLED_MODULE): | $(notice_target)
185