Browse Source

fix version definition when compiling from non-Git checkout

This also changes the release process; just before making a release
we have to remove the "-development" suffix in VERSION, commit and
tag the release and immediately after that increment it and re-add
the "-development" suffix in the very next commit.

This ensures that released versions will not have a suffix and
unreleased versions will have "development" as the suffix (if not
having Git or from tarball) or the commit ID if Git is present.

This also means that the VERSION file should never have a newline at the end.
Ashish Kulkarni 11 years ago
parent
commit
a762a849a6

+ 1 - 1
VERSION

@@ -1 +1 @@
-0.12.1
+0.12.1-development

+ 12 - 8
common.pri

@@ -49,11 +49,15 @@ QT += webkit network svg
 
 # version related information
 VERSION_TEXT=$$cat($$PWD/VERSION)
-FULL_VERSION=$$split(VERSION_TEXT, ".")
-MAJOR_VERSION=$$member(FULL_VERSION, 0)
-MINOR_VERSION=$$member(FULL_VERSION, 1)
-PATCH_VERSION=$$member(FULL_VERSION, 2)
-BUILD=$$system(git rev-parse HEAD)
-system(git describe --tags --exact-match HEAD):BUILD="final"
-
-DEFINES += MAJOR_VERSION=$$MAJOR_VERSION MINOR_VERSION=$$MINOR_VERSION PATCH_VERSION=$$PATCH_VERSION BUILD=$$BUILD
+VERSION_LIST=$$split(VERSION_TEXT, "-")
+count(VERSION_LIST, 1) {
+    VERSION=$$VERSION_TEXT
+    FULL_VERSION=$$VERSION
+} else {
+    VERSION=$$member(VERSION_LIST, 0)
+    BUILD=$$member(VERSION_LIST, 1)
+    system(git rev-parse HEAD):BUILD=$$system(git rev-parse HEAD)
+    FULL_VERSION=$$VERSION-$$BUILD
+}
+
+DEFINES += VERSION=$$VERSION FULL_VERSION=$$FULL_VERSION

+ 0 - 1
src/image/image.pro

@@ -18,7 +18,6 @@
 include(../../common.pri)
 
 TEMPLATE = app
-VERSION = $${MAJOR_VERSION}.$${MINOR_VERSION}.$${PATCH_VERSION}
 TARGET = wkhtmltoimage
 DESTDIR = ../../bin
 DEPENDPATH += . ../shared

+ 1 - 1
src/image/imagedocparts.cc

@@ -78,7 +78,7 @@ void ImageCommandLineParser::outputContact(Outputter * o) const {
   \param o The outputter to output to
 */
 void ImageCommandLineParser::outputDocStart(Outputter * o) const {
-	o->beginSection(QString("wkhtmltoimage ")+QString::number(MAJOR_VERSION)+"."+QString::number(MINOR_VERSION)+"."+QString::number(PATCH_VERSION)+(QString(STRINGIZE(BUILD)).isEmpty()?"":" ")+STRINGIZE(BUILD) + " Manual");
+	o->beginSection("wkhtmltoimage " STRINGIZE(FULL_VERSION) " Manual");
 	o->paragraph("This file documents wkhtmltoimage, a program capable of converting HTML "
 				 "documents into images.");
 	o->endSection();

+ 0 - 2
src/lib/lib.pro

@@ -37,8 +37,6 @@ windows {
    TARGET_EXT=.dll
 }
 
-VERSION=$${MAJOR_VERSION}.$${MINOR_VERSION}.$${PATCH_VERSION}
-
 TARGET=wkhtmltox
 INSTALLS += target
 wkhtmltox.path=$$INSTALLBASE/lib

+ 2 - 6
src/lib/pdf_c_bindings.cc

@@ -270,16 +270,12 @@ CAPI(int) wkhtmltopdf_extended_qt() {
 
 /**
  * \brief Return the version of wkhtmltopdf
- * Example: 0.10.0_beta4. The string is utf8 encoded and is owned by wkhtmltopdf.
+ * Example: 0.12.1-development. The string is utf8 encoded and is owned by wkhtmltopdf.
  *
  * \return Qt version
  */
 CAPI(const char *) wkhtmltopdf_version() {
-	return STRINGIZE(MAJOR_VERSION)"."STRINGIZE(MINOR_VERSION)"."STRINGIZE(PATCH_VERSION)
-#ifdef BUILD
-		"_"STRINGIZE(BUILD)
-#endif
-		;
+	return STRINGIZE(FULL_VERSION);
 }
 
 /**

+ 2 - 4
src/lib/pdfconverter.cc

@@ -274,8 +274,7 @@ QPrinter * PdfConverterPrivate::createPrinter(const QString & tempFile) {
 
     printer->setOrientation(settings.orientation);
     printer->setColorMode(settings.colorMode);
-    printer->setCreator("wkhtmltopdf " STRINGIZE(MAJOR_VERSION) "." STRINGIZE(MINOR_VERSION)
-                        "." STRINGIZE(PATCH_VERSION) " " STRINGIZE(BUILD));
+    printer->setCreator("wkhtmltopdf " STRINGIZE(FULL_VERSION));
 
     return printer;
 }
@@ -370,8 +369,7 @@ void PdfConverterPrivate::pagesLoaded(bool ok) {
 
 	printer->setOrientation(settings.orientation);
 	printer->setColorMode(settings.colorMode);
-	printer->setCreator("wkhtmltopdf " STRINGIZE(MAJOR_VERSION) "." STRINGIZE(MINOR_VERSION)
-						"." STRINGIZE(PATCH_VERSION) " " STRINGIZE(BUILD));
+	printer->setCreator("wkhtmltopdf " STRINGIZE(FULL_VERSION));
 
 	if (!printer->isValid()) {
 		emit out.error("Unable to write to destination");

+ 0 - 1
src/pdf/pdf.pro

@@ -18,7 +18,6 @@
 include(../../common.pri)
 
 TEMPLATE = app
-VERSION = $${MAJOR_VERSION}.$${MINOR_VERSION}.$${PATCH_VERSION}
 TARGET = wkhtmltopdf
 DESTDIR = ../../bin
 DEPENDPATH += . ../shared

+ 1 - 1
src/pdf/pdfdocparts.cc

@@ -301,7 +301,7 @@ void PdfCommandLineParser::outputContact(Outputter * o) const {
   \param o The outputter to output to
 */
 void PdfCommandLineParser::outputDocStart(Outputter * o) const {
-	o->beginSection(QString("wkhtmltopdf ")+QString::number(MAJOR_VERSION)+"."+QString::number(MINOR_VERSION)+"."+QString::number(PATCH_VERSION)+(QString(STRINGIZE(BUILD)).isEmpty()?"":" ")+STRINGIZE(BUILD) + " Manual");
+	o->beginSection("wkhtmltopdf " STRINGIZE(FULL_VERSION) " Manual");
 	o->paragraph("This file documents wkhtmltopdf, a program capable of converting html "
 				 "documents into PDF documents.");
 	o->endSection();

+ 1 - 1
src/shared/commondocparts.cc

@@ -30,7 +30,7 @@
 */
 void CommandLineParserBase::outputName(Outputter * o) const {
 	o->beginSection("Name");
-	o->paragraph(appName()+" "+QString::number(MAJOR_VERSION)+"."+QString::number(MINOR_VERSION)+"."+QString::number(PATCH_VERSION)+(QString(STRINGIZE(BUILD)).isEmpty()?"":" ")+STRINGIZE(BUILD));
+	o->paragraph(appName()+" " STRINGIZE(FULL_VERSION));
 	o->endSection();
 
 }