source: tspsg/version.pri @ 1299ea5b49

appveyorimgbotreadme
Last change on this file since 1299ea5b49 was 1299ea5b49, checked in by Oleksii Serdiuk, 12 years ago

Updated version info to be set based on git tags.

'git describe' is now used for version definition. Major, minor and
release are taken from the latest git tag. Build is defined as number of
commits since the latest tag. If we're out of source, then .tag file
should contain output of 'git describe --abbrev=40' command.

Also, moved version related code from tspsg.pro to version.pri.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1######################################################################
2#
3#  TSPSG: TSP Solver and Generator
4#  Copyright (C) 2007-2011 Lёppa <contacts[at]oleksii[dot]name>
5#
6#  $Id: $Format:%h %ai %an$ $
7#  $URL: http://tspsg.info/ $
8#
9#  This file is part of TSPSG.
10#
11######################################################################
12
13exists(".git/") {
14    DESC = $$system("git describe --abbrev=40")
15} else:exists(".tag") {
16    DESC = $$cat(".tag")
17}
18!isEmpty(DESC) {
19    DESC = $$split(DESC, "-")
20    VER = $$member(DESC, 0)
21    VER = $$split(VER, ".")
22
23    BUILD_VERSION_MAJOR = $$member(VER, 0)
24    BUILD_VERSION_MINOR = $$member(VER, 1)
25    BUILD_RELEASE = $$member(VER, 2)
26    count(DESC, 2) {
27        # We're exactly at a tag - use whatever is provided by it
28        BUILD_NUMBER = $$member(VER, 3)
29        isEmpty(BUILD_NUMBER) {
30            BUILD_NUMBER = 0
31        }
32
33        DEFINES += TSPSG_RELEASE_BUILD
34        DEFINES += BUILD_STATUS=$$member(DESC, 1)
35    } else {
36        TMP = $$member(VER, 3)
37        TMP = $$replace(TMP, "0$", "")
38        BUILD_NUMBER = $$TMP$$member(DESC, 2)
39        REVISION = $$member(DESC, 3)
40        REVISION = $$replace(REVISION, "^g", "")
41
42        DEFINES += REVISION=$$REVISION
43    }
44
45    SHORT_VERSION = $$sprintf("%1.%2",$$BUILD_VERSION_MAJOR,$$BUILD_VERSION_MINOR)
46    win32-msvc*|wincewm* {
47        VERSION = $$SHORT_VERSION
48    } else {
49        VERSION = $$sprintf("%1.%2",$$SHORT_VERSION,$$BUILD_RELEASE)
50    }
51} else {
52    # We can't deduce in case we don't have git or repo was exported.
53    # For this case defaults are provided.
54    BUILD_VERSION_MAJOR = 0
55    BUILD_VERSION_MINOR = 1
56    BUILD_RELEASE = 4
57    BUILD_NUMBER = 0
58}
Note: See TracBrowser for help on using the repository browser.