From 827bfad29a3d2c9bdee0d5af4efa96741bfa32b1 Mon Sep 17 00:00:00 2001 From: Carsten Rudolph <18394207+Aschratt@users.noreply.github.com> Date: Wed, 7 Apr 2021 22:33:59 +0200 Subject: [PATCH] [glad] Add features to support different configurations. (#16742) * Replace control file with manifest. * Update portfile and add features. * Added support for multiple specs. * Added OpenGL API features. * Fixed gles1/glsc2 format. * Fixed invalid invoke with default arguments. * Apply format. * Always use compatibility profile. * Replace deprecated cmake commands. * Use `vcpkg_check_features` for no-loader and extensions features. * Add patch to ignore python detection. * Update glad port version. * Remove `core-profile` feature from manifest. * Bump glad port version. * Only set profile, if not provided. Co-authored-by: Robert Schumacher * Added note about custom triplet. Co-authored-by: Robert Schumacher * Use string-append to build spec list. * Invert loader feature and use it by default. * Reset port version. Co-authored-by: Robert Schumacher * Use `version` instead of `version-string`. Co-authored-by: Robert Schumacher * Made API version features inter-dependent. * Also added dependencies if major version jumps. Note that only the latest verison gets passed to the generator anyway. * Apply format conventions. * Bump glad version. * Add note about wgl and glx compatibility. * Bump glad version. Co-authored-by: Robert Schumacher --- ports/glad/CONTROL | 5 - ports/glad/find_python.patch | 21 +++ ports/glad/portfile.cmake | 120 +++++++++++- ports/glad/vcpkg.json | 352 +++++++++++++++++++++++++++++++++++ versions/baseline.json | 2 +- versions/g-/glad.json | 10 + 6 files changed, 495 insertions(+), 15 deletions(-) delete mode 100644 ports/glad/CONTROL create mode 100644 ports/glad/find_python.patch create mode 100644 ports/glad/vcpkg.json diff --git a/ports/glad/CONTROL b/ports/glad/CONTROL deleted file mode 100644 index a0d234f3658..00000000000 --- a/ports/glad/CONTROL +++ /dev/null @@ -1,5 +0,0 @@ -Source: glad -Version: 0.1.33-1 -Description: Multi-Language Vulkan/GL/GLES/EGL/GLX/WGL Loader-Generator based on the official specs. -Build-Depends: egl-registry, opengl-registry -Homepage: https://github.com/Dav1dde/glad diff --git a/ports/glad/find_python.patch b/ports/glad/find_python.patch new file mode 100644 index 00000000000..c1f13229b48 --- /dev/null +++ b/ports/glad/find_python.patch @@ -0,0 +1,21 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c4031a6..6a106e9 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -23,16 +23,6 @@ project(GLAD VERSION 0.1.34 LANGUAGES C) + + set(GLAD_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + +-# Find the python interpreter, set the PYTHON_EXECUTABLE variable +-if (CMAKE_VERSION VERSION_LESS 3.12) +- # this logic is deprecated in CMake after 3.12 +- find_package(PythonInterp REQUIRED) +-else() +- # the new hotness. This will preferentially find Python3 instead of Python2 +- find_package(Python) +- set(PYTHON_EXECUTABLE ${Python_EXECUTABLE}) +-endif() +- + # Options + set(GLAD_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE STRING "Output directory") + set(GLAD_PROFILE "compatibility" CACHE STRING "OpenGL profile") diff --git a/ports/glad/portfile.cmake b/ports/glad/portfile.cmake index f94037d26d7..e8f3b0bef43 100644 --- a/ports/glad/portfile.cmake +++ b/ports/glad/portfile.cmake @@ -3,16 +3,113 @@ vcpkg_check_linkage(ONLY_STATIC_LIBRARY) vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO Dav1dde/glad - REF de6c39e3040c987323b8ed078c36442f4fb681b3 - SHA512 a24523186d59de5c0895791c639c62573eaacf1d3843d3bf81eba848b4a33a9a8d17f9b6f791202dac77692bf147e25b3650989731d5ddb7a22e7d023b66885e + REF 7ece538856bf124d798ab323c8e1e64ebb83cb50 + SHA512 f6a8ba7d0d09b89c23b6f76962d3e6eef1babc8e1a659e238d30e143eb33ccba424957e5a6d46d99a714bfa2967523b193586d0ff24e29ad8d86c92c9faf9c02 HEAD_REF master - PATCHES encoding.patch + PATCHES encoding.patch find_python.patch ) +if(NOT GLAD_PROFILE) + set(GLAD_PROFILE "compatibility") +endif() +message(STATUS "This version of glad uses the compatibility profile. To use the core profile instead, create an overlay port of this with GLAD_PROFILE set to 'core' or set GLAD_PROFILE to 'core' in a custom triplet.") +message(STATUS "This recipe is at ${CMAKE_CURRENT_LIST_DIR}") +message(STATUS "See the overlay ports documentation at https://github.com/microsoft/vcpkg/blob/master/docs/specifications/ports-overlay.md") + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + extensions GLAD_ALL_EXTENSIONS + INVERTED_FEATURES + loader GLAD_NO_LOADER +) + +set(GLAD_SPEC "gl") + +if("egl" IN_LIST FEATURES) + string(APPEND GLAD_SPEC ",egl") +endif() + +if("wgl" IN_LIST FEATURES) + string(APPEND GLAD_SPEC ",wgl") +endif() + +if("glx" IN_LIST FEATURES) + string(APPEND GLAD_SPEC ",glx") +endif() + +if("gl-api-latest" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=") +elseif("gl-api-10" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=1.0") +elseif("gl-api-11" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=1.1") +elseif("gl-api-12" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=1.2") +elseif("gl-api-13" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=1.3") +elseif("gl-api-14" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=1.4") +elseif("gl-api-15" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=1.5") +elseif("gl-api-20" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=2.0") +elseif("gl-api-21" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=2.1") +elseif("gl-api-30" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=3.0") +elseif("gl-api-31" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=3.1") +elseif("gl-api-32" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=3.2") +elseif("gl-api-33" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=3.3") +elseif("gl-api-40" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=4.0") +elseif("gl-api-41" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=4.1") +elseif("gl-api-42" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=4.2") +elseif("gl-api-43" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=4.3") +elseif("gl-api-44" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=4.4") +elseif("gl-api-45" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=4.5") +elseif("gl-api-46" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gl=4.6") +endif() + +if("gles1-api-latest" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gles1=") +elseif("gles1-api-10" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gles1=1.0") +endif() + +if("gles2-api-latest" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gles2=") +elseif("gles2-api-20" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gles2=2.0") +elseif("gles2-api-30" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gles2=3.0") +elseif("gles2-api-31" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gles2=3.1") +elseif("gles2-api-32" IN_LIST FEATURES) + LIST(APPEND GLAD_API "gles2=3.2") +endif() + +if("glsc2-api-latest" IN_LIST FEATURES) + LIST(APPEND GLAD_API "glsc2=") +elseif("glsc2-api-20" IN_LIST FEATURES) + LIST(APPEND GLAD_API "glsc2=2.0") +endif() + +string(REPLACE ";" "," GLAD_API "${GLAD_API}") + vcpkg_find_acquire_program(PYTHON3) file(COPY ${CURRENT_INSTALLED_DIR}/include/KHR/khrplatform.h + ${CURRENT_INSTALLED_DIR}/include/EGL/eglplatform.h ${CURRENT_INSTALLED_DIR}/share/egl-registry/egl.xml ${CURRENT_INSTALLED_DIR}/share/opengl-registry/gl.xml ${CURRENT_INSTALLED_DIR}/share/opengl-registry/glx.xml @@ -20,24 +117,29 @@ file(COPY DESTINATION ${SOURCE_PATH}/glad/files ) -vcpkg_configure_cmake( +vcpkg_cmake_configure( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA OPTIONS - -DGLAD_NO_LOADER=OFF -DGLAD_EXPORT=OFF -DGLAD_INSTALL=ON -DGLAD_REPRODUCIBLE=ON - -DGLAD_SPEC="gl" # {gl,egl,glx,wgl} - -DGLAD_PROFILE="compatibility" # {core,compatibility} + -DGLAD_SPEC=${GLAD_SPEC} + -DGLAD_API=${GLAD_API} + -DGLAD_PROFILE=${GLAD_PROFILE} -DPYTHON_EXECUTABLE=${PYTHON3} + ${FEATURE_OPTIONS} OPTIONS_DEBUG -DGLAD_GENERATOR="c-debug" + OPTIONS_RELEASE + -DGLAD_GENERATOR="c" ) -vcpkg_install_cmake() +vcpkg_cmake_install() vcpkg_copy_pdbs() -vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/glad) +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/glad) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include ${CURRENT_PACKAGES_DIR}/include/KHR) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include ${CURRENT_PACKAGES_DIR}/include/EGL) +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) diff --git a/ports/glad/vcpkg.json b/ports/glad/vcpkg.json new file mode 100644 index 00000000000..a3a637a1729 --- /dev/null +++ b/ports/glad/vcpkg.json @@ -0,0 +1,352 @@ +{ + "name": "glad", + "version": "0.1.34", + "description": "Multi-Language Vulkan/GL/GLES/EGL/GLX/WGL Loader-Generator based on the official specs.", + "homepage": "https://github.com/Dav1dde/glad", + "documentation": "https://github.com/Dav1dde/glad/wiki", + "license": "MIT", + "dependencies": [ + "egl-registry", + "opengl-registry", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + "loader" + ], + "features": { + "egl": { + "description": "Use `egl` spec instead of `gl`." + }, + "extensions": { + "description": "Enables all extensions." + }, + "gl-api-10": { + "description": "Imports extensions from OpenGL API specification version 1.0." + }, + "gl-api-11": { + "description": "Imports extensions from OpenGL API specification version 1.1.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-10" + ] + } + ] + }, + "gl-api-12": { + "description": "Imports extensions from OpenGL API specification version 1.2.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-11" + ] + } + ] + }, + "gl-api-13": { + "description": "Imports extensions from OpenGL API specification version 1.3.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-12" + ] + } + ] + }, + "gl-api-14": { + "description": "Imports extensions from OpenGL API specification version 1.4.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-13" + ] + } + ] + }, + "gl-api-15": { + "description": "Imports extensions from OpenGL API specification version 1.5.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-14" + ] + } + ] + }, + "gl-api-20": { + "description": "Imports extensions from OpenGL API specification version 2.0.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-15" + ] + } + ] + }, + "gl-api-21": { + "description": "Imports extensions from OpenGL API specification version 2.1.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-20" + ] + } + ] + }, + "gl-api-30": { + "description": "Imports extensions from OpenGL API specification version 3.0.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-21" + ] + } + ] + }, + "gl-api-31": { + "description": "Imports extensions from OpenGL API specification version 3.1.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-30" + ] + } + ] + }, + "gl-api-32": { + "description": "Imports extensions from OpenGL API specification version 3.2.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-31" + ] + } + ] + }, + "gl-api-33": { + "description": "Imports extensions from OpenGL API specification version 3.3.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-32" + ] + } + ] + }, + "gl-api-40": { + "description": "Imports extensions from OpenGL API specification version 4.0.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-33" + ] + } + ] + }, + "gl-api-41": { + "description": "Imports extensions from OpenGL API specification version 4.1.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-40" + ] + } + ] + }, + "gl-api-42": { + "description": "Imports extensions from OpenGL API specification version 4.2.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-41" + ] + } + ] + }, + "gl-api-43": { + "description": "Imports extensions from OpenGL API specification version 4.3.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-42" + ] + } + ] + }, + "gl-api-44": { + "description": "Imports extensions from OpenGL API specification version 4.4.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-43" + ] + } + ] + }, + "gl-api-45": { + "description": "Imports extensions from OpenGL API specification version 4.5.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-44" + ] + } + ] + }, + "gl-api-46": { + "description": "Imports extensions from OpenGL API specification version 4.6.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-45" + ] + } + ] + }, + "gl-api-latest": { + "description": "Imports extensions from latest OpenGL API specification version.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gl-api-46" + ] + } + ] + }, + "gles1-api-10": { + "description": "Imports extensions from OpenGL ES 1 specification version 1.0." + }, + "gles1-api-latest": { + "description": "Imports extensions from latest OpenGL ES 1 specification.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gles1-api-10" + ] + } + ] + }, + "gles2-api-20": { + "description": "Imports extensions from OpenGL ES 2 specification version 2.0." + }, + "gles2-api-30": { + "description": "Imports extensions from OpenGL ES 2 specification version 3.0.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gles2-api-20" + ] + } + ] + }, + "gles2-api-31": { + "description": "Imports extensions from OpenGL ES 2 specification version 3.1.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gles2-api-30" + ] + } + ] + }, + "gles2-api-32": { + "description": "Imports extensions from OpenGL ES 2 specification version 3.2.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gles2-api-31" + ] + } + ] + }, + "gles2-api-latest": { + "description": "Imports extensions from latest OpenGL ES 2 specification.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "gles2-api-32" + ] + } + ] + }, + "glsc2-api-20": { + "description": "Imports extensions from OpenGL SC API specification version 2.0." + }, + "glsc2-api-latest": { + "description": "Imports extensions from latest OpenGL SC API specification.", + "dependencies": [ + { + "name": "glad", + "default-features": false, + "features": [ + "glsc2-api-20" + ] + } + ] + }, + "glx": { + "description": "Use `glx` spec instead of `gl`. Only available with the X Window System." + }, + "loader": { + "description": "Generate loader logic." + }, + "wgl": { + "description": "Use `wgl` spec instead of `gl`. Only available for Windows and UWP platforms." + } + } +} diff --git a/versions/baseline.json b/versions/baseline.json index d792dd4a487..754031830c7 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -2229,7 +2229,7 @@ "port-version": 0 }, "glad": { - "baseline": "0.1.33-1", + "baseline": "0.1.34", "port-version": 0 }, "glbinding": { diff --git a/versions/g-/glad.json b/versions/g-/glad.json index d1411e042db..8f9bf92c0e2 100644 --- a/versions/g-/glad.json +++ b/versions/g-/glad.json @@ -1,5 +1,15 @@ { "versions": [ + { + "git-tree": "bea697f07b65eddfb003dc98637caaaa66a773fa", + "version": "0.1.34", + "port-version": 0 + }, + { + "git-tree": "d222f56675de6eedfc3a25e5a4b93fee39747f49", + "version-string": "0.1.34", + "port-version": 2 + }, { "git-tree": "abaac8ade7697e7f6ae4a82c981aafa2cc6a5359", "version-string": "0.1.33-1",