Generate build information from CHANGES.md

This PR significantly reworks the way glslang is versioned.

Instead of committing changes to the `GLSLANG_MINOR_VERSION` define in
`glslang/Public/ShaderLang.h`, and using `make-revision` to generate
`GLSLANG_PATCH_LEVEL` in `glslang/Include/revision.h`, all version
information is now derived from the new `CHANGES.md` file.

`CHANGES.md` acts as the single source of truth for glslang version
information, along with a convenient place to put all release notes for
each notable change made.

`CHANGES.md` is parsed using the new `build_info.py` python script.
This script can read basic template files to produce new source files,
which it does to read the new `build_info.h.tmpl` to generate (at build
time) a glslang private header at
`<build-dir>/include/glslang/build_info.h`.
I've written generators for each of the CMake, Bazel, gn, and
`Android.mk` build scripts.

The new version code conforms to the Semantic Versioning 2.0 spec.

This new version is also used by the CMake rules to produce versioned
shared objects, including a major-versioned SONAME.

New APIs:
---------

* `glslang::GetVersion()` returns a `Version` struct with the version
  major, minor, patch and flavor.

Breaking API changes:
---------------------

* The public defines `GLSLANG_MINOR_VERSION` and `GLSLANG_PATCH_LEVEL`
  have been entirely removed.
* `glslang/Public/ShaderLang.h` and `glslang/Include/revision.h` have
  been deleted.
* Instead, `<build-dir>/include/glslang/build_info.h` is created in
  the build directory, and `<build-dir>/include` is a CMake `PUBLIC`
  (dependee-inherited) include directory for the glslang targets.
* `<build-dir>/include/glslang/build_info.h` contains the following
   new #defines:
   `GLSLANG_VERSION_MAJOR`, `GLSLANG_VERSION_MINOR`,
   `GLSLANG_VERSION_PATCH`, `GLSLANG_VERSION_FLAVOR`,
   `GLSLANG_VERSION_GREATER_THAN(major, minor, patch)`,
   `GLSLANG_VERSION_GREATER_OR_EQUAL_TO(major, minor, patch)`,
   `GLSLANG_VERSION_LESS_THAN(major, minor, patch)`,
   `GLSLANG_VERSION_LESS_OR_EQUAL_TO(major, minor, patch)`
*  The CMake install output directory contains a copy of
   `build_info.h` at: `include/glslang/build_info.h`
*  Python3 is now always required to build glslang (likely always
   required for transitive dependency builds).
This commit is contained in:
Ben Clayton
2020-06-17 11:17:19 +01:00
parent 5aaa0c2bc8
commit fbe9a23baf
16 changed files with 514 additions and 63 deletions

View File

@@ -133,6 +133,9 @@ endif(ENABLE_HLSL)
add_library(MachineIndependent STATIC ${MACHINEINDEPENDENT_SOURCES} ${MACHINEINDEPENDENT_HEADERS})
set_property(TARGET MachineIndependent PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET MachineIndependent PROPERTY FOLDER glslang)
glslang_add_build_info_dependency(MachineIndependent)
glslang_pch(MachineIndependent MachineIndependent/pch.h)
target_link_libraries(MachineIndependent PRIVATE OGLCompiler OSDependent GenericCodeGen)
@@ -156,18 +159,22 @@ set(GLSLANG_HEADERS
Include/intermediate.h
Include/PoolAlloc.h
Include/ResourceLimits.h
Include/revision.h
Include/ShHandle.h
Include/Types.h)
add_library(glslang ${LIB_TYPE} ${BISON_GLSLParser_OUTPUT_SOURCE} ${GLSLANG_SOURCES} ${GLSLANG_HEADERS})
set_property(TARGET glslang PROPERTY FOLDER glslang)
set_property(TARGET glslang PROPERTY POSITION_INDEPENDENT_CODE ON)
set_target_properties(glslang PROPERTIES
FOLDER glslang
POSITION_INDEPENDENT_CODE ON
VERSION "${GLSLANG_VERSION}"
SOVERSION "${GLSLANG_VERSION_MAJOR}")
target_link_libraries(glslang PRIVATE OGLCompiler OSDependent MachineIndependent)
target_include_directories(glslang PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
glslang_add_build_info_dependency(glslang)
glslang_only_export_explicit_symbols(glslang)
if(WIN32 AND BUILD_SHARED_LIBS)
@@ -213,4 +220,7 @@ if(ENABLE_GLSLANG_INSTALL)
get_filename_component(dir ${file} DIRECTORY)
install(FILES ${file} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/glslang/${dir})
endforeach()
install(FILES ${GLSLANG_BUILD_INFO_H} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/glslang)
endif(ENABLE_GLSLANG_INSTALL)

View File

@@ -1,3 +0,0 @@
// This header is generated by the make-revision script.
#define GLSLANG_PATCH_LEVEL 3847

View File

@@ -1,13 +0,0 @@
// The file revision.h should be updated to the latest version, somehow, on
// check-in, if glslang has changed.
//
// revision.template is the source for revision.h when using SubWCRev as the
// method of updating revision.h. You don't have to do it this way, the
// requirement is only that revision.h gets updated.
//
// revision.h is under source control so that not all consumers of glslang
// source have to figure out how to create revision.h just to get a build
// going. However, if it is not updated, it can be a version behind.
#define GLSLANG_REVISION "$WCREV$"
#define GLSLANG_DATE "$WCDATE$"

View File

@@ -72,6 +72,9 @@
// token to print ", but none of that seems appropriate for this file.
#include "preprocessor/PpTokens.h"
// Build-time generated includes
#include "glslang/build_info.h"
namespace { // anonymous namespace for file-local functions and symbols
// Total number of successful initializers of glslang: a refcount
@@ -1684,19 +1687,29 @@ int ShGetUniformLocation(const ShHandle handle, const char* name)
namespace glslang {
#include "../Include/revision.h"
Version GetVersion()
{
Version version;
version.major = GLSLANG_VERSION_MAJOR;
version.minor = GLSLANG_VERSION_MINOR;
version.patch = GLSLANG_VERSION_PATCH;
version.flavor = GLSLANG_VERSION_FLAVOR;
return version;
}
#define QUOTE(s) #s
#define STR(n) QUOTE(n)
const char* GetEsslVersionString()
{
return "OpenGL ES GLSL 3.20 glslang Khronos. " STR(GLSLANG_MINOR_VERSION) "." STR(GLSLANG_PATCH_LEVEL);
return "OpenGL ES GLSL 3.20 glslang Khronos. " STR(GLSLANG_VERSION_MAJOR) "." STR(GLSLANG_VERSION_MINOR) "." STR(
GLSLANG_VERSION_PATCH) GLSLANG_VERSION_FLAVOR;
}
const char* GetGlslVersionString()
{
return "4.60 glslang Khronos. " STR(GLSLANG_MINOR_VERSION) "." STR(GLSLANG_PATCH_LEVEL);
return "4.60 glslang Khronos. " STR(GLSLANG_VERSION_MAJOR) "." STR(GLSLANG_VERSION_MINOR) "." STR(
GLSLANG_VERSION_PATCH) GLSLANG_VERSION_FLAVOR;
}
int GetKhronosToolId()

View File

@@ -74,11 +74,6 @@
extern "C" {
#endif
// This should always increase, as some paths to do not consume
// a more major number.
// It should increment by one when new functionality is added.
#define GLSLANG_MINOR_VERSION 15
//
// Call before doing any other compiler/linker operations.
//
@@ -399,6 +394,14 @@ class TInfoSink;
namespace glslang {
struct Version {
int major;
int minor;
int patch;
const char* flavor;
};
GLSLANG_EXPORT Version GetVersion();
GLSLANG_EXPORT const char* GetEsslVersionString();
GLSLANG_EXPORT const char* GetGlslVersionString();
GLSLANG_EXPORT int GetKhronosToolId();