Skip to content

Commit

Permalink
populate slang-tag-version with cmake (#4611)
Browse files Browse the repository at this point in the history
At the moment it is always "unknown"
  • Loading branch information
expipiplus1 authored Jul 11, 2024
1 parent 57742cb commit 45baeb3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
1 change: 0 additions & 1 deletion slang-tag-version.h

This file was deleted.

21 changes: 12 additions & 9 deletions slang.h
Original file line number Diff line number Diff line change
Expand Up @@ -1658,15 +1658,18 @@ extern "C"
void* userData);

/*!
@brief Get the build version 'tag' string. The string is the same as produced via `git describe --tags`
for the project. If Slang is built separately from the automated build scripts
the contents will by default be 'unknown'. Any string can be set by changing the
contents of 'slang-tag-version.h' file and recompiling the project.
This function will return exactly the same result as the method getBuildTag string on IGlobalSession.
An advantage of using this function over the method is that doing so does not require the creation of
a session, which can be a fairly costly operation.
@brief Get the build version 'tag' string. The string is the same as
produced via `git describe --tags --match v*` for the project. If such a
version could not be determined at build time then the contents will be
0.0.0-unknown. Any string can be set by passing
-DSLANG_VERSION_FULL=whatever during the cmake invocation.
This function will return exactly the same result as the method
getBuildTagString on IGlobalSession.
An advantage of using this function over the method is that doing so does
not require the creation of a session, which can be a fairly costly
operation.
@return The build tag string
*/
Expand Down
6 changes: 3 additions & 3 deletions source/slang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ target_include_directories(
#
# Slang itself
#
configure_file(${slang_SOURCE_DIR}/slang-tag-version.h.in slang-tag-version.h)
configure_file(${slang_SOURCE_DIR}/slang-tag-version.h.in slang-version-header/slang-tag-version.h)
slang_add_target(
.
${SLANG_LIB_TYPE}
Expand All @@ -267,10 +267,10 @@ slang_add_target(
# slang.h is in the project root, so include that directory in the interface
# for slang
INCLUDE_DIRECTORIES_PUBLIC ${slang_SOURCE_DIR}
INCLUDE_DIRECTORIES_PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
INCLUDE_DIRECTORIES_PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/slang-version-header
EXPORT_MACRO_PREFIX SLANG
INSTALL
PUBLIC_HEADERS ${slang_SOURCE_DIR}/slang*.h
PUBLIC_HEADERS ${slang_SOURCE_DIR}/slang*.h ${CMAKE_CURRENT_BINARY_DIR}/slang-version-header/*.h
)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
Expand Down
4 changes: 2 additions & 2 deletions source/slang/slang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

#include "slang-check-impl.h"

#include "../../slang-tag-version.h"
#include "slang-tag-version.h"

#include <sys/stat.h>

Expand Down Expand Up @@ -124,7 +124,7 @@ namespace Slang {

const char* getBuildTagString()
{
if (UnownedStringSlice(SLANG_TAG_VERSION) == "unknown")
if (UnownedStringSlice(SLANG_TAG_VERSION) == "0.0.0-unknown")
{
// If the tag is unknown, then we will try to get the timestamp of the shared library
// and use that as the version string, so that we can at least return something
Expand Down

0 comments on commit 45baeb3

Please sign in to comment.