xref: /aosp_15_r20/external/swiftshader/third_party/SPIRV-Tools/Android.bp (revision 03ce13f70fcc45d86ee91b7ee4cab1936a95046e)
1*03ce13f7SAndroid Build Coastguard Worker//
2*03ce13f7SAndroid Build Coastguard Worker// Copyright (C) 2018 The Android Open Source Project
3*03ce13f7SAndroid Build Coastguard Worker//
4*03ce13f7SAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License");
5*03ce13f7SAndroid Build Coastguard Worker// you may not use this file except in compliance with the License.
6*03ce13f7SAndroid Build Coastguard Worker// You may obtain a copy of the License at
7*03ce13f7SAndroid Build Coastguard Worker//
8*03ce13f7SAndroid Build Coastguard Worker//      http://www.apache.org/licenses/LICENSE-2.0
9*03ce13f7SAndroid Build Coastguard Worker//
10*03ce13f7SAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software
11*03ce13f7SAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS,
12*03ce13f7SAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*03ce13f7SAndroid Build Coastguard Worker// See the License for the specific language governing permissions and
14*03ce13f7SAndroid Build Coastguard Worker// limitations under the License.
15*03ce13f7SAndroid Build Coastguard Worker//
16*03ce13f7SAndroid Build Coastguard Worker
17*03ce13f7SAndroid Build Coastguard Worker// SPIRV Tools
18*03ce13f7SAndroid Build Coastguard Worker
19*03ce13f7SAndroid Build Coastguard Worker// genrules were obtained from the CMake build:
20*03ce13f7SAndroid Build Coastguard Worker// $ cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug
21*03ce13f7SAndroid Build Coastguard Worker// $ ninja -v -j 1 >log.log
22*03ce13f7SAndroid Build Coastguard Worker// Find Python invocations.
23*03ce13f7SAndroid Build Coastguard Worker// Use regex replacements to get "cmd:" lines below.
24*03ce13f7SAndroid Build Coastguard Worker
25*03ce13f7SAndroid Build Coastguard Workerpackage {
26*03ce13f7SAndroid Build Coastguard Worker    default_applicable_licenses: [
27*03ce13f7SAndroid Build Coastguard Worker        "external_swiftshader_third_party_SPIRV-Tools_license",
28*03ce13f7SAndroid Build Coastguard Worker    ],
29*03ce13f7SAndroid Build Coastguard Worker}
30*03ce13f7SAndroid Build Coastguard Worker
31*03ce13f7SAndroid Build Coastguard Worker// Added automatically by a large-scale-change that took the approach of
32*03ce13f7SAndroid Build Coastguard Worker// 'apply every license found to every target'. While this makes sure we respect
33*03ce13f7SAndroid Build Coastguard Worker// every license restriction, it may not be entirely correct.
34*03ce13f7SAndroid Build Coastguard Worker//
35*03ce13f7SAndroid Build Coastguard Worker// e.g. GPL in an MIT project might only apply to the contrib/ directory.
36*03ce13f7SAndroid Build Coastguard Worker//
37*03ce13f7SAndroid Build Coastguard Worker// Please consider splitting the single license below into multiple licenses,
38*03ce13f7SAndroid Build Coastguard Worker// taking care not to lose any license_kind information, and overriding the
39*03ce13f7SAndroid Build Coastguard Worker// default license using the 'licenses: [...]' property on targets as needed.
40*03ce13f7SAndroid Build Coastguard Worker//
41*03ce13f7SAndroid Build Coastguard Worker// For unused files, consider creating a 'filegroup' with "//visibility:private"
42*03ce13f7SAndroid Build Coastguard Worker// to attach the license to, and including a comment whether the files may be
43*03ce13f7SAndroid Build Coastguard Worker// used in the current project.
44*03ce13f7SAndroid Build Coastguard Worker// http://go/android-license-faq
45*03ce13f7SAndroid Build Coastguard Workerlicense {
46*03ce13f7SAndroid Build Coastguard Worker    name: "external_swiftshader_third_party_SPIRV-Tools_license",
47*03ce13f7SAndroid Build Coastguard Worker    visibility: [":__subpackages__"],
48*03ce13f7SAndroid Build Coastguard Worker    license_kinds: [
49*03ce13f7SAndroid Build Coastguard Worker        "SPDX-license-identifier-Apache-2.0",
50*03ce13f7SAndroid Build Coastguard Worker        "SPDX-license-identifier-BSD",
51*03ce13f7SAndroid Build Coastguard Worker        "SPDX-license-identifier-MIT",
52*03ce13f7SAndroid Build Coastguard Worker    ],
53*03ce13f7SAndroid Build Coastguard Worker    license_text: [
54*03ce13f7SAndroid Build Coastguard Worker        "LICENSE",
55*03ce13f7SAndroid Build Coastguard Worker    ],
56*03ce13f7SAndroid Build Coastguard Worker}
57*03ce13f7SAndroid Build Coastguard Worker
58*03ce13f7SAndroid Build Coastguard Workergenrule {
59*03ce13f7SAndroid Build Coastguard Worker    name: "swiftshader_spvtools_generate_grammar_tables",
60*03ce13f7SAndroid Build Coastguard Worker    out: [
61*03ce13f7SAndroid Build Coastguard Worker        "core.insts-unified1.inc",
62*03ce13f7SAndroid Build Coastguard Worker        "debuginfo.insts.inc",
63*03ce13f7SAndroid Build Coastguard Worker        "enum_string_mapping.inc",
64*03ce13f7SAndroid Build Coastguard Worker        "extension_enum.inc",
65*03ce13f7SAndroid Build Coastguard Worker        "glsl.std.450.insts.inc",
66*03ce13f7SAndroid Build Coastguard Worker        "opencl.debuginfo.100.insts.inc",
67*03ce13f7SAndroid Build Coastguard Worker        "opencl.std.insts.inc",
68*03ce13f7SAndroid Build Coastguard Worker        "operand.kinds-unified1.inc",
69*03ce13f7SAndroid Build Coastguard Worker        "spv-amd-gcn-shader.insts.inc",
70*03ce13f7SAndroid Build Coastguard Worker        "spv-amd-shader-ballot.insts.inc",
71*03ce13f7SAndroid Build Coastguard Worker        "spv-amd-shader-explicit-vertex-parameter.insts.inc",
72*03ce13f7SAndroid Build Coastguard Worker        "spv-amd-shader-trinary-minmax.insts.inc",
73*03ce13f7SAndroid Build Coastguard Worker        "nonsemantic.clspvreflection.insts.inc",
74*03ce13f7SAndroid Build Coastguard Worker        "nonsemantic.vkspreflection.insts.inc",
75*03ce13f7SAndroid Build Coastguard Worker        "nonsemantic.shader.debuginfo.100.insts.inc",
76*03ce13f7SAndroid Build Coastguard Worker    ],
77*03ce13f7SAndroid Build Coastguard Worker    srcs: [
78*03ce13f7SAndroid Build Coastguard Worker        ":swiftshader_spirv_headers_unified1_extinst.glsl.std.450.grammar.json",
79*03ce13f7SAndroid Build Coastguard Worker        ":swiftshader_spirv_headers_unified1_extinst.opencl.std.100.grammar.json",
80*03ce13f7SAndroid Build Coastguard Worker        ":swiftshader_spirv_headers_unified1_spirv.core.grammar.json",
81*03ce13f7SAndroid Build Coastguard Worker        ":swiftshader_spirv_headers_unified1_extinst.debuginfo.grammar.json",
82*03ce13f7SAndroid Build Coastguard Worker        ":swiftshader_spirv_headers_unified1_extinst.opencl.debuginfo.100.grammar.json",
83*03ce13f7SAndroid Build Coastguard Worker        ":swiftshader_spirv_headers_unified1_extinst.spv-amd-gcn-shader.grammar.json",
84*03ce13f7SAndroid Build Coastguard Worker        ":swiftshader_spirv_headers_unified1_extinst.spv-amd-shader-ballot.grammar.json",
85*03ce13f7SAndroid Build Coastguard Worker        ":swiftshader_spirv_headers_unified1_extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json",
86*03ce13f7SAndroid Build Coastguard Worker        ":swiftshader_spirv_headers_unified1_extinst.spv-amd-shader-trinary-minmax.grammar.json",
87*03ce13f7SAndroid Build Coastguard Worker        ":swiftshader_spirv_headers_unified1_extinst.nonsemantic.clspvreflection.grammar.json",
88*03ce13f7SAndroid Build Coastguard Worker        ":swiftshader_spirv_headers_unified1_extinst.nonsemantic.vkspreflection.grammar.json",
89*03ce13f7SAndroid Build Coastguard Worker        ":swiftshader_spirv_headers_unified1_extinst.nonsemantic.shader.debuginfo.100.grammar.json",
90*03ce13f7SAndroid Build Coastguard Worker    ],
91*03ce13f7SAndroid Build Coastguard Worker    tool_files: ["utils/generate_grammar_tables.py"],
92*03ce13f7SAndroid Build Coastguard Worker    cmd:
93*03ce13f7SAndroid Build Coastguard Worker        "$(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*03ce13f7SAndroid Build Coastguard Worker        "$(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*03ce13f7SAndroid Build Coastguard Worker        "$(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*03ce13f7SAndroid Build Coastguard Worker        "$(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*03ce13f7SAndroid Build Coastguard Worker        "$(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*03ce13f7SAndroid Build Coastguard Worker        "$(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*03ce13f7SAndroid Build Coastguard Worker        "$(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*03ce13f7SAndroid Build Coastguard Worker        "$(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*03ce13f7SAndroid Build Coastguard Worker        "$(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*03ce13f7SAndroid Build Coastguard Worker        "$(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*03ce13f7SAndroid Build Coastguard Worker        "$(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*03ce13f7SAndroid Build Coastguard Worker        "$(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*03ce13f7SAndroid Build Coastguard Worker        "$(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*03ce13f7SAndroid Build Coastguard Worker}
107*03ce13f7SAndroid Build Coastguard Worker
108*03ce13f7SAndroid Build Coastguard Workergenrule {
109*03ce13f7SAndroid Build Coastguard Worker    name: "swiftshader_spvtools_generate_registry_tables",
110*03ce13f7SAndroid Build Coastguard Worker    out: [
111*03ce13f7SAndroid Build Coastguard Worker        "generators.inc"
112*03ce13f7SAndroid Build Coastguard Worker    ],
113*03ce13f7SAndroid Build Coastguard Worker    srcs: [
114*03ce13f7SAndroid Build Coastguard Worker        ":swiftshader_spirv_headers_spir-v.xml"
115*03ce13f7SAndroid Build Coastguard Worker    ],
116*03ce13f7SAndroid Build Coastguard Worker    tool_files: ["utils/generate_registry_tables.py"],
117*03ce13f7SAndroid Build Coastguard Worker    cmd: "$(location) --xml=$(location :swiftshader_spirv_headers_spir-v.xml) --generator-output=$(location generators.inc)",
118*03ce13f7SAndroid Build Coastguard Worker}
119*03ce13f7SAndroid Build Coastguard Worker
120*03ce13f7SAndroid Build Coastguard Workergenrule { // FIXME this relies on `git` which is no good on build machines
121*03ce13f7SAndroid Build Coastguard Worker    name: "swiftshader_spvtools_update_build_version",
122*03ce13f7SAndroid Build Coastguard Worker    out: ["build-version.inc"],
123*03ce13f7SAndroid Build Coastguard Worker    srcs: ["CHANGES"],
124*03ce13f7SAndroid Build Coastguard Worker    tool_files: ["utils/update_build_version.py"],
125*03ce13f7SAndroid Build Coastguard Worker    cmd: "$(location) $(location CHANGES) " +
126*03ce13f7SAndroid Build Coastguard Worker         "$(location build-version.inc)",
127*03ce13f7SAndroid Build Coastguard Worker}
128*03ce13f7SAndroid Build Coastguard Worker
129*03ce13f7SAndroid Build Coastguard Workercc_library_static {
130*03ce13f7SAndroid Build Coastguard Worker    name: "swiftshader_spirv-tools",
131*03ce13f7SAndroid Build Coastguard Worker    host_supported: true,
132*03ce13f7SAndroid Build Coastguard Worker    vendor_available: true,
133*03ce13f7SAndroid Build Coastguard Worker    srcs: [
134*03ce13f7SAndroid Build Coastguard Worker        "source/*.cpp",
135*03ce13f7SAndroid Build Coastguard Worker        "source/util/*.cpp",
136*03ce13f7SAndroid Build Coastguard Worker        "source/val/*.cpp",
137*03ce13f7SAndroid Build Coastguard Worker        "source/opt/*.cpp",
138*03ce13f7SAndroid Build Coastguard Worker    ],
139*03ce13f7SAndroid Build Coastguard Worker    local_include_dirs: [
140*03ce13f7SAndroid Build Coastguard Worker        "source",
141*03ce13f7SAndroid Build Coastguard Worker    ],
142*03ce13f7SAndroid Build Coastguard Worker    export_include_dirs: [
143*03ce13f7SAndroid Build Coastguard Worker        "include",
144*03ce13f7SAndroid Build Coastguard Worker    ],
145*03ce13f7SAndroid Build Coastguard Worker    include_dirs: [
146*03ce13f7SAndroid Build Coastguard Worker        "external/swiftshader/third_party/SPIRV-Headers/include/",
147*03ce13f7SAndroid Build Coastguard Worker        "external/swiftshader/third_party/SPIRV-Headers/include/spirv/unified1/",
148*03ce13f7SAndroid Build Coastguard Worker    ],
149*03ce13f7SAndroid Build Coastguard Worker    generated_headers: [
150*03ce13f7SAndroid Build Coastguard Worker        "swiftshader_spvtools_generate_grammar_tables",
151*03ce13f7SAndroid Build Coastguard Worker        "swiftshader_spvtools_update_build_version",
152*03ce13f7SAndroid Build Coastguard Worker        "swiftshader_spvtools_generate_registry_tables",
153*03ce13f7SAndroid Build Coastguard Worker    ],
154*03ce13f7SAndroid Build Coastguard Worker    stl: "libc++_static",
155*03ce13f7SAndroid Build Coastguard Worker    cppflags: [
156*03ce13f7SAndroid Build Coastguard Worker        "-Wno-implicit-fallthrough"
157*03ce13f7SAndroid Build Coastguard Worker    ],
158*03ce13f7SAndroid Build Coastguard Worker}
159