• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Mesa 3-D graphics library
2//
3// Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
4// Copyright (C) 2010-2011 LunarG Inc.
5//
6// Permission is hereby granted, free of charge, to any person obtaining a
7// copy of this software and associated documentation files (the "Software"),
8// to deal in the Software without restriction, including without limitation
9// the rights to use, copy, modify, merge, publish, distribute, sublicense,
10// and/or sell copies of the Software, and to permit persons to whom the
11// Software is furnished to do so, subject to the following conditions:
12//
13// The above copyright notice and this permission notice shall be included
14// in all copies or substantial portions of the Software.
15//
16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22// DEALINGS IN THE SOFTWARE.
23
24// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS.  PLEASE
25//     CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE
26//     DEPENDING ON IT IN YOUR PROJECT. ***
27
28package {
29    default_applicable_licenses: ["external_mesa3d_license"],
30}
31
32// Added automatically by a large-scale-change that took the approach of
33// 'apply every license found to every target'. While this makes sure we respect
34// every license restriction, it may not be entirely correct.
35//
36// e.g. GPL in an MIT project might only apply to the contrib/ directory.
37//
38// Please consider splitting the single license below into multiple licenses,
39// taking care not to lose any license_kind information, and overriding the
40// default license using the 'licenses: [...]' property on targets as needed.
41//
42// For unused files, consider creating a 'fileGroup' with "//visibility:private"
43// to attach the license to, and including a comment whether the files may be
44// used in the current project.
45// See: http://go/android-license-faq
46license {
47    name: "external_mesa3d_license",
48    visibility: [":__subpackages__"],
49    license_kinds: [
50        "SPDX-license-identifier-Apache-2.0",
51        "SPDX-license-identifier-BSD",
52        "SPDX-license-identifier-BSL-1.0",
53        "SPDX-license-identifier-GPL",
54        "SPDX-license-identifier-GPL-2.0",
55        "SPDX-license-identifier-ISC",
56        "SPDX-license-identifier-MIT",
57        "SPDX-license-identifier-Unlicense",
58        "legacy_by_exception_only", // by exception only
59        "legacy_notice",
60        "legacy_unencumbered",
61    ],
62    license_text: [
63        "LICENSE",
64    ],
65}
66
67cc_defaults {
68    name: "mesa_version_defaults",
69    cflags: ["-DPACKAGE_VERSION=\"24.2\""],
70}
71
72python_binary_host {
73    name: "git_sha1_gen",
74    main: "bin/git_sha1_gen.py",
75    srcs: [
76        "bin/git_sha1_gen.py",
77    ],
78}
79
80genrule {
81    name: "git_sha1_header",
82    out: ["git_sha1.h"],
83    tools: ["git_sha1_gen"],
84    cmd: "MESA_GIT_SHA1_OVERRIDE=(git-l33t9876) python3 $(location git_sha1_gen) " +
85        "--output $(location git_sha1.h)",
86}
87
88cc_defaults {
89    name: "mesa_flagged_defaults",
90    cflags: select(soong_config_variable("gfxstream", "mesa3d_platforms"), {
91        // Android surfaceless build
92        "none": [
93            "-UANDROID",
94            "-U__ANDROID__",
95            "-DLINUX_GUEST_BUILD",
96        ],
97        // The default when variable is not set is Android
98        default: [
99            "-DVK_USE_PLATFORM_ANDROID_KHR",
100        ],
101    }),
102}
103
104cc_library_headers {
105    name: "mesa_common_headers",
106    defaults: ["mesa_flagged_defaults"],
107    vendor_available: true,
108    host_supported: true,
109    export_include_dirs: [
110        "src",
111        "include",
112    ],
113    visibility: [":__subpackages__"],
114}
115
116// This needs to be kept in sync with Android.common.mk
117cc_defaults {
118    name: "mesa_common_defaults",
119    defaults: [
120        "mesa_version_defaults",
121        "mesa_flagged_defaults",
122    ],
123    // uncomment to keep the debug symbols
124    // strip: { none: true, },
125    header_libs: ["mesa_common_headers"],
126    cflags: [
127        "-Wno-error",
128        "-Werror=incompatible-pointer-types",
129        "-Wno-unused-parameter",
130        "-Wno-pointer-arith",
131        "-Wno-missing-field-initializers",
132        "-Wno-initializer-overrides",
133        "-Wno-mismatched-tags",
134        // PACKAGE_VERSION is in mesa_version_defaults
135        "-DPACKAGE_BUGREPORT=\"https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa\"",
136        // XXX: The following __STDC_*_MACROS defines should not be needed.
137        // It's likely due to a bug elsewhere, but let's temporarily add them
138        // here to fix the radeonsi build.
139        "-DENABLE_SHADER_CACHE",
140        "-D__STDC_CONSTANT_MACROS",
141        "-D__STDC_LIMIT_MACROS",
142        "-DHAVE___BUILTIN_EXPECT",
143        "-DHAVE___BUILTIN_FFS",
144        "-DHAVE___BUILTIN_FFSLL",
145        "-DHAVE_DLFCN_H",
146        "-DHAVE_FUNC_ATTRIBUTE_FLATTEN",
147        "-DHAVE_FUNC_ATTRIBUTE_UNUSED",
148        "-DHAVE_FUNC_ATTRIBUTE_FORMAT",
149        "-DHAVE_FUNC_ATTRIBUTE_PACKED",
150        "-DHAVE_FUNC_ATTRIBUTE_ALIAS",
151        "-DHAVE_FUNC_ATTRIBUTE_NORETURN",
152        "-DHAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL",
153        "-DHAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT",
154        "-DHAVE___BUILTIN_CTZ",
155        "-DHAVE___BUILTIN_POPCOUNT",
156        "-DHAVE___BUILTIN_POPCOUNTLL",
157        "-DHAVE___BUILTIN_CLZ",
158        "-DHAVE___BUILTIN_CLZLL",
159        "-DHAVE___BUILTIN_UNREACHABLE",
160        "-DHAVE_PTHREAD=1",
161        "-DHAVE_DLADDR",
162        "-DHAVE_DL_ITERATE_PHDR",
163        "-DHAVE_LINUX_FUTEX_H",
164        "-DHAVE_ENDIAN_H",
165        "-DMAJOR_IN_SYSMACROS",
166        "-DMESA_DEBUG=0",
167        "-fvisibility=hidden",
168        "-fno-math-errno",
169        "-fno-trapping-math",
170        "-Werror",
171        "-Wno-#warnings",
172        "-Wno-asm-operand-widths",
173        "-Wno-cast-calling-convention",
174        "-Wno-constant-logical-operand",
175        "-Wno-enum-conversion",
176        "-Wno-format",
177        "-Wno-gnu-variable-sized-type-not-at-end",
178        "-Wno-implicit-fallthrough",
179        "-Wno-implicit-int",
180        "-Wno-incompatible-pointer-types",
181        "-Wno-missing-braces",
182        "-Wno-overloaded-virtual",
183        "-Wno-self-assign",
184        "-Wno-shift-negative-value",
185        "-Wno-sign-compare",
186        "-Wno-sometimes-uninitialized",
187        "-Wno-switch",
188        "-Wno-typedef-redefinition",
189        "-Wno-uninitialized",
190        "-Wno-implicit-const-int-float-conversion",
191        "-Wno-sync-alignment",
192        "-Wno-implicit-function-declaration",
193        "-Wno-constant-conversion",
194        "-DHAVE_TIMESPEC_GET",
195        "-DHAVE_STRUCT_TIMESPEC",
196        "-DMESA_LLVM_VERSION_STRING=\"16.0.0\"",
197        "-DDRAW_LLVM_AVAILABLE=1",
198        "-DHAVE_LIBDRM",
199        "-DHAVE_COMPRESSION",
200        "-DHAVE_ZSTD",
201    ],
202    c_std: "c11",
203    shared_libs: ["libdrm"],
204    cppflags: [
205        "-D__STDC_CONSTANT_MACROS",
206        "-D__STDC_FORMAT_MACROS",
207        "-D__STDC_LIMIT_MACROS",
208        "-Wno-error=non-virtual-dtor",
209        "-Wno-non-virtual-dtor",
210    ],
211    arch: {
212        arm: {
213            cflags: ["-DNO_FORMAT_ASM"],
214        },
215        arm64: {
216            cflags: ["-DNO_FORMAT_ASM"],
217        },
218    },
219    multilib: {
220        lib32: {
221            cflags: ["-DDEFAULT_DRIVER_DIR=\"/vendor/lib/dri\""],
222        },
223        lib64: {
224            cflags: ["-DDEFAULT_DRIVER_DIR=\"/vendor/lib64/dri\""],
225        },
226    },
227    product_variables: {
228        platform_sdk_version: {
229            cflags: ["-DANDROID_API_LEVEL=%d"],
230        },
231    },
232    target: {
233        host: {
234            cflags: [
235                "-D_GNU_SOURCE",
236                "-DHAVE_SECURE_GETENV",
237            ],
238        },
239        android: {
240            cflags: [
241                "-DHAVE_REALLOCARRAY",
242            ],
243        },
244        linux_musl: {
245            cflags: [
246                "-DHAVE_REALLOCARRAY",
247            ],
248        },
249    },
250}
251