Skip to content

Commit

Permalink
Update version handling (#1408)
Browse files Browse the repository at this point in the history
ccutil/version.h is now no longer needed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil authored and zdenop committed Mar 22, 2018
1 parent 8c84d29 commit b94bbd6
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 20 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ install(FILES
ccutil/unicharcompress.h
ccutil/unicharmap.h
ccutil/unicharset.h
ccutil/version.h

#from lstm/makefile.am
lstm/convolve.h
Expand Down
1 change: 0 additions & 1 deletion api/apitypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#define TESSERACT_API_APITYPES_H_

#include "publictypes.h"
#include "version.h"

// The types used by the API and Page/ResultIterator can be found in:
// ccstruct/publictypes.h
Expand Down
6 changes: 1 addition & 5 deletions api/baseapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,7 @@ TessBaseAPI::~TessBaseAPI() {
* Returns the version identifier as a static string. Do not delete.
*/
const char* TessBaseAPI::Version() {
#if defined(GIT_REV) && (defined(DEBUG) || defined(_DEBUG))
return GIT_REV;
#else
return TESSERACT_VERSION_STR;
#endif
return PACKAGE_VERSION;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion api/pdfrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,8 @@ bool TessPDFRenderer::EndDocumentHandler() {
" /Title <%s>\n"
">>\n"
"endobj\n",
obj_, TESSERACT_VERSION_STR, datestr, utf16_title.c_str());
obj_, tesseract::TessBaseAPI::Version(),
datestr, utf16_title.c_str());
lept_free(datestr);
if (n >= sizeof(buf)) return false;
AppendPDFObject(buf);
Expand Down
2 changes: 1 addition & 1 deletion api/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ bool TessHOcrRenderer::BeginDocumentHandler() {
"</title>\n"
"<meta http-equiv=\"Content-Type\" content=\"text/html;"
"charset=utf-8\" />\n"
" <meta name='ocr-system' content='tesseract " TESSERACT_VERSION_STR
" <meta name='ocr-system' content='tesseract " PACKAGE_VERSION
"' />\n"
" <meta name='ocr-capabilities' content='ocr_page ocr_carea ocr_par"
" ocr_line ocrx_word");
Expand Down
3 changes: 1 addition & 2 deletions ccutil/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ endif
include_HEADERS = \
basedir.h errcode.h fileerr.h genericvector.h helpers.h host.h memry.h \
ndminx.h params.h ocrclass.h platform.h serialis.h strngs.h \
tesscallback.h unichar.h unicharcompress.h unicharmap.h unicharset.h \
version.h
tesscallback.h unichar.h unicharcompress.h unicharmap.h unicharset.h

noinst_HEADERS = \
ambigs.h bits16.h bitvector.h ccutil.h clst.h doubleptr.h elst2.h \
Expand Down
9 changes: 0 additions & 9 deletions ccutil/version.h

This file was deleted.

6 comments on commit b94bbd6

@nguyenq
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Help! How would a Visual Studio project find and read this new PACKAGE_VERSION string since it's no longer defined in .h or .cpp file.

@stweil
Copy link
Member Author

@stweil stweil commented on b94bbd6 Mar 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use Visual Studio with CMake, then CMake will add a definition for the macro PACKAGE_VERSION in the generated file config_auto.h.
If you have your own Visual Studio Project, you can add a compiler option yourself (-DPACKAGE_VERSION=x.y.z).

@zdenop
Copy link
Contributor

@zdenop zdenop commented on b94bbd6 Mar 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still thinking about this change.
Putting version number to .h file is IMO better for handling API changes at compilation time e.g. There was change of API between 3.0x version and programs using tesseract library need to adapt code based on this version information. I have no time to test it but AFAIK something this is not possible at current code.

@stweil
Copy link
Member Author

@stweil stweil commented on b94bbd6 Mar 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we need something like that, we could derive TESSERACT_VERSION_MAJOR and TESSERACT_VERSION_MINOR macros from PACKAGE_VERSION and write them to config_auto, too.
CMake already has Tesseract_VERSION_MAJOR and Tesseract_VERSION_MINOR, but it is unclear where those are used, and I would also prefer all uppercase (cf. for example PANGO_VERSION_MAJOR).

@nguyenq
Copy link
Contributor

@nguyenq nguyenq commented on b94bbd6 Mar 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a PACKAGE_VERSION="4.0.0-beta.1" line to Preprocessor Definitions property completed the build. Thanks.

@Shreeshrii
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stweil Please also add version information to the training tools programs e.g. text2image. Thanks.

Please sign in to comment.