xref: /aosp_15_r20/external/mesa3d/src/compiler/spirv/Android.bp (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1/*
2 * Copyright (C) 2024 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
17package {
18    // See: http://go/android-license-faq
19    default_applicable_licenses: ["external_mesa3d_license"],
20}
21
22filegroup {
23    name: "mesa_spirv_grammar",
24    srcs: ["spirv.core.grammar.json"],
25}
26
27filegroup {
28    name: "mesa_spirv_xml",
29    srcs: ["spir-v.xml"],
30}
31
32python_binary_host {
33    name: "vtn_gather_types_gen",
34    main: "vtn_gather_types_c.py",
35    srcs: ["vtn_gather_types_c.py"],
36    libs: [
37        "mako",
38    ],
39}
40
41python_binary_host {
42    name: "spirv_info_gen",
43    main: "spirv_info_gen.py",
44    srcs: ["spirv_info_gen.py"],
45    libs: [
46        "mako",
47    ],
48}
49
50python_binary_host {
51    name: "vtn_generator_ids_gen",
52    main: "vtn_generator_ids_h.py",
53    srcs: ["vtn_generator_ids_h.py"],
54    libs: [
55        "mako",
56    ],
57}
58
59genrule {
60    name: "vtn_gather_types_impl",
61    srcs: [":mesa_spirv_grammar"],
62    out: ["vtn_gather_types.c"],
63    tools: ["vtn_gather_types_gen"],
64    cmd: "python3 $(location vtn_gather_types_gen) " +
65        "$(location :mesa_spirv_grammar) " +
66        "$(location vtn_gather_types.c)",
67}
68
69genrule {
70    name: "spirv_info_header",
71    srcs: [":mesa_spirv_grammar"],
72    out: ["src/compiler/spirv/spirv_info.h"],
73    tools: ["spirv_info_gen"],
74    export_include_dirs: [
75        "src/compiler/spirv",
76        "src/",
77    ],
78    cmd: "python3 $(location spirv_info_gen) " +
79        "--json $(location :mesa_spirv_grammar) " +
80        "--out-h $(location src/compiler/spirv/spirv_info.h) " +
81        "--out-c $(genDir)/placeholder.c",
82}
83
84genrule {
85    name: "spirv_info_impl",
86    srcs: [":mesa_spirv_grammar"],
87    out: ["spirv_info.c"],
88    tools: ["spirv_info_gen"],
89    cmd: "python3 $(location spirv_info_gen) " +
90        "--json $(location :mesa_spirv_grammar) " +
91        "--out-h $(genDir)/placeholder.h " +
92        "--out-c $(location spirv_info.c)",
93}
94
95genrule {
96    name: "vtn_generator_ids_header",
97    srcs: [":mesa_spirv_xml"],
98    out: ["vtn_generator_ids.h"],
99    tools: ["vtn_generator_ids_gen"],
100    cmd: "python3 $(location vtn_generator_ids_gen) " +
101        "$(location :mesa_spirv_xml) " +
102        "$(location vtn_generator_ids.h)",
103}
104
105cc_library_static {
106    name: "mesa_spirv",
107    vendor: true,
108    host_supported: true,
109    defaults: [
110        "mesa_common_defaults",
111    ],
112    generated_headers: [
113        "vtn_generator_ids_header",
114        "nir_builder_opcodes_header",
115        "nir_opcodes_header",
116        "nir_intrinsics_header",
117        "nir_intrinsics_indices_header",
118        "spirv_info_header",
119        "u_format_gen_header",
120        "builtin_types_header",
121    ],
122    header_libs: [
123        "mesa_gallium_auxiliary_headers",
124        "mesa_gallium_headers",
125        "mesa_src_headers",
126        "mesa_compiler_headers",
127        "mesa_nir_headers",
128        "mesa_common_headers",
129    ],
130    generated_sources: [
131        "spirv_info_impl",
132        "vtn_gather_types_impl",
133    ],
134    srcs: [
135        "spirv_to_nir.c",
136        "vtn_alu.c",
137        "vtn_amd.c",
138        "vtn_cfg.c",
139        "vtn_glsl450.c",
140        "vtn_opencl.c",
141        "vtn_subgroup.c",
142        "vtn_variables.c",
143    ],
144}
145