chore: refresco desde el monorepo (pin tawasuyu.git v0.2.0)
1#![allow(clippy::disallowed_macros)]
2#[cfg(any(feature = "backend_egl", feature = "renderer_gl"))]
3fn gl_generate() {
4 use gl_generator::{Api, Fallbacks, Profile, Registry};
5 use std::{env, fs::File, path::PathBuf};
6
7 let dest = PathBuf::from(&env::var("OUT_DIR").unwrap());
8
9 if env::var_os("CARGO_FEATURE_BACKEND_EGL").is_some() {
10 let mut file = File::create(dest.join("egl_bindings.rs")).unwrap();
11 Registry::new(
12 Api::Egl,
13 (1, 5),
14 Profile::Core,
15 Fallbacks::All,
16 [
17 "EGL_KHR_create_context",
18 "EGL_EXT_create_context_robustness",
19 "EGL_KHR_create_context_no_error",
20 "EGL_KHR_no_config_context",
21 "EGL_EXT_pixel_format_float",
22 "EGL_EXT_device_base",
23 "EGL_EXT_device_enumeration",
24 "EGL_EXT_device_query",
25 "EGL_EXT_device_drm",
26 "EGL_EXT_device_drm_render_node",
27 "EGL_KHR_stream",
28 "EGL_KHR_stream_producer_eglsurface",
29 "EGL_EXT_platform_base",
30 "EGL_KHR_platform_x11",
31 "EGL_EXT_platform_x11",
32 "EGL_KHR_platform_wayland",
33 "EGL_EXT_platform_wayland",
34 "EGL_KHR_platform_gbm",
35 "EGL_MESA_platform_gbm",
36 "EGL_MESA_platform_surfaceless",
37 "EGL_EXT_platform_device",
38 "EGL_WL_bind_wayland_display",
39 "EGL_KHR_image_base",
40 "EGL_EXT_image_dma_buf_import",
41 "EGL_EXT_image_dma_buf_import_modifiers",
42 "EGL_MESA_image_dma_buf_export",
43 "EGL_KHR_gl_image",
44 "EGL_EXT_buffer_age",
45 "EGL_EXT_swap_buffers_with_damage",
46 "EGL_KHR_swap_buffers_with_damage",
47 "EGL_KHR_fence_sync",
48 "EGL_ANDROID_native_fence_sync",
49 "EGL_IMG_context_priority",
50 ],
51 )
52 .write_bindings(gl_generator::GlobalGenerator, &mut file)
53 .unwrap();
54 }
55
56 if env::var_os("CARGO_FEATURE_RENDERER_GL").is_some() {
57 let mut file = File::create(dest.join("gl_bindings.rs")).unwrap();
58 Registry::new(
59 Api::Gles2,
60 (3, 2),
61 Profile::Compatibility,
62 Fallbacks::None,
63 [
64 "GL_OES_EGL_image",
65 "GL_OES_EGL_image_external",
66 "GL_EXT_texture_format_BGRA8888",
67 "GL_EXT_unpack_subimage",
68 "GL_OES_EGL_sync",
69 ],
70 )
71 .write_bindings(gl_generator::StructGenerator, &mut file)
72 .unwrap();
73 }
74}
75
76#[cfg(all(feature = "backend_gbm", not(feature = "backend_gbm_has_fd_for_plane")))]
77fn test_gbm_bo_fd_for_plane() {
78 let gbm = match pkg_config::probe_library("gbm") {
79 Ok(lib) => lib,
80 Err(_) => {
81 println!("cargo:warning=failed to find gbm, assuming gbm_bo_get_fd_for_plane is unavailable");
82 return;
83 }
84 };
85
86 let has_gbm_bo_get_fd_for_plane = cc::Build::new()
87 .file("test_gbm_bo_get_fd_for_plane.c")
88 .includes(gbm.include_paths)
89 .warnings_into_errors(true)
90 .cargo_metadata(false)
91 .try_compile("test_gbm_bo_get_fd_for_plane")
92 .is_ok();
93
94 if has_gbm_bo_get_fd_for_plane {
95 println!("cargo:rustc-cfg=feature=\"backend_gbm_has_fd_for_plane\"");
96 }
97}
98
99#[cfg(all(
100 feature = "backend_gbm",
101 not(feature = "backend_gbm_has_create_with_modifiers2")
102))]
103fn test_gbm_bo_create_with_modifiers2() {
104 let gbm = match pkg_config::probe_library("gbm") {
105 Ok(lib) => lib,
106 Err(_) => {
107 println!(
108 "cargo:warning=failed to find gbm, assuming gbm_bo_create_with_modifiers2 is unavailable"
109 );
110 return;
111 }
112 };
113
114 let has_gbm_bo_create_with_modifiers2 = cc::Build::new()
115 .file("test_gbm_bo_create_with_modifiers2.c")
116 .includes(gbm.include_paths)
117 .warnings_into_errors(true)
118 .cargo_metadata(false)
119 .try_compile("test_gbm_bo_create_with_modifiers2")
120 .is_ok();
121
122 if has_gbm_bo_create_with_modifiers2 {
123 println!("cargo:rustc-cfg=feature=\"backend_gbm_has_create_with_modifiers2\"");
124 }
125}
126
127fn main() {
128 #[cfg(any(feature = "backend_egl", feature = "renderer_gl"))]
129 gl_generate();
130
131 #[cfg(all(feature = "backend_gbm", not(feature = "backend_gbm_has_fd_for_plane")))]
132 test_gbm_bo_fd_for_plane();
133 #[cfg(all(
134 feature = "backend_gbm",
135 not(feature = "backend_gbm_has_create_with_modifiers2")
136 ))]
137 test_gbm_bo_create_with_modifiers2();
138}