• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1###############################################################
2## Renderscript support for java
3## Adds rules to convert .rscript files to .java and .bc files
4###############################################################
5
6renderscript_sources := $(filter %.rscript,$(LOCAL_SRC_FILES))
7LOCAL_SRC_FILES := $(filter-out %.rscript,$(LOCAL_SRC_FILES))
8
9rs_generated_res_zip :=
10rs_generated_src_jar :=
11rs_compatibility_jni_libs :=
12ifneq ($(renderscript_sources),)
13renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
14renderscript_intermediate.COMMON := $(intermediates.COMMON)/renderscript
15rs_generated_res_zip := $(renderscript_intermediate.COMMON)/res.zip
16rs_generated_src_jar := $(renderscript_intermediate.COMMON)/rs.srcjar
17
18LOCAL_SRCJARS += $(rs_generated_src_jar)
19
20# Defaulting to an empty string uses the latest available platform SDK.
21renderscript_target_api :=
22
23ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API))
24  renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API)
25else
26  ifneq (,$(LOCAL_SDK_VERSION))
27    # Set target-api for LOCAL_SDK_VERSIONs other than current.
28    ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION)))
29      renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
30    endif
31  endif  # LOCAL_SDK_VERSION is set
32endif  # LOCAL_RENDERSCRIPT_TARGET_API is set
33
34# For 64-bit, we always have to upgrade to at least 21 for compat build.
35ifneq ($(LOCAL_RENDERSCRIPT_COMPATIBILITY),)
36  ifeq ($(TARGET_IS_64_BIT),true)
37    ifneq ($(filter $(RSCOMPAT_32BIT_ONLY_API_LEVELS),$(renderscript_target_api)),)
38      renderscript_target_api := 21
39    endif
40  endif
41endif
42
43ifeq ($(LOCAL_RENDERSCRIPT_CC),)
44LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
45endif
46
47# Turn on all warnings and warnings as errors for RS compiles.
48# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error
49renderscript_flags := -Wall -Werror
50renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS)
51
52# prepend the RenderScript system include path
53ifneq ($(filter-out current system_current test_current core_current,$(LOCAL_SDK_VERSION))$(if $(TARGET_BUILD_USE_PREBUILT_SDKS),$(filter current system_current test_current,$(LOCAL_SDK_VERSION))),)
54# if a numeric LOCAL_SDK_VERSION, or current LOCAL_SDK_VERSION with TARGET_BUILD_USE_PREBUILT_SDKS
55LOCAL_RENDERSCRIPT_INCLUDES := \
56    $(HISTORICAL_SDK_VERSIONS_ROOT)/renderscript/clang-include \
57    $(HISTORICAL_SDK_VERSIONS_ROOT)/renderscript/include \
58    $(LOCAL_RENDERSCRIPT_INCLUDES)
59else
60LOCAL_RENDERSCRIPT_INCLUDES := \
61    $(TOPDIR)external/clang/lib/Headers \
62    $(TOPDIR)frameworks/rs/script_api/include \
63    $(LOCAL_RENDERSCRIPT_INCLUDES)
64endif
65
66ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
67LOCAL_RENDERSCRIPT_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
68endif
69
70bc_files := $(patsubst %.rscript,%.bc, $(notdir $(renderscript_sources)))
71bc_dep_files := $(addprefix $(renderscript_intermediate.COMMON)/,$(patsubst %.bc,%.d,$(bc_files)))
72
73$(rs_generated_src_jar): PRIVATE_RS_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES)
74$(rs_generated_src_jar): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
75$(rs_generated_src_jar): PRIVATE_RS_FLAGS := $(renderscript_flags)
76$(rs_generated_src_jar): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
77$(rs_generated_src_jar): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate.COMMON)
78$(rs_generated_src_jar): PRIVATE_RS_TARGET_API := $(patsubst current,0,$(renderscript_target_api))
79$(rs_generated_src_jar): PRIVATE_DEP_FILES := $(bc_dep_files)
80$(rs_generated_src_jar): PRIVATE_RS_OUTPUT_RES_ZIP := $(rs_generated_res_zip)
81$(rs_generated_src_jar): .KATI_IMPLICIT_OUTPUTS := $(rs_generated_res_zip)
82$(rs_generated_src_jar): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC) $(SOONG_ZIP)
83	$(transform-renderscripts-to-java-and-bc)
84
85# include the dependency files (.d) generated by llvm-rs-cc.
86$(call include-depfile,$(rs_generated_src_jar).d,$(rs_generated_src_jar))
87
88ifneq ($(LOCAL_RENDERSCRIPT_COMPATIBILITY),)
89
90
91ifeq ($(filter $(RSCOMPAT_32BIT_ONLY_API_LEVELS),$(renderscript_target_api)),)
92ifeq ($(TARGET_IS_64_BIT),true)
93renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/bc64/
94else
95renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/bc32/
96endif
97else
98renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/
99endif
100
101rs_generated_bc := $(addprefix \
102    $(renderscript_intermediate.bc_folder), $(bc_files))
103
104renderscript_intermediate := $(intermediates)/renderscript
105
106# We don't need the .so files in bundled branches
107# Prevent these from showing up on the device
108# One exception is librsjni.so, which is needed for
109# both native path and compat path.
110rs_jni_lib := $(call intermediates-dir-for,SHARED_LIBRARIES,librsjni.so)/librsjni.so
111LOCAL_JNI_SHARED_LIBRARIES += librsjni
112
113ifneq (,$(TARGET_BUILD_USE_PREBUILT_SDKS)$(FORCE_BUILD_RS_COMPAT))
114
115rs_compatibility_jni_libs := $(addprefix \
116    $(renderscript_intermediate)/librs., \
117    $(patsubst %.bc,%.so, $(bc_files)))
118
119$(rs_generated_src_jar): .KATI_IMPLICIT_OUTPUTS += $(rs_generated_bc)
120
121rs_support_lib := $(call intermediates-dir-for,SHARED_LIBRARIES,libRSSupport)/libRSSupport.so
122LOCAL_JNI_SHARED_LIBRARIES += libRSSupport
123
124rs_support_io_lib :=
125# check if the target api level support USAGE_IO
126ifeq ($(filter $(RSCOMPAT_NO_USAGEIO_API_LEVELS),$(renderscript_target_api)),)
127rs_support_io_lib := $(call intermediates-dir-for,SHARED_LIBRARIES,libRSSupportIO)/libRSSupportIO.so
128LOCAL_JNI_SHARED_LIBRARIES += libRSSupportIO
129endif
130
131my_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
132ifneq (,$(filter arm64 x86_64,$(my_arch)))
133  my_min_sdk_version := 21
134else
135  my_min_sdk_version := $(MIN_SUPPORTED_SDK_VERSION)
136endif
137
138$(rs_compatibility_jni_libs): $(RS_PREBUILT_CLCORE) \
139    $(rs_support_lib) $(rs_support_io_lib) $(rs_jni_lib) $(rs_compiler_rt)
140$(rs_compatibility_jni_libs): $(BCC_COMPAT)
141$(rs_compatibility_jni_libs): PRIVATE_CXX := $(CXX_WRAPPER) $(CLANG_CXX)
142$(rs_compatibility_jni_libs): PRIVATE_CXX_LINK := $(CLANG_CXX)
143$(rs_compatibility_jni_libs): PRIVATE_SDK_VERSION := $(my_min_sdk_version)
144$(rs_compatibility_jni_libs): $(renderscript_intermediate)/librs.%.so: \
145    $(renderscript_intermediate.bc_folder)%.bc \
146    $(SOONG_OUT_DIR)/ndk.timestamp
147	$(transform-bc-to-so)
148
149endif
150
151endif
152
153LOCAL_INTERMEDIATE_TARGETS += $(rs_generated_src_jar)
154# Make sure the generated resource will be added to the apk.
155LOCAL_RESOURCE_DIR := $(renderscript_intermediate.COMMON)/res $(LOCAL_RESOURCE_DIR)
156endif
157