1#
2# Copyright (C) 2017 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)
18
19SPIRIT_SRCS := \
20	builder.cpp\
21	entity.cpp\
22	instructions.cpp\
23	module.cpp\
24	pass.cpp\
25	pass_queue.cpp\
26	transformer.cpp\
27	visitor.cpp\
28	word_stream.cpp\
29	word_stream_impl.cpp
30
31LIBNAME = libspirit
32
33NDK_PREBUILTS := $(TOP)/prebuilts/ndk/current
34SPIRV_TOOLS_PATH := $(NDK_PREBUILTS)/sources/third_party/shaderc/third_party/spirv-tools
35SPIRV_HEADERS_PATH := $(SPIRV_TOOLS_PATH)/external/spirv-headers
36SPIRV_CORE_GRAMMAR := $(SPIRV_HEADERS_PATH)/include/spirv/1.1/spirv.core.grammar.json
37GENERATOR := $(LOCAL_PATH)/generate.py
38
39LOCAL_CFLAGS := -Wall -Werror
40
41# Don't build for unbundled branches
42ifeq (,$(TARGET_BUILD_APPS))
43
44#=====================================================================
45# Host shared library libspirit.so
46#=====================================================================
47
48include $(CLEAR_VARS)
49
50LOCAL_SRC_FILES := $(SPIRIT_SRCS)
51
52LOCAL_MODULE := $(LIBNAME)
53LOCAL_MULTILIB := first
54LOCAL_MODULE_CLASS := SHARED_LIBRARIES
55LOCAL_IS_HOST_MODULE := true
56
57PATH_TO_GENERATED := $(local-generated-sources-dir)
58GEN := \
59	instructions_generated.h\
60	types_generated.h\
61	opcodes_generated.h\
62	instruction_dispatches_generated.h\
63	enum_dispatches_generated.h\
64	type_inst_dispatches_generated.h\
65	const_inst_dispatches_generated.h\
66	factory_methods_generated.h
67
68FULL_GEN := $(addprefix $(PATH_TO_GENERATED)/,$(GEN))
69$(FULL_GEN): $(SPIRV_CORE_GRAMMAR) $(GENERATOR)
70	$(GENERATOR) $< --$(notdir $(@:%_generated.h=%)) $@
71
72LOCAL_GENERATED_SOURCES := $(FULL_GEN)
73
74LOCAL_CFLAGS := -Wall -Werror
75
76LOCAL_C_INCLUDES += $(PATH_TO_GENERATED)
77
78LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) $(PATH_TO_GENERATED)
79
80include $(BUILD_HOST_SHARED_LIBRARY)
81
82#=====================================================================
83# Tests for host module word_stream
84#=====================================================================
85
86include $(CLEAR_VARS)
87
88LOCAL_SRC_FILES := \
89  word_stream.cpp \
90  word_stream_impl.cpp \
91  word_stream_test.cpp
92
93LOCAL_STATIC_LIBRARIES := libgtest_host
94
95LOCAL_MODULE := word_stream_test
96LOCAL_MULTILIB := first
97LOCAL_MODULE_TAGS := tests
98LOCAL_MODULE_CLASS := NATIVE_TESTS
99LOCAL_IS_HOST_MODULE := true
100
101PATH_TO_GENERATED := $(local-generated-sources-dir)
102GEN := \
103	enum_dispatches_generated.h\
104	types_generated.h
105
106FULL_GEN := $(addprefix $(PATH_TO_GENERATED)/,$(GEN))
107$(FULL_GEN): $(SPIRV_CORE_GRAMMAR) $(GENERATOR)
108	$(GENERATOR) $< --$(notdir $(@:%_generated.h=%)) $@
109
110LOCAL_GENERATED_SOURCES := $(FULL_GEN)
111
112LOCAL_C_INCLUDES += $(PATH_TO_GENERATED)
113
114LOCAL_CFLAGS := -Wall -Werror
115
116include $(BUILD_HOST_NATIVE_TEST)
117
118#=====================================================================
119# Tests for host module instructions
120#=====================================================================
121
122include $(CLEAR_VARS)
123
124LOCAL_SRC_FILES := \
125  entity.cpp \
126  instructions.cpp \
127  instructions_test.cpp \
128  visitor.cpp \
129  word_stream.cpp \
130  word_stream_impl.cpp
131
132LOCAL_STATIC_LIBRARIES := libgtest_host
133
134LOCAL_MODULE := instructions_test
135LOCAL_MULTILIB := first
136LOCAL_MODULE_TAGS := tests
137LOCAL_MODULE_CLASS := NATIVE_TESTS
138LOCAL_IS_HOST_MODULE := true
139
140PATH_TO_GENERATED := $(local-generated-sources-dir)
141GEN := \
142	enum_dispatches_generated.h\
143	instruction_dispatches_generated.h\
144	instructions_generated.h\
145	types_generated.h\
146	opcodes_generated.h
147
148FULL_GEN := $(addprefix $(PATH_TO_GENERATED)/,$(GEN))
149$(FULL_GEN): $(SPIRV_CORE_GRAMMAR) $(GENERATOR)
150	$(GENERATOR) $< --$(notdir $(@:%_generated.h=%)) $@
151
152LOCAL_GENERATED_SOURCES := $(FULL_GEN)
153
154LOCAL_CFLAGS := -Wall -Werror
155
156LOCAL_C_INCLUDES += $(PATH_TO_GENERATED)
157
158include $(BUILD_HOST_NATIVE_TEST)
159
160#=====================================================================
161# Tests for host module pass queue
162#=====================================================================
163
164include $(CLEAR_VARS)
165
166LOCAL_SRC_FILES := \
167  pass.cpp \
168  pass_queue.cpp \
169  pass_queue_test.cpp \
170
171LOCAL_STATIC_LIBRARIES := libgtest_host
172
173LOCAL_SHARED_LIBRARIES := $(LIBNAME)
174
175LOCAL_MODULE := pass_queue_test
176LOCAL_MULTILIB := first
177LOCAL_MODULE_TAGS := tests
178LOCAL_MODULE_CLASS := NATIVE_TESTS
179LOCAL_IS_HOST_MODULE := true
180LOCAL_CFLAGS := -Wall -Werror
181
182include $(BUILD_HOST_NATIVE_TEST)
183
184#=====================================================================
185# Tests for host shared library
186#=====================================================================
187
188include $(CLEAR_VARS)
189
190LOCAL_SRC_FILES := \
191  builder_test.cpp \
192  module_test.cpp \
193  transformer_test.cpp \
194
195LOCAL_STATIC_LIBRARIES := libgtest_host
196
197LOCAL_SHARED_LIBRARIES := $(LIBNAME)
198
199LOCAL_MODULE := $(LIBNAME)_test
200LOCAL_MULTILIB := first
201LOCAL_MODULE_TAGS := tests
202LOCAL_MODULE_CLASS := NATIVE_TESTS
203LOCAL_IS_HOST_MODULE := true
204LOCAL_CFLAGS := -Wall -Werror
205
206include $(BUILD_HOST_NATIVE_TEST)
207
208#=====================================================================
209# Device shared library libspirit.so
210#=====================================================================
211
212include $(CLEAR_VARS)
213
214LOCAL_SRC_FILES := $(SPIRIT_SRCS)
215
216LOCAL_C_INCLUDES := $(SPIRIT_INCLUDES)
217
218LOCAL_MODULE := $(LIBNAME)
219LOCAL_MODULE_CLASS := SHARED_LIBRARIES
220
221LOCAL_SHARED_LIBRARIES +=
222
223PATH_TO_GENERATED := $(local-generated-sources-dir)
224
225GEN := \
226	instructions_generated.h\
227	types_generated.h\
228	opcodes_generated.h\
229	instruction_dispatches_generated.h\
230	enum_dispatches_generated.h\
231	type_inst_dispatches_generated.h\
232	const_inst_dispatches_generated.h\
233	factory_methods_generated.h
234
235FULL_GEN := $(addprefix $(PATH_TO_GENERATED)/,$(GEN))
236$(FULL_GEN): $(SPIRV_CORE_GRAMMAR) $(GENERATOR)
237	$(GENERATOR) $< --$(notdir $(@:%_generated.h=%)) $@
238
239LOCAL_GENERATED_SOURCES := $(FULL_GEN)
240
241LOCAL_C_INCLUDES += $(PATH_TO_GENERATED)
242
243LOCAL_CFLAGS := -Wall -Werror -Wno-error=non-virtual-dtor
244
245LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) $(PATH_TO_GENERATED)
246
247include $(BUILD_SHARED_LIBRARY)
248
249endif # Don't build in unbundled branches
250