Skip to content

Commit

Permalink
feat: add the "version.pri" file
Browse files Browse the repository at this point in the history
Change-Id: I78c4e6784e7a88991371d5c23bc2fd0049ef5a10
  • Loading branch information
zccrs committed Jan 16, 2018
1 parent 198b958 commit 07aab9f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 29 deletions.
38 changes: 11 additions & 27 deletions src/lib.pri
Original file line number Diff line number Diff line change
@@ -1,32 +1,6 @@
TEMPLATE = lib

isEmpty(VERSION) {
VERSION = $$system(git describe --tags --abbrev=0)
isEmpty(VERSION):VERSION = $$DTK_VERSION
isEmpty(VERSION):error(VERSION is empty)
VERSION = $$replace(VERSION, [^0-9.],)
}

ver_list = $$split(VERSION, .)

isEmpty(VER_MAJ) {
VER_MAJ = $$first(ver_list)
}

isEmpty(VER_MIN) {
VER_MIN = $$member(ver_list, 1, 1)
isEmpty(VER_MIN):VER_MIN = 0
}

isEmpty(VER_PAT) {
VER_PAT = $$member(ver_list, 2, 2)
isEmpty(VER_PAT):VER_PAT = 0
}

isEmpty(VER_BUI) {
VER_BUI = $$member(ver_list, 3, 3)
isEmpty(VER_BUI):VER_BUI = 0
}
include($$PWD/version.pri)

CONFIG += c++11 create_pc create_prl no_install_prl
CONFIG += no_keywords
Expand All @@ -53,3 +27,13 @@ win32* {
DEFINES += STATIC_LIB
CONFIG += staticlib
}

pri_dev.files += $$PWD/version.pri

isEmpty(LIB_INSTALL_DIR) {
pri_dev.path = $$PREFIX/lib/libdtk-$${VER_MAJ}.$${VER_MIN}.$${VER_PAT}/modules
} else {
pri_dev.path = $$LIB_INSTALL_DIR/libdtk-$${VER_MAJ}.$${VER_MIN}.$${VER_PAT}/modules
}

INSTALLS += pri_dev
3 changes: 1 addition & 2 deletions src/src.pro
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include($$PWD/lib.pri)

QT -= gui
QT += dbus
CONFIG += link_pkgconfig
Expand All @@ -13,6 +11,7 @@ INCLUDEPATH += $$PWD $$PWD/base
HEADERS += \
$$PWD/dtkcore_global.h

include($$PWD/lib.pri)
include($$PWD/base/base.pri)
include($$PWD/util/util.pri)
include($$PWD/log/log.pri)
Expand Down
32 changes: 32 additions & 0 deletions src/version.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
isEmpty(VERSION) {
!isEqual(TARGET, dtkcore) {
PKG_CONFIG = $$pkgConfigExecutable()
!isEmpty(PKG_CONFIG): VERSION = $$system($$PKG_CONFIG --modversion dtkcore)
}

isEmpty(VERSION): VERSION = $$system(git describe --tags --abbrev=0)
isEmpty(VERSION): VERSION = $$DTK_VERSION
isEmpty(VERSION): error(VERSION is empty)
VERSION = $$replace(VERSION, [^0-9.],)
}

ver_list = $$split(VERSION, .)

isEmpty(VER_MAJ) {
VER_MAJ = $$first(ver_list)
}

isEmpty(VER_MIN) {
VER_MIN = $$member(ver_list, 1, 1)
isEmpty(VER_MIN):VER_MIN = 0
}

isEmpty(VER_PAT) {
VER_PAT = $$member(ver_list, 2, 2)
isEmpty(VER_PAT):VER_PAT = 0
}

isEmpty(VER_BUI) {
VER_BUI = $$member(ver_list, 3, 3)
isEmpty(VER_BUI):VER_BUI = 0
}

0 comments on commit 07aab9f

Please sign in to comment.