Skip to content

libglvnd 1.4.0 #11121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Aug 6, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipes/libglvnd/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.4.0":
url: "https://gitlab.freedesktop.org/glvnd/libglvnd/uploads/ca5bf4295beb39bb324f692c481ac8a1/libglvnd-1.4.0.tar.gz"
sha256: "c4a884503d2412dc1fa209613aa8a77193aeb7065b823fe1775dc8b6f3e45211"
171 changes: 171 additions & 0 deletions recipes/libglvnd/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
from conans import Meson, ConanFile, tools
from conans.errors import ConanInvalidConfiguration
import functools
import os
import textwrap

required_conan_version = ">=1.45.0"

class LibGlvndConan(ConanFile):
name = "libglvnd"
Copy link
Contributor

@Croydon Croydon Jun 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a note: My understanding is, that this might be the better replacement for all the places we currently use opengl/system, but this might break compatibility for older systems with older GPU drivers and in general GPU drivers that aren't supported by glvnd.

We probably would need the currently opengl/system package in the form of an optional mesa-opengl/system package or something, but it wouldn't necessarily be required, as any driver would be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, some of the distros install glvnd as system opengl too (https://ubuntu.pkgs.org/22.04/ubuntu-main-amd64/libgl-dev_1.4.0-1_amd64.deb.html), so mesa-opengl/system is probably not the good name either.

description = "The GL Vendor-Neutral Dispatch library"
license = "LicenseRef-LICENSE"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://gitlab.freedesktop.org/glvnd/libglvnd"
topics = ("gl", "vendor-neutral", "dispatch")
settings = "os", "arch", "compiler", "build_type"
options = {
"asm": [True, False],
"x11": [True, False],
"egl": [True, False],
"glx": [True, False],
"gles1": [True, False],
"gles2": [True, False],
"tls": [True, False],
"dispatch_tls": [True, False],
"headers": [True, False],
"entrypoint_patching": [True, False],
}
default_options = {
"asm" : True,
"x11": True,
"egl": True,
"glx": True,
"gles1": True,
"gles2": True,
"tls": True,
"dispatch_tls": True,
"headers": True,
"entrypoint_patching": True,
}

generators = "pkg_config"


@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

# don't use self.settings_build
@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)

# don't use self.user_info_build
@property
def _user_info_build(self):
return getattr(self, "user_info_build", self.deps_user_info)

def configure(self):
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

def requirements(self):
if self.options.x11:
self.requires("xorg/system")
if self.options.glx:
self.requires("xorg-proto/2021.4")

def validate(self):
if self.settings.os not in ['Linux', 'FreeBSD']:
raise ConanInvalidConfiguration("libglvnd is only compatible with Linux and FreeBSD")

def build_requirements(self):
self.build_requires("meson/0.62.2")
self.build_requires("pkgconf/1.7.4")

def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

@functools.lru_cache(1)
def _configure_meson(self):
meson = Meson(self)
defs = {}
defs["asm"] = self.options.asm
defs["x11"] = self.options.x11
defs["egl"] = self.options.egl
defs["glx"] = self.options.glx
defs["gles1"] = self.options.gles1
defs["gles2"] = self.options.gles2
defs["tls"] = self.options.tls
defs["dispatch-tls"] = self.options.dispatch_tls
defs["headers"] = self.options.headers
defs["entrypoint-patching"] = self.options.entrypoint_patching
meson.configure(source_folder=self._source_subfolder, build_folder=self._build_subfolder)
return meson

def build(self):
meson = self._configure_meson()
meson.build()

def package(self):
meson = self._configure_meson()
meson.install()

tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "share"))

tools.save(os.path.join(self.package_folder, "licenses", "LICENSE"), textwrap.dedent('''\
Copyright (c) 2013, NVIDIA CORPORATION.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and/or associated documentation files (the
"Materials"), to deal in the Materials without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Materials, and to
permit persons to whom the Materials are furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
unaltered in all copies or substantial portions of the Materials.
Any additions, deletions, or changes to the original source files
must be clearly indicated in accompanying documentation.

THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
'''))

def package_info(self):
self.cpp_info.components['gldispatch'].libs = ["GLdispatch"]
self.cpp_info.components['gldispatch'].system_libs.extend(["pthread", "dl"])

self.cpp_info.components['opengl'].libs = ["OpenGL"]
self.cpp_info.components['opengl'].requires.extend(["gldispatch"])
self.cpp_info.components['opengl'].set_property("pkg_config_name", "opengl")

if self.options.egl:
self.cpp_info.components['egl'].libs = ["EGL"]
self.cpp_info.components['egl'].system_libs.extend(["pthread", "dl", "m"])
self.cpp_info.components['egl'].requires.extend(["xorg::x11", "gldispatch"])
self.cpp_info.components['egl'].set_property("pkg_config_name", "egl")

if self.options.glx:
self.cpp_info.components['glx'].libs = ["GLX"]
self.cpp_info.components['glx'].system_libs.extend(["dl"])
self.cpp_info.components['glx'].requires.extend(["xorg::x11", "xorg-proto::glproto", "gldispatch"])
self.cpp_info.components['glx'].set_property("pkg_config_name", "glx")

self.cpp_info.components['gl'].libs = ["GL"]
self.cpp_info.components['gl'].system_libs.extend(["dl"])
self.cpp_info.components['gl'].requires.extend(["xorg::x11", "glx", "gldispatch"])
self.cpp_info.components['gl'].set_property("pkg_config_name", "gl")

if self.options.gles1:
self.cpp_info.components['gles1'].libs = ["GLESv1_CM"]
self.cpp_info.components['gles1'].requires.extend(["gldispatch"])
self.cpp_info.components['gles1'].set_property("pkg_config_name", "glesv1_cm")

if self.options.gles2:
self.cpp_info.components['gles2'].libs = ["GLESv2"]
self.cpp_info.components['gles2'].requires.extend(["gldispatch"])
self.cpp_info.components['gles2'].set_property("pkg_config_name", "glesv2")
8 changes: 8 additions & 0 deletions recipes/libglvnd/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
17 changes: 17 additions & 0 deletions recipes/libglvnd/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
17 changes: 17 additions & 0 deletions recipes/libglvnd/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdio.h>

#include <GL/gl.h>


int main()
{
const char * gl_vendor = (const char *) glGetString(GL_VENDOR);
const char * gl_renderer = (const char *) glGetString(GL_RENDERER);
const char * gl_version = (const char *) glGetString(GL_VERSION);
const char * gl_extensions = (const char *) glGetString(GL_EXTENSIONS);
printf( "GL_VENDOR: %s\n", gl_vendor ? gl_vendor : "(null)");
printf( "GL_RENDERER: %s\n", gl_renderer ? gl_renderer : "(null)");
printf( "GL_VERSION: %s\n", gl_version ? gl_version : "(null)");
printf( "GL_EXTENSIONS: %s\n", gl_extensions ? gl_extensions : "(null)");
return 0;
}
3 changes: 3 additions & 0 deletions recipes/libglvnd/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.4.0":
folder: "all"