1// 2// Copyright (C) 2018 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// SPIRV Tools 18 19// genrules were obtained from the CMake build: 20// $ cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug 21// $ ninja -v -j 1 >log.log 22// Find Python invocations. 23// Use regex replacements to get "cmd:" lines below. 24 25genrule { 26 name: "swiftshader_spvtools_generate_grammar_tables", 27 out: [ 28 "core.insts-unified1.inc", 29 "debuginfo.insts.inc", 30 "enum_string_mapping.inc", 31 "extension_enum.inc", 32 "glsl.std.450.insts.inc", 33 "opencl.debuginfo.100.insts.inc", 34 "opencl.std.insts.inc", 35 "operand.kinds-unified1.inc", 36 "spv-amd-gcn-shader.insts.inc", 37 "spv-amd-shader-ballot.insts.inc", 38 "spv-amd-shader-explicit-vertex-parameter.insts.inc", 39 "spv-amd-shader-trinary-minmax.insts.inc", 40 ], 41 srcs: [ 42 ":swiftshader_spirv_headers_unified1_extinst.glsl.std.450.grammar.json", 43 ":swiftshader_spirv_headers_unified1_extinst.opencl.std.100.grammar.json", 44 ":swiftshader_spirv_headers_unified1_spirv.core.grammar.json", 45 "source/extinst.debuginfo.grammar.json", 46 "source/extinst.opencl.debuginfo.100.grammar.json", 47 "source/extinst.spv-amd-gcn-shader.grammar.json", 48 "source/extinst.spv-amd-shader-ballot.grammar.json", 49 "source/extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json", 50 "source/extinst.spv-amd-shader-trinary-minmax.grammar.json", 51 ], 52 tool_files: ["utils/generate_grammar_tables.py"], 53 cmd: 54 "$(location) --extinst-vendor-grammar=$(location source/extinst.spv-amd-gcn-shader.grammar.json) --vendor-insts-output=$(location spv-amd-gcn-shader.insts.inc) --vendor-operand-kind-prefix=; "+ 55 "$(location) --spirv-core-grammar=$(location :swiftshader_spirv_headers_unified1_spirv.core.grammar.json) --extinst-debuginfo-grammar=$(location source/extinst.debuginfo.grammar.json) --extinst-cldebuginfo100-grammar=$(location source/extinst.opencl.debuginfo.100.grammar.json) --core-insts-output=$(location core.insts-unified1.inc) --operand-kinds-output=$(location operand.kinds-unified1.inc); "+ 56 "$(location) --extinst-vendor-grammar=$(location source/extinst.debuginfo.grammar.json) --vendor-insts-output=$(location debuginfo.insts.inc) --vendor-operand-kind-prefix=; "+ 57 "$(location) --extinst-vendor-grammar=$(location source/extinst.spv-amd-shader-ballot.grammar.json) --vendor-insts-output=$(location spv-amd-shader-ballot.insts.inc) --vendor-operand-kind-prefix=; "+ 58 "$(location) --extinst-vendor-grammar=$(location source/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=; "+ 59 "$(location) --extinst-vendor-grammar=$(location source/extinst.spv-amd-shader-trinary-minmax.grammar.json) --vendor-insts-output=$(location spv-amd-shader-trinary-minmax.insts.inc) --vendor-operand-kind-prefix=; "+ 60 "$(location) --extinst-vendor-grammar=$(location source/extinst.opencl.debuginfo.100.grammar.json) --vendor-insts-output=$(location opencl.debuginfo.100.insts.inc) --vendor-operand-kind-prefix=CLDEBUG100_; "+ 61 "$(location) --spirv-core-grammar=$(location :swiftshader_spirv_headers_unified1_spirv.core.grammar.json) --extinst-debuginfo-grammar=$(location source/extinst.debuginfo.grammar.json) --extinst-cldebuginfo100-grammar=$(location source/extinst.opencl.debuginfo.100.grammar.json) --extension-enum-output=$(location extension_enum.inc) --enum-string-mapping-output=$(location enum_string_mapping.inc); "+ 62 "$(location) --extinst-opencl-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.opencl.std.100.grammar.json) --opencl-insts-output=$(location opencl.std.insts.inc); "+ 63 "$(location) --extinst-glsl-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.glsl.std.450.grammar.json) --glsl-insts-output=$(location glsl.std.450.insts.inc); " 64} 65 66 67genrule { 68 name: "swiftshader_spvtools_generate_language_headers", 69 out: [ 70 "DebugInfo.h", 71 "OpenCLDebugInfo100.h", 72 ], 73 srcs: [ 74 "source/extinst.debuginfo.grammar.json", 75 "source/extinst.opencl.debuginfo.100.grammar.json", 76 ], 77 tool_files: ["utils/generate_language_headers.py"], 78 cmd: 79 "$(location) --extinst-name=DebugInfo --extinst-grammar=$(location source/extinst.debuginfo.grammar.json) --extinst-output-base=$$(dirname $(location DebugInfo.h))/DebugInfo; "+ 80 "$(location) --extinst-name=OpenCLDebugInfo100 --extinst-grammar=$(location source/extinst.opencl.debuginfo.100.grammar.json) --extinst-output-base=$$(dirname $(location OpenCLDebugInfo100.h))/OpenCLDebugInfo100; " 81} 82 83genrule { 84 name: "swiftshader_spvtools_generate_registry_tables", 85 out: [ 86 "generators.inc" 87 ], 88 srcs: [ 89 ":swiftshader_spirv_headers_spir-v.xml" 90 ], 91 tool_files: ["utils/generate_registry_tables.py"], 92 cmd: "$(location) --xml=$(location :swiftshader_spirv_headers_spir-v.xml) --generator-output=$(location generators.inc)", 93} 94 95genrule { // FIXME this relies on `git` which is no good on build machines 96 name: "swiftshader_spvtools_update_build_version", 97 out: ["build-version.inc"], 98 srcs: ["CHANGES"], 99 tool_files: ["utils/update_build_version.py"], 100 cmd: "$(location) $$(dirname $(location CHANGES)) " + 101 "$(location build-version.inc)", 102} 103 104cc_library_static { 105 name: "swiftshader_spirv-tools", 106 vendor_available: true, 107 srcs: [ 108 "source/*.cpp", 109 "source/util/*.cpp", 110 "source/val/*.cpp", 111 "source/opt/*.cpp", 112 ], 113 local_include_dirs: [ 114 "source", 115 ], 116 export_include_dirs: [ 117 "include", 118 ], 119 include_dirs: [ 120 "external/swiftshader/third_party/SPIRV-Headers/include" 121 ], 122 generated_headers: [ 123 "swiftshader_spvtools_generate_grammar_tables", 124 "swiftshader_spvtools_generate_language_headers", 125 "swiftshader_spvtools_update_build_version", 126 "swiftshader_spvtools_generate_registry_tables", 127 ], 128 stl: "libc++_static", 129 cppflags: [ 130 "-Wno-implicit-fallthrough" 131 ], 132} 133