1THIRD_PARTY_PATH := $(call my-dir)
2
3GLSLANG_LOCAL_PATH := $(THIRD_PARTY_PATH)/glslang
4LOCAL_PATH := $(GLSLANG_LOCAL_PATH)
5
6GLSLANG_OS_FLAGS := -DGLSLANG_OSINCLUDE_UNIX
7
8include $(CLEAR_VARS)
9LOCAL_MODULE:=SPIRV
10LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti $(GLSLANG_OS_FLAGS)
11LOCAL_EXPORT_C_INCLUDES:=$(GLSLANG_LOCAL_PATH)
12LOCAL_SRC_FILES:= \
13	SPIRV/GlslangToSpv.cpp \
14	SPIRV/InReadableOrder.cpp \
15	SPIRV/Logger.cpp \
16	SPIRV/SPVRemapper.cpp \
17	SPIRV/SpvBuilder.cpp \
18	SPIRV/disassemble.cpp \
19	SPIRV/doc.cpp
20
21LOCAL_C_INCLUDES:=$(GLSLANG_LOCAL_PATH) $(GLSLANG_LOCAL_PATH)/glslang/SPIRV
22LOCAL_EXPORT_C_INCLUDES:=$(GLSLANG_LOCAL_PATH)/glslang/SPIRV
23include $(BUILD_STATIC_LIBRARY)
24
25include $(CLEAR_VARS)
26LOCAL_MODULE:=OSDependent
27LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti $(GLSLANG_OS_FLAGS)
28LOCAL_EXPORT_C_INCLUDES:=$(GLSLANG_LOCAL_PATH)
29LOCAL_SRC_FILES:=glslang/OSDependent/Unix/ossource.cpp
30LOCAL_C_INCLUDES:=$(GLSLANG_LOCAL_PATH) $(GLSLANG_LOCAL_PATH)/glslang/OSDependent/Unix/
31LOCAL_EXPORT_C_INCLUDES:=$(GLSLANG_LOCAL_PATH)/glslang/OSDependent/Unix/
32include $(BUILD_STATIC_LIBRARY)
33
34include $(CLEAR_VARS)
35LOCAL_MODULE:=OGLCompiler
36LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti $(GLSLANG_OS_FLAGS)
37LOCAL_EXPORT_C_INCLUDES:=$(GLSLANG_LOCAL_PATH)
38LOCAL_SRC_FILES:=OGLCompilersDLL/InitializeDll.cpp
39LOCAL_C_INCLUDES:=$(GLSLANG_LOCAL_PATH)/OGLCompiler
40LOCAL_STATIC_LIBRARIES:=OSDependent
41include $(BUILD_STATIC_LIBRARY)
42
43
44# Build Glslang's HLSL parser library.
45include $(CLEAR_VARS)
46LOCAL_MODULE:=HLSL
47LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti
48LOCAL_SRC_FILES:= \
49		hlsl/hlslGrammar.cpp \
50		hlsl/hlslOpMap.cpp \
51		hlsl/hlslParseables.cpp \
52		hlsl/hlslParseHelper.cpp \
53		hlsl/hlslScanContext.cpp \
54		hlsl/hlslTokenStream.cpp
55LOCAL_C_INCLUDES:=$(GLSLANG_LOCAL_PATH) \
56	$(GLSLANG_LOCAL_PATH)/hlsl
57include $(BUILD_STATIC_LIBRARY)
58
59
60include $(CLEAR_VARS)
61
62GLSLANG_OUT_PATH=$(abspath $(TARGET_OUT))
63
64LOCAL_MODULE:=glslang
65LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti $(GLSLANG_OS_FLAGS)
66LOCAL_EXPORT_C_INCLUDES:=$(GLSLANG_LOCAL_PATH)
67
68LOCAL_SRC_FILES:= \
69		glslang/GenericCodeGen/CodeGen.cpp \
70		glslang/GenericCodeGen/Link.cpp \
71		glslang/MachineIndependent/Constant.cpp \
72		glslang/MachineIndependent/glslang_tab.cpp \
73		glslang/MachineIndependent/InfoSink.cpp \
74		glslang/MachineIndependent/Initialize.cpp \
75		glslang/MachineIndependent/Intermediate.cpp \
76		glslang/MachineIndependent/intermOut.cpp \
77		glslang/MachineIndependent/IntermTraverse.cpp \
78		glslang/MachineIndependent/limits.cpp \
79		glslang/MachineIndependent/linkValidate.cpp \
80		glslang/MachineIndependent/parseConst.cpp \
81		glslang/MachineIndependent/ParseHelper.cpp \
82		glslang/MachineIndependent/PoolAlloc.cpp \
83		glslang/MachineIndependent/propagateNoContraction.cpp \
84		glslang/MachineIndependent/reflection.cpp \
85		glslang/MachineIndependent/RemoveTree.cpp \
86		glslang/MachineIndependent/Scan.cpp \
87		glslang/MachineIndependent/ShaderLang.cpp \
88		glslang/MachineIndependent/SymbolTable.cpp \
89		glslang/MachineIndependent/Versions.cpp \
90		glslang/MachineIndependent/preprocessor/PpAtom.cpp \
91		glslang/MachineIndependent/preprocessor/PpContext.cpp \
92		glslang/MachineIndependent/preprocessor/Pp.cpp \
93		glslang/MachineIndependent/preprocessor/PpMemory.cpp \
94		glslang/MachineIndependent/preprocessor/PpScanner.cpp \
95		glslang/MachineIndependent/preprocessor/PpSymbols.cpp \
96		glslang/MachineIndependent/preprocessor/PpTokens.cpp
97
98LOCAL_C_INCLUDES:=$(GLSLANG_LOCAL_PATH) \
99	$(GLSLANG_LOCAL_PATH)/glslang/MachineIndependent \
100	$(GLSLANG_OUT_PATH)
101LOCAL_STATIC_LIBRARIES:=OSDependent OGLCompiler SPIRV HLSL
102include $(BUILD_STATIC_LIBRARY)
103
104
105SPVTOOLS_LOCAL_PATH := $(THIRD_PARTY_PATH)/spirv-tools
106LOCAL_PATH := $(SPVTOOLS_LOCAL_PATH)
107SPVTOOLS_OUT_PATH=$(abspath $(TARGET_OUT))
108SPVHEADERS_LOCAL_PATH := $(THIRD_PARTY_PATH)/spirv-tools/external/spirv-headers
109
110# Locations of grammar files.
111SPV_CORE10_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/1.0/spirv.core.grammar.json
112SPV_CORE11_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/1.1/spirv.core.grammar.json
113SPV_GLSL_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/1.0/extinst.glsl.std.450.grammar.json
114# OpenCL grammar has not yet been published to SPIRV-Headers
115SPV_OPENCL_GRAMMAR=$(SPVTOOLS_LOCAL_PATH)/source/extinst-1.0.opencl.std.grammar.json
116
117define gen_spvtools_grammar_tables
118$(call generate-file-dir,$(1)/core.insts-1.0.inc)
119$(1)/core.insts-1.0.inc $(1)/operand.kinds-1.0.inc $(1)/glsl.std.450.insts-1.0.inc $(1)/opencl.std.insts-1.0.inc: \
120        $(SPVTOOLS_LOCAL_PATH)/utils/generate_grammar_tables.py \
121        $(SPV_CORE10_GRAMMAR) \
122        $(SPV_GLSL_GRAMMAR) \
123        $(SPV_OPENCL_GRAMMAR)
124		@$(HOST_PYTHON) $(SPVTOOLS_LOCAL_PATH)/utils/generate_grammar_tables.py \
125		                --spirv-core-grammar=$(SPV_CORE10_GRAMMAR) \
126		                --extinst-glsl-grammar=$(SPV_GLSL_GRAMMAR) \
127		                --extinst-opencl-grammar=$(SPV_OPENCL_GRAMMAR) \
128		                --core-insts-output=$(1)/core.insts-1.0.inc \
129		                --glsl-insts-output=$(1)/glsl.std.450.insts-1.0.inc \
130		                --opencl-insts-output=$(1)/opencl.std.insts-1.0.inc \
131		                --operand-kinds-output=$(1)/operand.kinds-1.0.inc
132		@echo "[$(TARGET_ARCH_ABI)] Grammar v1.0   : instructions & operands <= grammar JSON files"
133$(1)/core.insts-1.1.inc $(1)/operand.kinds-1.1.inc: \
134        $(SPVTOOLS_LOCAL_PATH)/utils/generate_grammar_tables.py \
135        $(SPV_CORE11_GRAMMAR)
136		@$(HOST_PYTHON) $(SPVTOOLS_LOCAL_PATH)/utils/generate_grammar_tables.py \
137		                --spirv-core-grammar=$(SPV_CORE11_GRAMMAR) \
138		                --core-insts-output=$(1)/core.insts-1.1.inc \
139		                --operand-kinds-output=$(1)/operand.kinds-1.1.inc
140		@echo "[$(TARGET_ARCH_ABI)] Grammar v1.1   : instructions & operands <= grammar JSON files"
141$(SPVTOOLS_LOCAL_PATH)/source/opcode.cpp: $(1)/core.insts-1.0.inc $(1)/core.insts-1.1.inc
142$(SPVTOOLS_LOCAL_PATH)/source/operand.cpp: $(1)/operand.kinds-1.0.inc $(1)/operand.kinds-1.1.inc
143$(SPVTOOLS_LOCAL_PATH)/source/ext_inst.cpp: $(1)/glsl.std.450.insts-1.0.inc $(1)/opencl.std.insts-1.0.inc
144endef
145$(eval $(call gen_spvtools_grammar_tables,$(SPVTOOLS_OUT_PATH)))
146
147define gen_spvtools_build_version_inc
148$(call generate-file-dir,$(1)/dummy_filename)
149$(1)/build-version.inc: \
150        $(SPVTOOLS_LOCAL_PATH)/utils/update_build_version.py \
151        $(SPVTOOLS_LOCAL_PATH)/CHANGES
152		@$(HOST_PYTHON) $(SPVTOOLS_LOCAL_PATH)/utils/update_build_version.py \
153		                $(SPVTOOLS_LOCAL_PATH) $(1)/build-version.inc
154		@echo "[$(TARGET_ARCH_ABI)] Generate       : build-version.inc <= CHANGES"
155$(SPVTOOLS_LOCAL_PATH)/source/software_version.cpp: $(1)/build-version.inc
156endef
157$(eval $(call gen_spvtools_build_version_inc,$(SPVTOOLS_OUT_PATH)))
158
159include $(CLEAR_VARS)
160LOCAL_MODULE := SPIRV-Tools
161LOCAL_C_INCLUDES := \
162		$(SPVTOOLS_LOCAL_PATH)/include \
163		$(SPVTOOLS_LOCAL_PATH)/source \
164		$(SPVTOOLS_LOCAL_PATH)/external/spirv-headers/include \
165		$(SPVTOOLS_OUT_PATH)
166LOCAL_EXPORT_C_INCLUDES := \
167		$(SPVTOOLS_LOCAL_PATH)/include
168LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti
169LOCAL_SRC_FILES:= \
170		source/assembly_grammar.cpp \
171		source/binary.cpp \
172		source/diagnostic.cpp \
173		source/disassemble.cpp \
174		source/ext_inst.cpp \
175		source/instruction.cpp \
176		source/name_mapper.cpp \
177		source/opcode.cpp \
178		source/operand.cpp \
179		source/print.cpp \
180		source/software_version.cpp \
181		source/spirv_endian.cpp \
182		source/spirv_target_env.cpp \
183		source/table.cpp \
184		source/text.cpp \
185		source/text_handler.cpp \
186		source/val/BasicBlock.cpp \
187		source/val/Construct.cpp \
188		source/val/Function.cpp \
189		source/val/ValidationState.cpp \
190		source/validate_cfg.cpp \
191		source/validate.cpp \
192		source/validate_id.cpp \
193		source/validate_instruction.cpp \
194		source/validate_layout.cpp \
195		source/validate_ssa.cpp
196include $(BUILD_STATIC_LIBRARY)
197