xref: /aosp_15_r20/external/swiftshader/third_party/SPIRV-Tools/Android.bp (revision 03ce13f70fcc45d86ee91b7ee4cab1936a95046e)
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
25package {
26    default_applicable_licenses: [
27        "external_swiftshader_third_party_SPIRV-Tools_license",
28    ],
29}
30
31// Added automatically by a large-scale-change that took the approach of
32// 'apply every license found to every target'. While this makes sure we respect
33// every license restriction, it may not be entirely correct.
34//
35// e.g. GPL in an MIT project might only apply to the contrib/ directory.
36//
37// Please consider splitting the single license below into multiple licenses,
38// taking care not to lose any license_kind information, and overriding the
39// default license using the 'licenses: [...]' property on targets as needed.
40//
41// For unused files, consider creating a 'filegroup' with "//visibility:private"
42// to attach the license to, and including a comment whether the files may be
43// used in the current project.
44// http://go/android-license-faq
45license {
46    name: "external_swiftshader_third_party_SPIRV-Tools_license",
47    visibility: [":__subpackages__"],
48    license_kinds: [
49        "SPDX-license-identifier-Apache-2.0",
50        "SPDX-license-identifier-BSD",
51        "SPDX-license-identifier-MIT",
52    ],
53    license_text: [
54        "LICENSE",
55    ],
56}
57
58genrule {
59    name: "swiftshader_spvtools_generate_grammar_tables",
60    out: [
61        "core.insts-unified1.inc",
62        "debuginfo.insts.inc",
63        "enum_string_mapping.inc",
64        "extension_enum.inc",
65        "glsl.std.450.insts.inc",
66        "opencl.debuginfo.100.insts.inc",
67        "opencl.std.insts.inc",
68        "operand.kinds-unified1.inc",
69        "spv-amd-gcn-shader.insts.inc",
70        "spv-amd-shader-ballot.insts.inc",
71        "spv-amd-shader-explicit-vertex-parameter.insts.inc",
72        "spv-amd-shader-trinary-minmax.insts.inc",
73        "nonsemantic.clspvreflection.insts.inc",
74        "nonsemantic.vkspreflection.insts.inc",
75        "nonsemantic.shader.debuginfo.100.insts.inc",
76    ],
77    srcs: [
78        ":swiftshader_spirv_headers_unified1_extinst.glsl.std.450.grammar.json",
79        ":swiftshader_spirv_headers_unified1_extinst.opencl.std.100.grammar.json",
80        ":swiftshader_spirv_headers_unified1_spirv.core.grammar.json",
81        ":swiftshader_spirv_headers_unified1_extinst.debuginfo.grammar.json",
82        ":swiftshader_spirv_headers_unified1_extinst.opencl.debuginfo.100.grammar.json",
83        ":swiftshader_spirv_headers_unified1_extinst.spv-amd-gcn-shader.grammar.json",
84        ":swiftshader_spirv_headers_unified1_extinst.spv-amd-shader-ballot.grammar.json",
85        ":swiftshader_spirv_headers_unified1_extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json",
86        ":swiftshader_spirv_headers_unified1_extinst.spv-amd-shader-trinary-minmax.grammar.json",
87        ":swiftshader_spirv_headers_unified1_extinst.nonsemantic.clspvreflection.grammar.json",
88        ":swiftshader_spirv_headers_unified1_extinst.nonsemantic.vkspreflection.grammar.json",
89        ":swiftshader_spirv_headers_unified1_extinst.nonsemantic.shader.debuginfo.100.grammar.json",
90    ],
91    tool_files: ["utils/generate_grammar_tables.py"],
92    cmd:
93        "$(location) --extinst-vendor-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.spv-amd-gcn-shader.grammar.json) --vendor-insts-output=$(location spv-amd-gcn-shader.insts.inc) --vendor-operand-kind-prefix=; "+
94        "$(location) --spirv-core-grammar=$(location :swiftshader_spirv_headers_unified1_spirv.core.grammar.json) --extinst-debuginfo-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.debuginfo.grammar.json) --extinst-cldebuginfo100-grammar=$(location :swiftshader_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) --output-language=c++; "+
95        "$(location) --extinst-vendor-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.debuginfo.grammar.json) --vendor-insts-output=$(location debuginfo.insts.inc) --vendor-operand-kind-prefix=; "+
96        "$(location) --extinst-vendor-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.spv-amd-shader-ballot.grammar.json) --vendor-insts-output=$(location spv-amd-shader-ballot.insts.inc) --vendor-operand-kind-prefix=; "+
97        "$(location) --extinst-vendor-grammar=$(location :swiftshader_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=; "+
98        "$(location) --extinst-vendor-grammar=$(location :swiftshader_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=; "+
99        "$(location) --extinst-vendor-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.opencl.debuginfo.100.grammar.json) --vendor-insts-output=$(location opencl.debuginfo.100.insts.inc) --vendor-operand-kind-prefix=CLDEBUG100_; "+
100        "$(location) --spirv-core-grammar=$(location :swiftshader_spirv_headers_unified1_spirv.core.grammar.json) --extinst-debuginfo-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.debuginfo.grammar.json) --extinst-cldebuginfo100-grammar=$(location :swiftshader_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) --output-language=c++; "+
101        "$(location) --extinst-opencl-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.opencl.std.100.grammar.json) --opencl-insts-output=$(location opencl.std.insts.inc) --output-language=c++; "+
102        "$(location) --extinst-glsl-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.glsl.std.450.grammar.json) --glsl-insts-output=$(location glsl.std.450.insts.inc) --output-language=c++; " +
103        "$(location) --extinst-vendor-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.nonsemantic.clspvreflection.grammar.json) --vendor-insts-output=$(location nonsemantic.clspvreflection.insts.inc) --vendor-operand-kind-prefix=; " +
104        "$(location) --extinst-vendor-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.nonsemantic.vkspreflection.grammar.json) --vendor-insts-output=$(location nonsemantic.vkspreflection.insts.inc) --vendor-operand-kind-prefix=; " +
105        "$(location) --extinst-vendor-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.nonsemantic.shader.debuginfo.100.grammar.json) --vendor-insts-output=$(location nonsemantic.shader.debuginfo.100.insts.inc) --vendor-operand-kind-prefix=SHDEBUG100_; "
106}
107
108genrule {
109    name: "swiftshader_spvtools_generate_registry_tables",
110    out: [
111        "generators.inc"
112    ],
113    srcs: [
114        ":swiftshader_spirv_headers_spir-v.xml"
115    ],
116    tool_files: ["utils/generate_registry_tables.py"],
117    cmd: "$(location) --xml=$(location :swiftshader_spirv_headers_spir-v.xml) --generator-output=$(location generators.inc)",
118}
119
120genrule { // FIXME this relies on `git` which is no good on build machines
121    name: "swiftshader_spvtools_update_build_version",
122    out: ["build-version.inc"],
123    srcs: ["CHANGES"],
124    tool_files: ["utils/update_build_version.py"],
125    cmd: "$(location) $(location CHANGES) " +
126         "$(location build-version.inc)",
127}
128
129cc_library_static {
130    name: "swiftshader_spirv-tools",
131    host_supported: true,
132    vendor_available: true,
133    srcs: [
134        "source/*.cpp",
135        "source/util/*.cpp",
136        "source/val/*.cpp",
137        "source/opt/*.cpp",
138    ],
139    local_include_dirs: [
140        "source",
141    ],
142    export_include_dirs: [
143        "include",
144    ],
145    include_dirs: [
146        "external/swiftshader/third_party/SPIRV-Headers/include/",
147        "external/swiftshader/third_party/SPIRV-Headers/include/spirv/unified1/",
148    ],
149    generated_headers: [
150        "swiftshader_spvtools_generate_grammar_tables",
151        "swiftshader_spvtools_update_build_version",
152        "swiftshader_spvtools_generate_registry_tables",
153    ],
154    stl: "libc++_static",
155    cppflags: [
156        "-Wno-implicit-fallthrough"
157    ],
158}
159