Skip to content

Commit

Permalink
handle $Id$ in CMakeLists.txt instead of config.h.in
Browse files Browse the repository at this point in the history
  • Loading branch information
hkrn committed Jan 11, 2014
1 parent 9ca9da6 commit 9036ea3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .gitattributes
@@ -1,2 +1,2 @@
config.h ident
config.h.in ident
CMakeLists.txt ident

3 changes: 1 addition & 2 deletions VPAPI/include/LoggingThread.h
Expand Up @@ -97,11 +97,10 @@ class LoggingThread : public QRunnable {

private:
void run() {
static const QString commitRevision = QString(vpvl2::libraryCommitRevisionString()).split(" ").at(1);
QStringList stringList;
stringList.reserve(4);
qInstallMessageHandler(&LoggingThread::delegateMessage);
qDebug("libvpvl2: version=%s commit=%s", vpvl2::libraryVersionString(), qPrintable(commitRevision));
qDebug("libvpvl2: version=%s commit=%s", vpvl2::libraryVersionString(), vpvl2::libraryCommitRevisionString());
while (m_active) {
QMutexLocker locker(&m_mutex); Q_UNUSED(locker);
m_cond.wait(&m_mutex);
Expand Down
3 changes: 3 additions & 0 deletions libvpvl2/CMakeLists.txt
Expand Up @@ -7,7 +7,10 @@ project(libvpvl2)
set(VPVL2_VERSION_MAJOR 0)
set(VPVL2_VERSION_COMPAT 33)
set(VPVL2_VERSION_MINOR 0)
set(VPVL2_COMMIT_REVISION_ID "$Id$")
set(VPVL2_PROJECT_NAME "vpvl2")
string(REGEX REPLACE "Id: ([0-9a-f]+) " "\\1" VPVL2_COMMIT_REVISION ${VPVL2_COMMIT_REVISION_ID})
string(REPLACE "$" "" VPVL2_COMMIT_REVISION ${VPVL2_COMMIT_REVISION})

# include external cmake scripts
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
Expand Down
2 changes: 1 addition & 1 deletion libvpvl2/include/vpvl2/config.h.in
Expand Up @@ -177,7 +177,7 @@
VPVL2_VERSION_MINOR)

#define VPVL2_VERSION_STRING "@VPVL2_VERSION@"
#define VPVL2_COMMIT_REVISION "$Id$"
#define VPVL2_COMMIT_REVISION "@VPVL2_COMMIT_REVISION@"

/* _MSC_VER < 1300 (= Visual Studio 6) doesn't support */
#if (defined(_MSC_VER) && _MSC_VER < 1600)
Expand Down
13 changes: 9 additions & 4 deletions libvpvl2/libvpvl2.qbs
Expand Up @@ -157,12 +157,17 @@ Product {
content = content.replace(regexp, "#define " + value)
}
}
var versionArray = versionString.split(/\./)
var file = new TextFile(product.sourceDirectory + "/CMakeLists.txt", TextFile.ReadOnly), cmakeVariables = {}
while (!file.atEof()) {
var line = file.readLine()
if (line.match(/(VPVL2_COMMIT_REVISION)_ID\s+"\$Id:\s+(\w+)\s+\$"/) ||
line.match(/(VPVL2_VERSION_\w+)\s+(\d+)/)) {
cmakeVariables[RegExp.$1] = RegExp.$2
}
}
content = content.replace(/#cmakedefine\s+(\w+)/gm, "/* #undef $1 */")
content = content.replace(/@VPVL2_VERSION_MAJOR@/gm, versionArray[0])
content = content.replace(/@VPVL2_VERSION_COMPAT@/gm, versionArray[1])
content = content.replace(/@VPVL2_VERSION_MINOR@/gm, versionArray[2])
content = content.replace(/@VPVL2_VERSION@/gm, versionString)
content = content.replace(/@(VPVL2_\w+)@/gm, function(match, p1) { return cmakeVariables[p1] })
outputFile.truncate()
outputFile.write(content)
outputFile.close()
Expand Down

0 comments on commit 9036ea3

Please sign in to comment.