Merge commit '20b122b2e0d43fcc322a383354d1a3f4514e3757' into master

Conflicts:
 Android.mk

Bug: b/201652781
Change-Id: I913b4e06834a953ffc60487fd61ffc56ebf5aff2
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..8aeedaa
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,150 @@
+
+package {
+    default_applicable_licenses: ["external_deqp-deps_SPIRV-Tools_license"],
+}
+
+// Added automatically by a large-scale-change that took the approach of
+// 'apply every license found to every target'. While this makes sure we respect
+// every license restriction, it may not be entirely correct.
+//
+// e.g. GPL in an MIT project might only apply to the contrib/ directory.
+//
+// Please consider splitting the single license below into multiple licenses,
+// taking care not to lose any license_kind information, and overriding the
+// default license using the 'licenses: [...]' property on targets as needed.
+//
+// For unused files, consider creating a 'fileGroup' with "//visibility:private"
+// to attach the license to, and including a comment whether the files may be
+// used in the current project.
+// See: http://go/android-license-faq
+license {
+    name: "external_deqp-deps_SPIRV-Tools_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-Apache-2.0",
+        "SPDX-license-identifier-BSD",
+        "SPDX-license-identifier-MIT",
+    ],
+    license_text: [
+        "LICENSE",
+    ],
+}
+
+genrule {
+    name: "deqp_spvtools_generate_grammar_tables",
+    out: [
+        "core.insts-unified1.inc",
+        "debuginfo.insts.inc",
+        "enum_string_mapping.inc",
+        "extension_enum.inc",
+        "glsl.std.450.insts.inc",
+        "nonsemantic.clspvreflection.insts.inc",
+        "nonsemantic.vulkan.debuginfo.100.insts.inc",
+        "opencl.debuginfo.100.insts.inc",
+        "opencl.std.insts.inc",
+        "operand.kinds-unified1.inc",
+        "spv-amd-gcn-shader.insts.inc",
+        "spv-amd-shader-ballot.insts.inc",
+        "spv-amd-shader-explicit-vertex-parameter.insts.inc",
+        "spv-amd-shader-trinary-minmax.insts.inc",
+    ],
+    srcs: [
+        ":deqp_spirv_headers_unified1_extinst.debuginfo.grammar.json",
+        ":deqp_spirv_headers_unified1_extinst.glsl.std.450.grammar.json",
+        ":deqp_spirv_headers_unified1_extinst.nonsemantic.clspvreflection.grammar.json",
+        ":deqp_spirv_headers_unified1_extinst.opencl.debuginfo.100.grammar.json",
+        ":deqp_spirv_headers_unified1_extinst.opencl.std.100.grammar.json",
+        ":deqp_spirv_headers_unified1_extinst.spv-amd-gcn-shader.grammar.json",
+        ":deqp_spirv_headers_unified1_extinst.spv-amd-shader-ballot.grammar.json",
+        ":deqp_spirv_headers_unified1_extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json",
+        ":deqp_spirv_headers_unified1_extinst.spv-amd-shader-trinary-minmax.grammar.json",
+        ":deqp_spirv_headers_unified1_spirv.core.grammar.json",
+        "source/extinst.nonsemantic.vulkan.debuginfo.100.grammar.json",
+    ],
+    tool_files: ["utils/generate_grammar_tables.py"],
+    cmd:
+        "$(location) --extinst-vendor-grammar=$(location :deqp_spirv_headers_unified1_extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json) --vendor-insts-output=$(location spv-amd-shader-explicit-vertex-parameter.insts.inc) --vendor-operand-kind-prefix=; "+
+        "$(location) --extinst-vendor-grammar=$(location :deqp_spirv_headers_unified1_extinst.spv-amd-gcn-shader.grammar.json) --vendor-insts-output=$(location spv-amd-gcn-shader.insts.inc) --vendor-operand-kind-prefix=; "+
+        "$(location) --extinst-vendor-grammar=$(location :deqp_spirv_headers_unified1_extinst.spv-amd-shader-trinary-minmax.grammar.json) --vendor-insts-output=$(location spv-amd-shader-trinary-minmax.insts.inc) --vendor-operand-kind-prefix=; "+
+        "$(location) --extinst-vendor-grammar=$(location :deqp_spirv_headers_unified1_extinst.debuginfo.grammar.json) --vendor-insts-output=$(location debuginfo.insts.inc) --vendor-operand-kind-prefix=; "+
+        "$(location) --extinst-vendor-grammar=$(location :deqp_spirv_headers_unified1_extinst.spv-amd-shader-ballot.grammar.json) --vendor-insts-output=$(location spv-amd-shader-ballot.insts.inc) --vendor-operand-kind-prefix=; "+
+        "$(location) --extinst-vendor-grammar=$(location :deqp_spirv_headers_unified1_extinst.opencl.debuginfo.100.grammar.json) --vendor-insts-output=$(location opencl.debuginfo.100.insts.inc) --vendor-operand-kind-prefix=CLDEBUG100_; "+
+        "$(location) --extinst-vendor-grammar=$(location source/extinst.nonsemantic.vulkan.debuginfo.100.grammar.json) --vendor-insts-output=$(location nonsemantic.vulkan.debuginfo.100.insts.inc) --vendor-operand-kind-prefix=VKDEBUG100_; "+
+        "$(location) --extinst-vendor-grammar=$(location :deqp_spirv_headers_unified1_extinst.nonsemantic.clspvreflection.grammar.json) --vendor-insts-output=$(location nonsemantic.clspvreflection.insts.inc) --vendor-operand-kind-prefix=; "+
+        "$(location) --extinst-opencl-grammar=$(location :deqp_spirv_headers_unified1_extinst.opencl.std.100.grammar.json) --opencl-insts-output=$(location opencl.std.insts.inc); "+
+        "$(location) --extinst-glsl-grammar=$(location :deqp_spirv_headers_unified1_extinst.glsl.std.450.grammar.json) --glsl-insts-output=$(location glsl.std.450.insts.inc); "+
+        "$(location) --spirv-core-grammar=$(location :deqp_spirv_headers_unified1_spirv.core.grammar.json) --extinst-debuginfo-grammar=$(location :deqp_spirv_headers_unified1_extinst.debuginfo.grammar.json) --extinst-cldebuginfo100-grammar=$(location :deqp_spirv_headers_unified1_extinst.opencl.debuginfo.100.grammar.json) --core-insts-output=$(location core.insts-unified1.inc) --operand-kinds-output=$(location operand.kinds-unified1.inc); "+
+        "$(location) --spirv-core-grammar=$(location :deqp_spirv_headers_unified1_spirv.core.grammar.json) --extinst-debuginfo-grammar=$(location :deqp_spirv_headers_unified1_extinst.debuginfo.grammar.json) --extinst-cldebuginfo100-grammar=$(location :deqp_spirv_headers_unified1_extinst.opencl.debuginfo.100.grammar.json) --extension-enum-output=$(location extension_enum.inc) --enum-string-mapping-output=$(location enum_string_mapping.inc); "
+}
+
+
+genrule {
+    name: "deqp_spvtools_generate_language_headers",
+    out: [
+        "DebugInfo.h",
+        "OpenCLDebugInfo100.h",
+        "NonSemanticVulkanDebugInfo100.h",
+    ],
+    srcs: [
+        ":deqp_spirv_headers_unified1_extinst.debuginfo.grammar.json",
+        ":deqp_spirv_headers_unified1_extinst.opencl.debuginfo.100.grammar.json",
+        "source/extinst.nonsemantic.vulkan.debuginfo.100.grammar.json",
+    ],
+    tool_files: ["utils/generate_language_headers.py"],
+    cmd: 
+        "$(location) --extinst-grammar=$(location :deqp_spirv_headers_unified1_extinst.debuginfo.grammar.json) --extinst-output-path=$(location DebugInfo.h); "+
+        "$(location) --extinst-grammar=$(location :deqp_spirv_headers_unified1_extinst.opencl.debuginfo.100.grammar.json) --extinst-output-path=$(location OpenCLDebugInfo100.h); "+
+        "$(location) --extinst-grammar=$(location source/extinst.nonsemantic.vulkan.debuginfo.100.grammar.json) --extinst-output-path=$(location NonSemanticVulkanDebugInfo100.h); "
+}
+
+genrule {
+    name: "deqp_spvtools_generate_registry_tables",
+    out: [
+        "generators.inc"
+    ],
+    srcs: [
+        ":deqp_spirv_headers_spir-v.xml"
+    ],
+    tool_files: ["utils/generate_registry_tables.py"],
+    cmd: "$(location) --xml=$(location :deqp_spirv_headers_spir-v.xml) --generator-output=$(location generators.inc)",
+}
+
+genrule { // FIXME this relies on `git` which is no good on build machines
+    name: "deqp_spvtools_update_build_version",
+    out: ["build-version.inc"],
+    srcs: ["CHANGES"],
+    tool_files: ["utils/update_build_version.py"],
+    cmd: "$(location) $$(dirname $(location CHANGES)) " +
+         "$(location build-version.inc)",
+}
+
+cc_library {
+    name: "deqp_spirv-tools",
+    defaults: ["deqp_and_deps_defaults"],
+    srcs: [
+        "source/*.cpp",
+        "source/util/*.cpp",
+        "source/val/*.cpp",
+        "source/opt/*.cpp",
+    ],
+    local_include_dirs: [
+        ".",
+    ],
+    export_include_dirs: [
+        "include",
+    ],
+    include_dirs: [
+        "external/deqp-deps/SPIRV-Headers/include"
+    ],
+    generated_headers: [
+        "deqp_spvtools_generate_grammar_tables",
+        "deqp_spvtools_generate_language_headers",
+        "deqp_spvtools_update_build_version",
+        "deqp_spvtools_generate_registry_tables",
+    ],
+    cppflags: [
+        "-Wno-implicit-fallthrough",
+        "-Wno-sign-conversion",
+        "-Wno-switch",
+    ],
+}
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index 2aee928..0000000
--- a/Android.mk
+++ /dev/null
@@ -1,344 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-SPVTOOLS_OUT_PATH=$(if $(call host-path-is-absolute,$(TARGET_OUT)),$(TARGET_OUT),$(abspath $(TARGET_OUT)))
-
-ifeq ($(SPVHEADERS_LOCAL_PATH),)
-	SPVHEADERS_LOCAL_PATH := $(LOCAL_PATH)/external/spirv-headers
-endif
-
-SPVTOOLS_SRC_FILES := \
-		source/assembly_grammar.cpp \
-		source/binary.cpp \
-		source/diagnostic.cpp \
-		source/disassemble.cpp \
-		source/ext_inst.cpp \
-		source/enum_string_mapping.cpp \
-		source/extensions.cpp \
-		source/libspirv.cpp \
-		source/name_mapper.cpp \
-		source/opcode.cpp \
-		source/operand.cpp \
-		source/parsed_operand.cpp \
-		source/print.cpp \
-		source/software_version.cpp \
-		source/spirv_endian.cpp \
-		source/spirv_optimizer_options.cpp \
-		source/spirv_target_env.cpp \
-		source/spirv_validator_options.cpp \
-		source/table.cpp \
-		source/text.cpp \
-		source/text_handler.cpp \
-		source/util/bit_vector.cpp \
-		source/util/parse_number.cpp \
-		source/util/string_utils.cpp \
-		source/util/timer.cpp \
-		source/val/basic_block.cpp \
-		source/val/construct.cpp \
-		source/val/function.cpp \
-		source/val/instruction.cpp \
-		source/val/validation_state.cpp \
-		source/val/validate.cpp \
-		source/val/validate_adjacency.cpp \
-		source/val/validate_annotation.cpp \
-		source/val/validate_arithmetics.cpp \
-		source/val/validate_atomics.cpp \
-		source/val/validate_barriers.cpp \
-		source/val/validate_bitwise.cpp \
-		source/val/validate_builtins.cpp \
-		source/val/validate_capability.cpp \
-		source/val/validate_cfg.cpp \
-		source/val/validate_composites.cpp \
-		source/val/validate_constants.cpp \
-		source/val/validate_conversion.cpp \
-		source/val/validate_debug.cpp \
-		source/val/validate_decorations.cpp \
-		source/val/validate_derivatives.cpp \
-		source/val/validate_extensions.cpp \
-		source/val/validate_execution_limitations.cpp \
-		source/val/validate_function.cpp \
-		source/val/validate_id.cpp \
-		source/val/validate_image.cpp \
-		source/val/validate_interfaces.cpp \
-		source/val/validate_instruction.cpp \
-		source/val/validate_memory.cpp \
-		source/val/validate_memory_semantics.cpp \
-		source/val/validate_misc.cpp \
-		source/val/validate_mode_setting.cpp \
-		source/val/validate_layout.cpp \
-		source/val/validate_literals.cpp \
-		source/val/validate_logicals.cpp \
-		source/val/validate_non_uniform.cpp \
-		source/val/validate_primitives.cpp \
-		source/val/validate_scopes.cpp \
-		source/val/validate_small_type_uses.cpp \
-		source/val/validate_type.cpp
-
-SPVTOOLS_OPT_SRC_FILES := \
-		source/opt/aggressive_dead_code_elim_pass.cpp \
-		source/opt/amd_ext_to_khr.cpp \
-		source/opt/basic_block.cpp \
-		source/opt/block_merge_pass.cpp \
-		source/opt/block_merge_util.cpp \
-		source/opt/build_module.cpp \
-		source/opt/cfg.cpp \
-		source/opt/cfg_cleanup_pass.cpp \
-		source/opt/ccp_pass.cpp \
-		source/opt/code_sink.cpp \
-		source/opt/combine_access_chains.cpp \
-		source/opt/compact_ids_pass.cpp \
-		source/opt/composite.cpp \
-		source/opt/const_folding_rules.cpp \
-		source/opt/constants.cpp \
-		source/opt/control_dependence.cpp \
-		source/opt/convert_to_sampled_image_pass.cpp \
-		source/opt/convert_to_half_pass.cpp \
-		source/opt/copy_prop_arrays.cpp \
-		source/opt/dataflow.cpp \
-		source/opt/dead_branch_elim_pass.cpp \
-		source/opt/dead_insert_elim_pass.cpp \
-		source/opt/dead_variable_elimination.cpp \
-		source/opt/decoration_manager.cpp \
-		source/opt/debug_info_manager.cpp \
-		source/opt/def_use_manager.cpp \
-		source/opt/desc_sroa.cpp \
-		source/opt/desc_sroa_util.cpp \
-		source/opt/dominator_analysis.cpp \
-		source/opt/dominator_tree.cpp \
-		source/opt/eliminate_dead_constant_pass.cpp \
-		source/opt/eliminate_dead_functions_pass.cpp \
-		source/opt/eliminate_dead_functions_util.cpp \
-		source/opt/eliminate_dead_members_pass.cpp \
-		source/opt/feature_manager.cpp \
-		source/opt/fix_storage_class.cpp \
-		source/opt/flatten_decoration_pass.cpp \
-		source/opt/fold.cpp \
-		source/opt/folding_rules.cpp \
-		source/opt/fold_spec_constant_op_and_composite_pass.cpp \
-		source/opt/freeze_spec_constant_value_pass.cpp \
-		source/opt/function.cpp \
-		source/opt/graphics_robust_access_pass.cpp \
-		source/opt/if_conversion.cpp \
-		source/opt/inline_pass.cpp \
-		source/opt/inline_exhaustive_pass.cpp \
-		source/opt/inline_opaque_pass.cpp \
-		source/opt/inst_bindless_check_pass.cpp \
-		source/opt/inst_buff_addr_check_pass.cpp \
-		source/opt/inst_debug_printf_pass.cpp \
-		source/opt/instruction.cpp \
-		source/opt/instruction_list.cpp \
-		source/opt/instrument_pass.cpp \
-		source/opt/interp_fixup_pass.cpp \
-		source/opt/ir_context.cpp \
-		source/opt/ir_loader.cpp \
-		source/opt/licm_pass.cpp \
-		source/opt/local_access_chain_convert_pass.cpp \
-		source/opt/local_redundancy_elimination.cpp \
-		source/opt/local_single_block_elim_pass.cpp \
-		source/opt/local_single_store_elim_pass.cpp \
-		source/opt/loop_dependence.cpp \
-		source/opt/loop_dependence_helpers.cpp \
-		source/opt/loop_descriptor.cpp \
-		source/opt/loop_fission.cpp \
-		source/opt/loop_fusion.cpp \
-		source/opt/loop_fusion_pass.cpp \
-		source/opt/loop_peeling.cpp \
-		source/opt/loop_unroller.cpp \
-		source/opt/loop_unswitch_pass.cpp \
-		source/opt/loop_utils.cpp \
-		source/opt/mem_pass.cpp \
-		source/opt/merge_return_pass.cpp \
-		source/opt/module.cpp \
-		source/opt/optimizer.cpp \
-		source/opt/pass.cpp \
-		source/opt/pass_manager.cpp \
-		source/opt/private_to_local_pass.cpp \
-		source/opt/propagator.cpp \
-		source/opt/reduce_load_size.cpp \
-		source/opt/redundancy_elimination.cpp \
-		source/opt/register_pressure.cpp \
-		source/opt/relax_float_ops_pass.cpp \
-		source/opt/remove_duplicates_pass.cpp \
-		source/opt/remove_unused_interface_variables_pass.cpp \
-		source/opt/replace_desc_array_access_using_var_index.cpp \
-		source/opt/replace_invalid_opc.cpp \
-		source/opt/scalar_analysis.cpp \
-		source/opt/scalar_analysis_simplification.cpp \
-		source/opt/scalar_replacement_pass.cpp \
-		source/opt/set_spec_constant_default_value_pass.cpp \
-		source/opt/simplification_pass.cpp \
-		source/opt/spread_volatile_semantics.cpp \
-		source/opt/ssa_rewrite_pass.cpp \
-		source/opt/strength_reduction_pass.cpp \
-		source/opt/strip_debug_info_pass.cpp \
-		source/opt/strip_nonsemantic_info_pass.cpp \
-		source/opt/struct_cfg_analysis.cpp \
-		source/opt/type_manager.cpp \
-		source/opt/types.cpp \
-		source/opt/unify_const_pass.cpp \
-		source/opt/upgrade_memory_model.cpp \
-		source/opt/value_number_table.cpp \
-		source/opt/vector_dce.cpp \
-		source/opt/workaround1209.cpp \
-		source/opt/wrap_opkill.cpp
-
-# Locations of grammar files.
-#
-SPV_COREUNIFIED1_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/spirv.core.grammar.json
-SPV_GLSL_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.glsl.std.450.grammar.json
-SPV_OPENCL_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.opencl.std.100.grammar.json
-SPV_DEBUGINFO_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.debuginfo.grammar.json
-SPV_CLDEBUGINFO100_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json
-SPV_VKDEBUGINFO100_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json
-
-define gen_spvtools_grammar_tables
-$(call generate-file-dir,$(1)/core.insts-unified1.inc)
-$(1)/core.insts-unified1.inc $(1)/operand.kinds-unified1.inc \
-$(1)/glsl.std.450.insts.inc \
-$(1)/opencl.std.insts.inc \
-: \
-        $(LOCAL_PATH)/utils/generate_grammar_tables.py \
-        $(SPV_COREUNIFIED1_GRAMMAR) \
-        $(SPV_GLSL_GRAMMAR) \
-        $(SPV_OpenCL_GRAMMAR) \
-        $(SPV_DEBUGINFO_GRAMMAR) \
-        $(SPV_CLDEBUGINFO100_GRAMMAR)
-		@$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \
-		                --spirv-core-grammar=$(SPV_COREUNIFIED1_GRAMMAR) \
-		                --extinst-glsl-grammar=$(SPV_GLSL_GRAMMAR) \
-		                --extinst-opencl-grammar=$(SPV_OPENCL_GRAMMAR) \
-		                --extinst-debuginfo-grammar=$(SPV_DEBUGINFO_GRAMMAR) \
-		                --extinst-cldebuginfo100-grammar=$(SPV_CLDEBUGINFO100_GRAMMAR) \
-		                --core-insts-output=$(1)/core.insts-unified1.inc \
-		                --glsl-insts-output=$(1)/glsl.std.450.insts.inc \
-		                --opencl-insts-output=$(1)/opencl.std.insts.inc \
-		                --operand-kinds-output=$(1)/operand.kinds-unified1.inc
-		@echo "[$(TARGET_ARCH_ABI)] Grammar (from unified1)  : instructions & operands <= grammar JSON files"
-$(LOCAL_PATH)/source/opcode.cpp: $(1)/core.insts-unified1.inc
-$(LOCAL_PATH)/source/operand.cpp: $(1)/operand.kinds-unified1.inc
-$(LOCAL_PATH)/source/ext_inst.cpp: \
-	$(1)/glsl.std.450.insts.inc \
-	$(1)/opencl.std.insts.inc \
-	$(1)/debuginfo.insts.inc \
-	$(1)/opencl.debuginfo.100.insts.inc \
-	$(1)/nonsemantic.shader.debuginfo.100.insts.inc \
-	$(1)/spv-amd-gcn-shader.insts.inc \
-	$(1)/spv-amd-shader-ballot.insts.inc \
-	$(1)/spv-amd-shader-explicit-vertex-parameter.insts.inc \
-	$(1)/spv-amd-shader-trinary-minmax.insts.inc
-$(LOCAL_PATH)/source/opt/amd_ext_to_khr.cpp: \
-	$(1)/spv-amd-shader-ballot.insts.inc
-endef
-$(eval $(call gen_spvtools_grammar_tables,$(SPVTOOLS_OUT_PATH)))
-
-
-define gen_spvtools_lang_headers
-# Generate language-specific headers.  So far we only generate C headers
-# $1 is the output directory.
-# $2 is the base name of the header file, e.g. "DebugInfo".
-# $3 is the grammar file containing token definitions.
-$(call generate-file-dir,$(1)/$(2).h)
-$(1)/$(2).h : \
-        $(LOCAL_PATH)/utils/generate_language_headers.py \
-        $(3)
-		@$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_language_headers.py \
-		    --extinst-grammar=$(3) \
-		    --extinst-output-path=$(1)/$(2).h
-		@echo "[$(TARGET_ARCH_ABI)] Generate language specific header for $(2): headers <= grammar"
-$(foreach F,$(SPVTOOLS_SRC_FILES) $(SPVTOOLS_OPT_SRC_FILES),$(LOCAL_PATH)/$F ) \
-	: $(1)/$(2).h
-endef
-# We generate language-specific headers for DebugInfo and OpenCL.DebugInfo.100
-$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),DebugInfo,$(SPV_DEBUGINFO_GRAMMAR)))
-$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),OpenCLDebugInfo100,$(SPV_CLDEBUGINFO100_GRAMMAR)))
-$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),NonSemanticShaderDebugInfo100,$(SPV_VKDEBUGINFO100_GRAMMAR)))
-
-
-define gen_spvtools_vendor_tables
-$(call generate-file-dir,$(1)/$(2).insts.inc)
-$(1)/$(2).insts.inc : \
-        $(LOCAL_PATH)/utils/generate_grammar_tables.py \
-        $(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.$(2).grammar.json
-		@$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \
-		    --extinst-vendor-grammar=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.$(2).grammar.json \
-		    --vendor-insts-output=$(1)/$(2).insts.inc \
-		    --vendor-operand-kind-prefix=$(3)
-		@echo "[$(TARGET_ARCH_ABI)] Vendor extended instruction set: $(2) tables <= grammar"
-$(LOCAL_PATH)/source/ext_inst.cpp: $(1)/$(2).insts.inc
-endef
-# Vendor and debug extended instruction sets, with grammars from SPIRV-Tools source tree.
-$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),debuginfo,""))
-$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),opencl.debuginfo.100,"CLDEBUG100_"))
-$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),nonsemantic.shader.debuginfo.100,"SHDEBUG100_"))
-$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-gcn-shader,""))
-$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-ballot,""))
-$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-explicit-vertex-parameter,""))
-$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-trinary-minmax,""))
-$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),nonsemantic.clspvreflection,""))
-
-define gen_spvtools_enum_string_mapping
-$(call generate-file-dir,$(1)/extension_enum.inc.inc)
-$(1)/extension_enum.inc $(1)/enum_string_mapping.inc: \
-        $(LOCAL_PATH)/utils/generate_grammar_tables.py \
-        $(SPV_COREUNIFIED1_GRAMMAR)
-		@$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \
-		                --spirv-core-grammar=$(SPV_COREUNIFIED1_GRAMMAR) \
-		                --extinst-debuginfo-grammar=$(SPV_DEBUGINFO_GRAMMAR) \
-		                --extinst-cldebuginfo100-grammar=$(SPV_CLDEBUGINFO100_GRAMMAR) \
-		                --extension-enum-output=$(1)/extension_enum.inc \
-		                --enum-string-mapping-output=$(1)/enum_string_mapping.inc
-		@echo "[$(TARGET_ARCH_ABI)] Generate enum<->string mapping <= grammar JSON files"
-# Generated header extension_enum.inc is transitively included by table.h, which is
-# used pervasively.  Capture the pervasive dependency.
-$(foreach F,$(SPVTOOLS_SRC_FILES) $(SPVTOOLS_OPT_SRC_FILES),$(LOCAL_PATH)/$F ) \
-  : $(1)/extension_enum.inc
-$(LOCAL_PATH)/source/enum_string_mapping.cpp: $(1)/enum_string_mapping.inc
-endef
-$(eval $(call gen_spvtools_enum_string_mapping,$(SPVTOOLS_OUT_PATH)))
-
-define gen_spvtools_build_version_inc
-$(call generate-file-dir,$(1)/dummy_filename)
-$(1)/build-version.inc: \
-        $(LOCAL_PATH)/utils/update_build_version.py \
-        $(LOCAL_PATH)/CHANGES
-		@$(HOST_PYTHON) $(LOCAL_PATH)/utils/update_build_version.py \
-		                $(LOCAL_PATH) $(1)/build-version.inc
-		@echo "[$(TARGET_ARCH_ABI)] Generate       : build-version.inc <= CHANGES"
-$(LOCAL_PATH)/source/software_version.cpp: $(1)/build-version.inc
-endef
-$(eval $(call gen_spvtools_build_version_inc,$(SPVTOOLS_OUT_PATH)))
-
-define gen_spvtools_generators_inc
-$(call generate-file-dir,$(1)/dummy_filename)
-$(1)/generators.inc: \
-        $(LOCAL_PATH)/utils/generate_registry_tables.py \
-        $(SPVHEADERS_LOCAL_PATH)/include/spirv/spir-v.xml
-		@$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_registry_tables.py \
-		                --xml=$(SPVHEADERS_LOCAL_PATH)/include/spirv/spir-v.xml \
-				--generator-output=$(1)/generators.inc
-		@echo "[$(TARGET_ARCH_ABI)] Generate       : generators.inc <= spir-v.xml"
-$(LOCAL_PATH)/source/opcode.cpp: $(1)/generators.inc
-endef
-$(eval $(call gen_spvtools_generators_inc,$(SPVTOOLS_OUT_PATH)))
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := SPIRV-Tools
-LOCAL_C_INCLUDES := \
-		$(LOCAL_PATH)/include \
-		$(SPVHEADERS_LOCAL_PATH)/include \
-		$(SPVTOOLS_OUT_PATH)
-LOCAL_EXPORT_C_INCLUDES := \
-		$(LOCAL_PATH)/include
-LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti -Werror
-LOCAL_SRC_FILES:= $(SPVTOOLS_SRC_FILES)
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := SPIRV-Tools-opt
-LOCAL_C_INCLUDES := \
-		$(LOCAL_PATH)/include \
-		$(LOCAL_PATH)/source \
-		$(SPVHEADERS_LOCAL_PATH)/include \
-		$(SPVTOOLS_OUT_PATH)
-LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti -Werror
-LOCAL_STATIC_LIBRARIES:=SPIRV-Tools
-LOCAL_SRC_FILES:= $(SPVTOOLS_OPT_SRC_FILES)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/METADATA b/METADATA
new file mode 100644
index 0000000..9da54b2
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,14 @@
+name: "SPIRV-Tools"
+description:
+    "The SPIR-V Tools project provides an API and commands for processing "
+    "SPIR-V modules."
+
+third_party {
+  url {
+    type: GIT
+    value: "https://github.com/KhronosGroup/SPIRV-Tools.git"
+  }
+  version: "eea449a1e82ab6a860b68f9b0a23f0432fe9939f"
+  license_type: NOTICE
+  last_upgrade_date { year: 2018 month: 12 day: 17 }
+}
diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MODULE_LICENSE_APACHE2
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..ca2b824
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1 @@
+include platform/external/deqp:/OWNERS
diff --git a/android_test/Android.mk b/android_test/Android.mk
deleted file mode 100644
index dbaf93b..0000000
--- a/android_test/Android.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc .cpp .cxx
-LOCAL_SRC_FILES:=test.cpp
-LOCAL_MODULE:=spirvtools_test
-LOCAL_LDLIBS:=-landroid
-LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti -Werror
-LOCAL_STATIC_LIBRARIES=SPIRV-Tools SPIRV-Tools-opt
-include $(BUILD_SHARED_LIBRARY)
-
-include $(LOCAL_PATH)/../Android.mk