1#
2# Copyright (C) 2016 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
17LOCAL_PATH := $(call my-dir)
18LLVM_ROOT_PATH := external/llvm
19LIBBCC_ROOT_PATH := frameworks/compile/libbcc
20LIBSPIRV_ROOT_PATH := external/spirv-llvm/lib/SPIRV
21
22FORCE_RS2SPIRV_DEBUG_BUILD ?= false
23RS2SPRIV_DEVICE_BUILD ?= true
24
25RS2SPIRV_SOURCES := \
26  rs2spirv.cpp \
27  Builtin.cpp \
28  Context.cpp \
29  GlobalAllocPass.cpp \
30  GlobalAllocSPIRITPass.cpp \
31  GlobalMergePass.cpp \
32  InlinePreparationPass.cpp \
33  RemoveNonkernelsPass.cpp \
34  RSAllocationUtils.cpp \
35  RSSPIRVWriter.cpp \
36  Wrapper.cpp \
37
38RS2SPIRV_INCLUDES := \
39  $(LIBSPIRV_ROOT_PATH) \
40  $(LIBSPIRV_ROOT_PATH)/Mangler \
41  $(LIBSPIRV_ROOT_PATH)/libSPIRV \
42  $(LIBBCC_ROOT_PATH)/include \
43  $(LLVM_ROOT_PATH)/include \
44  $(LLVM_ROOT_PATH)/host/include
45
46#=====================================================================
47# Unit tests for Wrapper module
48#=====================================================================
49
50include $(CLEAR_VARS)
51include $(CLEAR_TBLGEN_VARS)
52
53LOCAL_SRC_FILES := \
54  Builtin.cpp \
55  Context.cpp \
56  GlobalAllocSPIRITPass.cpp \
57  RSAllocationUtils.cpp \
58  Wrapper.cpp \
59  Wrapper_test.cpp \
60
61LOCAL_STATIC_LIBRARIES := libgtest_host
62
63LOCAL_SHARED_LIBRARIES := libLLVM_android libbcinfo libspirit
64
65LOCAL_C_INCLUDES := \
66  $(LLVM_ROOT_PATH)/include \
67  $(LLVM_ROOT_PATH)/host/include
68
69# End protobuf section
70
71LOCAL_MODULE := Wrapper_test
72LOCAL_MULTILIB := first
73LOCAL_MODULE_TAGS := tests
74
75LOCAL_MODULE_CLASS := NATIVE_TESTS
76
77include $(LLVM_ROOT_PATH)/llvm.mk
78include $(LLVM_HOST_BUILD_MK)
79include $(LLVM_GEN_INTRINSICS_MK)
80include $(LLVM_GEN_ATTRIBUTES_MK)
81include $(BUILD_HOST_NATIVE_TEST)
82
83#=====================================================================
84# Unit tests for Builtin module
85#=====================================================================
86
87include $(CLEAR_VARS)
88include $(CLEAR_TBLGEN_VARS)
89
90LOCAL_SRC_FILES := \
91  Builtin.cpp \
92  Builtin_test.cpp \
93
94LOCAL_STATIC_LIBRARIES := libgtest_host
95
96LOCAL_SHARED_LIBRARIES := libspirit
97
98# End protobuf section
99
100LOCAL_MODULE := Builtin_test
101LOCAL_MULTILIB := first
102LOCAL_MODULE_TAGS := tests
103LOCAL_CFLAGS := -Wall -Werror
104
105LOCAL_MODULE_CLASS := NATIVE_TESTS
106
107include $(BUILD_HOST_NATIVE_TEST)
108
109#=====================================================================
110# Host Executable rs2spirv
111#=====================================================================
112
113# Don't build for unbundled branches
114ifeq (,$(TARGET_BUILD_APPS))
115
116include $(CLEAR_VARS)
117include $(CLEAR_TBLGEN_VARS)
118
119LOCAL_SRC_FILES := \
120  $(RS2SPIRV_SOURCES)
121
122LOCAL_C_INCLUDES := \
123  $(RS2SPIRV_INCLUDES)
124
125LOCAL_MODULE := rs2spirv
126LOCAL_MODULE_CLASS := EXECUTABLES
127
128# TODO: fix the remaining warnings
129
130LOCAL_CFLAGS += $(TOOL_CFLAGS) \
131  -D_SPIRV_LLVM_API \
132  -Wno-error=pessimizing-move \
133  -Wno-error=unused-variable \
134  -Wno-error=unused-private-field \
135  -Wno-error=unused-function \
136  -Wno-error=dangling-else \
137  -Wno-error=ignored-qualifiers \
138  -Wno-error=non-virtual-dtor
139
140ifeq (true, $(FORCE_RS2SPIRV_DEBUG_BUILD))
141  LOCAL_CFLAGS += -O0 -DRS2SPIRV_DEBUG=1
142endif
143
144LOCAL_SHARED_LIBRARIES := libLLVM_android libbcinfo libSPIRV libspirit
145
146include $(LLVM_ROOT_PATH)/llvm.mk
147include $(LLVM_HOST_BUILD_MK)
148include $(LLVM_GEN_INTRINSICS_MK)
149include $(LLVM_GEN_ATTRIBUTES_MK)
150include $(BUILD_HOST_EXECUTABLE)
151
152endif # Don't build in unbundled branches
153
154#=====================================================================
155# Device Executable rs2spirv
156#=====================================================================
157
158ifneq (true,$(RS2SPRIV_DEVICE_BUILD)))
159
160include $(CLEAR_VARS)
161include $(CLEAR_TBLGEN_VARS)
162
163LOCAL_SRC_FILES := \
164  $(RS2SPIRV_SOURCES)
165
166LOCAL_C_INCLUDES := \
167  $(RS2SPIRV_INCLUDES)
168
169LOCAL_MODULE := rs2spirv
170LOCAL_MODULE_CLASS := EXECUTABLES
171
172LOCAL_SHARED_LIBRARIES += libLLVM_android libbcinfo libSPIRV libspirit
173
174LOCAL_CFLAGS += $(TOOL_CFLAGS) \
175  -D_SPIRV_LLVM_API \
176  -Wno-error=pessimizing-move \
177  -Wno-error=unused-variable \
178  -Wno-error=unused-private-field \
179  -Wno-error=unused-function \
180  -Wno-error=dangling-else \
181  -Wno-error=ignored-qualifiers \
182  -Wno-error=non-virtual-dtor \
183
184ifeq (true, $(FORCE_RS2SPIRV_DEBUG_BUILD))
185  LOCAL_CFLAGS += -O0 -DRS2SPIRV_DEBUG=1
186endif
187
188include $(LLVM_GEN_INTRINSICS_MK)
189include $(LLVM_GEN_ATTRIBUTES_MK)
190include $(LLVM_DEVICE_BUILD_MK)
191include $(BUILD_EXECUTABLE)
192
193endif # Don't build in unbundled branches
194
195#=====================================================================
196# Include Subdirectories
197#=====================================================================
198
199include $(call all-makefiles-under,$(LOCAL_PATH))
200