Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Trace the commit ID and branch the library was built from
  • Loading branch information
kcat committed Dec 21, 2016
1 parent 8f581c0 commit bcb6dfe
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Alc/ALc.c
Expand Up @@ -20,6 +20,8 @@

#include "config.h"

#include "version.h"

#include <math.h>
#include <stdlib.h>
#include <stdio.h>
Expand Down Expand Up @@ -900,6 +902,8 @@ static void alc_initconfig(void)
else ERR("Failed to open log file '%s'\n", str);
}

TRACE("Initializing library v%s-%s %s\n", ALSOFT_VERSION,
ALSOFT_GIT_COMMIT_HASH, ALSOFT_GIT_BRANCH);
{
char buf[1024] = "";
int len = snprintf(buf, sizeof(buf), "%s", BackendList[0].name);
Expand Down
22 changes: 22 additions & 0 deletions CMakeLists.txt
Expand Up @@ -1174,6 +1174,25 @@ IF(LIBTYPE STREQUAL "STATIC")
SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
ENDIF()

IF(EXISTS "${OpenAL_SOURCE_DIR}/.git")
# Get the current working branch and its latest abbreviated commit hash
EXECUTE_PROCESS(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
EXECUTE_PROCESS(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
ELSE()
SET(GIT_BRANCH "UNKNOWN")
SET(GIT_COMMIT_HASH "unknown")
ENDIF()

# Needed for openal.pc.in
SET(prefix ${CMAKE_INSTALL_PREFIX})
SET(exec_prefix "\${prefix}")
Expand All @@ -1183,6 +1202,9 @@ SET(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
SET(PACKAGE_VERSION "${LIB_VERSION}")

# End configuration
CONFIGURE_FILE(
"${OpenAL_SOURCE_DIR}/version.h.in"
"${OpenAL_BINARY_DIR}/version.h")
CONFIGURE_FILE(
"${OpenAL_SOURCE_DIR}/config.h.in"
"${OpenAL_BINARY_DIR}/config.h")
Expand Down
2 changes: 2 additions & 0 deletions OpenAL32/alState.c
Expand Up @@ -20,6 +20,8 @@

#include "config.h"

#include "version.h"

#include <stdlib.h>
#include "alMain.h"
#include "AL/alc.h"
Expand Down
3 changes: 0 additions & 3 deletions config.h.in
Expand Up @@ -2,9 +2,6 @@
#define AL_API ${EXPORT_DECL}
#define ALC_API ${EXPORT_DECL}

/* Define to the library version */
#define ALSOFT_VERSION "${LIB_VERSION}"

/* Define any available alignment declaration */
#define ALIGN(x) ${ALIGN_DECL}

Expand Down
5 changes: 4 additions & 1 deletion utils/alsoft-config/mainwindow.cpp
@@ -1,6 +1,8 @@

#include "config.h"

#include "version.h"

#include <iostream>
#include <cmath>

Expand Down Expand Up @@ -461,7 +463,8 @@ void MainWindow::cancelCloseAction()
void MainWindow::showAboutPage()
{
QMessageBox::information(this, tr("About"),
tr("OpenAL Soft Configuration Utility.\nBuilt for OpenAL Soft library version ")+(ALSOFT_VERSION ".")
tr("OpenAL Soft Configuration Utility.\nBuilt for OpenAL Soft library version ")+
(ALSOFT_VERSION "-" ALSOFT_GIT_COMMIT_HASH " (" ALSOFT_GIT_BRANCH " branch).")
);
}

Expand Down
8 changes: 8 additions & 0 deletions version.h.in
@@ -0,0 +1,8 @@
/* Define to the library version */
#define ALSOFT_VERSION "${LIB_VERSION}"

/* Define the branch being built */
#define ALSOFT_GIT_BRANCH "${GIT_BRANCH}"

/* Define the hash of the head commit */
#define ALSOFT_GIT_COMMIT_HASH "${GIT_COMMIT_HASH}"

0 comments on commit bcb6dfe

Please sign in to comment.