1#
2# Copyright (C) 2010 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17# The prebuilt tools should be used when we are doing app-only build.
18ifeq ($(TARGET_BUILD_APPS),)
19
20LOCAL_PATH := $(call my-dir)
21
22local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror
23ifneq ($(TARGET_BUILD_VARIANT),eng)
24local_cflags_for_slang += -D__DISABLE_ASSERTS
25endif
26local_cflags_for_slang += -DTARGET_BUILD_VARIANT=$(TARGET_BUILD_VARIANT)
27
28ifeq "REL" "$(PLATFORM_VERSION_CODENAME)"
29  RS_VERSION := $(PLATFORM_SDK_VERSION)
30else
31  # Increment by 1 whenever this is not a final release build, since we want to
32  # be able to see the RS version number change during development.
33  # See build/core/version_defaults.mk for more information about this.
34  RS_VERSION := "(1 + $(PLATFORM_SDK_VERSION))"
35endif
36local_cflags_for_slang += -DRS_VERSION=$(RS_VERSION)
37
38static_libraries_needed_by_slang := \
39	libclangParse \
40	libclangSema \
41	libclangAnalysis \
42	libclangCodeGen \
43	libclangAST \
44	libclangLex \
45	libclangEdit \
46	libclangFrontend \
47	libclangBasic \
48	libclangSerialization \
49	libLLVMLinker \
50	libLLVMipo \
51	libLLVMBitWriter \
52	libLLVMBitWriter_2_9 \
53	libLLVMBitWriter_2_9_func \
54	libLLVMBitReader \
55	libLLVMARMCodeGen \
56	libLLVMARMAsmParser \
57	libLLVMARMAsmPrinter \
58	libLLVMARMInfo \
59	libLLVMARMDesc \
60	libLLVMX86CodeGen \
61	libLLVMX86Info \
62	libLLVMX86Desc \
63	libLLVMX86AsmParser \
64	libLLVMX86AsmPrinter \
65	libLLVMX86Utils \
66	libLLVMMipsCodeGen \
67	libLLVMMipsInfo \
68	libLLVMMipsDesc \
69	libLLVMMipsAsmParser \
70	libLLVMMipsAsmPrinter \
71	libLLVMAsmPrinter \
72	libLLVMSelectionDAG \
73	libLLVMCodeGen \
74	libLLVMScalarOpts \
75	libLLVMInstCombine \
76	libLLVMInstrumentation \
77	libLLVMTransformUtils \
78	libLLVMipa \
79	libLLVMAnalysis \
80	libLLVMTarget \
81	libLLVMMC \
82	libLLVMMCParser \
83	libLLVMCore \
84	libLLVMArchive \
85	libLLVMAsmParser \
86	libLLVMSupport \
87	libLLVMVectorize
88
89# Static library libslang for host
90# ========================================================
91include $(CLEAR_VARS)
92include $(CLEAR_TBLGEN_VARS)
93
94LLVM_ROOT_PATH := external/llvm
95CLANG_ROOT_PATH := external/clang
96
97include $(CLANG_ROOT_PATH)/clang.mk
98
99LOCAL_MODULE := libslang
100LOCAL_MODULE_TAGS := optional
101
102LOCAL_CFLAGS += $(local_cflags_for_slang)
103
104TBLGEN_TABLES :=    \
105	AttrList.inc	\
106	Attrs.inc	\
107	CommentNodes.inc \
108	DeclNodes.inc	\
109	DiagnosticCommonKinds.inc	\
110	DiagnosticFrontendKinds.inc	\
111	DiagnosticSemaKinds.inc	\
112	StmtNodes.inc
113
114LOCAL_SRC_FILES :=	\
115	slang.cpp	\
116	slang_utils.cpp	\
117	slang_backend.cpp	\
118	slang_pragma_recorder.cpp	\
119	slang_diagnostic_buffer.cpp
120
121LOCAL_C_INCLUDES += frameworks/compile/libbcc/include
122
123LOCAL_LDLIBS := -ldl -lpthread
124
125include $(CLANG_HOST_BUILD_MK)
126include $(CLANG_TBLGEN_RULES_MK)
127include $(LLVM_GEN_INTRINSICS_MK)
128include $(BUILD_HOST_STATIC_LIBRARY)
129
130# Host static library containing rslib.bc
131# ========================================================
132include $(CLEAR_VARS)
133
134input_data_file := frameworks/compile/slang/rslib.bc
135slangdata_output_var_name := rslib_bc
136
137LOCAL_IS_HOST_MODULE := true
138LOCAL_MODULE := librslib
139LOCAL_MODULE_TAGS := optional
140
141LOCAL_MODULE_CLASS := STATIC_LIBRARIES
142
143include $(LOCAL_PATH)/SlangData.mk
144include $(BUILD_HOST_STATIC_LIBRARY)
145
146# Executable slang-data for host
147# ========================================================
148include $(CLEAR_VARS)
149
150LOCAL_MODULE := slang-data
151LOCAL_MODULE_TAGS := optional
152
153LOCAL_MODULE_CLASS := EXECUTABLES
154
155LOCAL_SRC_FILES := slang-data.c
156
157include $(BUILD_HOST_EXECUTABLE)
158
159# Executable llvm-rs-link for host
160# ========================================================
161include $(CLEAR_VARS)
162include $(CLEAR_TBLGEN_VARS)
163
164include $(LLVM_ROOT_PATH)/llvm.mk
165
166LOCAL_MODULE := llvm-rs-link
167LOCAL_MODULE_TAGS := optional
168
169LOCAL_MODULE_CLASS := EXECUTABLES
170
171LOCAL_SRC_FILES :=	\
172	llvm-rs-link.cpp
173
174LOCAL_STATIC_LIBRARIES :=	\
175	librslib libslang \
176	$(static_libraries_needed_by_slang)
177
178LOCAL_LDLIBS := -ldl -lpthread
179
180include $(LLVM_HOST_BUILD_MK)
181include $(LLVM_GEN_INTRINSICS_MK)
182include $(BUILD_HOST_EXECUTABLE)
183
184# Executable rs-spec-gen for host
185# ========================================================
186include $(CLEAR_VARS)
187
188LOCAL_MODULE := rs-spec-gen
189LOCAL_MODULE_TAGS := optional
190
191LOCAL_MODULE_CLASS := EXECUTABLES
192
193LOCAL_SRC_FILES :=	\
194	slang_rs_spec_table.cpp
195
196include $(BUILD_HOST_EXECUTABLE)
197
198# Executable llvm-rs-cc for host
199# ========================================================
200include $(CLEAR_VARS)
201include $(CLEAR_TBLGEN_VARS)
202
203LOCAL_IS_HOST_MODULE := true
204LOCAL_MODULE := llvm-rs-cc
205LOCAL_MODULE_TAGS := optional
206
207LOCAL_MODULE_CLASS := EXECUTABLES
208
209LOCAL_CFLAGS += $(local_cflags_for_slang)
210
211TBLGEN_TABLES :=    \
212	AttrList.inc    \
213	Attrs.inc    \
214	CommentNodes.inc \
215	DeclNodes.inc    \
216	DiagnosticCommonKinds.inc   \
217	DiagnosticDriverKinds.inc	\
218	DiagnosticFrontendKinds.inc	\
219	DiagnosticSemaKinds.inc	\
220	StmtNodes.inc	\
221	RSCCOptions.inc
222
223RS_SPEC_TABLES :=	\
224	RSClangBuiltinEnums.inc	\
225	RSDataTypeEnums.inc	\
226	RSDataElementEnums.inc	\
227	RSMatrixTypeEnums.inc	\
228	RSObjectTypeEnums.inc
229
230LOCAL_SRC_FILES :=	\
231	llvm-rs-cc.cpp	\
232	slang_rs.cpp	\
233	slang_rs_ast_replace.cpp	\
234	slang_rs_check_ast.cpp	\
235	slang_rs_context.cpp	\
236	slang_rs_pragma_handler.cpp	\
237	slang_rs_backend.cpp	\
238	slang_rs_exportable.cpp	\
239	slang_rs_export_type.cpp	\
240	slang_rs_export_element.cpp	\
241	slang_rs_export_var.cpp	\
242	slang_rs_export_func.cpp	\
243	slang_rs_export_foreach.cpp \
244	slang_rs_object_ref_count.cpp	\
245	slang_rs_reflection.cpp \
246	slang_rs_reflection_base.cpp \
247	slang_rs_reflection_cpp.cpp \
248	slang_rs_reflect_utils.cpp
249
250LOCAL_STATIC_LIBRARIES :=	\
251	libclangDriver libslang \
252	$(static_libraries_needed_by_slang)
253
254ifeq ($(HOST_OS),windows)
255  LOCAL_LDLIBS := -limagehlp -lpsapi
256else
257  LOCAL_LDLIBS := -ldl -lpthread
258endif
259
260# For build RSCCOptions.inc from RSCCOptions.td
261intermediates := $(call local-intermediates-dir)
262LOCAL_GENERATED_SOURCES += $(intermediates)/RSCCOptions.inc
263$(intermediates)/RSCCOptions.inc: $(LOCAL_PATH)/RSCCOptions.td $(CLANG_ROOT_PATH)/include/clang/Driver/OptParser.td $(CLANG_TBLGEN)
264	@echo "Building Renderscript compiler (llvm-rs-cc) Option tables with tblgen"
265	$(call transform-host-clang-td-to-out,opt-parser-defs)
266
267include frameworks/compile/slang/RSSpec.mk
268include $(CLANG_HOST_BUILD_MK)
269include $(CLANG_TBLGEN_RULES_MK)
270include $(BUILD_HOST_EXECUTABLE)
271
272endif  # TARGET_BUILD_APPS
273
274#=====================================================================
275# Include Subdirectories
276#=====================================================================
277include $(call all-makefiles-under,$(LOCAL_PATH))
278