Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move all public headers to include/tesseract #2735

Merged
merged 5 commits into from
Oct 29, 2019

Conversation

amitdo
Copy link
Collaborator

@amitdo amitdo commented Oct 28, 2019

Also:

  • Fix #include path of public headers
  • Fix autotools build

@@ -36,7 +36,7 @@ config_auto.h
/doc/*.xml

# generated version file
/src/api/tess_version.h
/include/tesseract/tess_version.h
Copy link
Member

Choose a reason for hiding this comment

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

The file name is now always preceded by the tesseract directory, so we could simply use tesseract/version.h.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True

@amitdo
Copy link
Collaborator Author

amitdo commented Oct 28, 2019

This does not include the needed changes to CMake and sw, so the CI will fail.

I tested it with autotools and it works fine.

@egorpugin, please push more commits to this PR or first merge and do the CMake fix later.

Please don't squash my commits.

@amitdo
Copy link
Collaborator Author

amitdo commented Oct 28, 2019

See #594 (comment)

@lgtm-com
Copy link

lgtm-com bot commented Oct 28, 2019

This pull request fixes 1 alert when merging 2f8884a into cede5b3 - view on LGTM.com

fixed alerts:

  • 1 for Comparison result is always the same

@egorpugin
Copy link
Contributor

@stweil @zdenop
Is this ok for you?
Waiting for the approval/confirmation for such changes.

@@ -0,0 +1,54 @@
AM_CPPFLAGS += \
Copy link
Member

Choose a reason for hiding this comment

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

Is AM_CPPFLAGS really needed here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure. You can try to remove it and see if it compiles.
Remove (usr/local)/include/tesseract in your system first.

Copy link
Member

@stweil stweil Oct 28, 2019

Choose a reason for hiding this comment

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

It works without it because no files are compiled there. But I suggest an even more radical modification, namely no include/tesseract/Makefile.am at all. Instead use this code:

diff --git a/Makefile.am b/Makefile.am
index 27de8e24..1e900be8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,7 +22,7 @@ endif
 
 SUBDIRS = src/arch src/ccutil src/viewer src/cutil src/opencl src/ccstruct
 SUBDIRS += src/dict src/classify src/wordrec src/textord src/lstm
-SUBDIRS += src/ccmain src/api . tessdata doc unittest include/tesseract
+SUBDIRS += src/ccmain src/api . tessdata doc unittest
 
 EXTRA_DIST = README.md LICENSE
 EXTRA_DIST += aclocal.m4 config configure.ac autogen.sh
@@ -65,6 +65,25 @@ doc-clean:
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = tesseract.pc
 
+pkginclude_HEADERS = $(top_builddir)/include/tesseract/tess_version.h
+pkginclude_HEADERS += include/tesseract/apitypes.h
+pkginclude_HEADERS += include/tesseract/baseapi.h
+pkginclude_HEADERS += include/tesseract/capi.h
+pkginclude_HEADERS += include/tesseract/genericvector.h
+pkginclude_HEADERS += include/tesseract/helpers.h
+pkginclude_HEADERS += include/tesseract/ltrresultiterator.h
+pkginclude_HEADERS += include/tesseract/ocrclass.h
+pkginclude_HEADERS += include/tesseract/osdetect.h
+pkginclude_HEADERS += include/tesseract/pageiterator.h
+pkginclude_HEADERS += include/tesseract/platform.h
+pkginclude_HEADERS += include/tesseract/publictypes.h
+pkginclude_HEADERS += include/tesseract/renderer.h
+pkginclude_HEADERS += include/tesseract/resultiterator.h
+pkginclude_HEADERS += include/tesseract/serialis.h
+pkginclude_HEADERS += include/tesseract/strngs.h
+pkginclude_HEADERS += include/tesseract/thresholder.h
+pkginclude_HEADERS += include/tesseract/unichar.h
+
 # fuzzer-api is used for fuzzing tests.
 # They are run by OSS-Fuzz https://oss-fuzz.com/, but can also be run locally.
 # Note: -fsanitize=fuzzer currently requires the clang++ compiler.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I agree.

Copy link
Member

@stweil stweil left a comment

Choose a reason for hiding this comment

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

unittest also needs fixed include statements.
The include statements in include/tesseract don't need the added tesseract/.

@amitdo
Copy link
Collaborator Author

amitdo commented Oct 28, 2019

unittest also needs fixed include statements.

e1bae15#diff-ee6e88ad125acd6b96556b3373ed48d7

@amitdo
Copy link
Collaborator Author

amitdo commented Oct 28, 2019

This pull request fixes 1 alert when merging 2f8884a into cede5b3 - view on LGTM.com

fixed alerts:

  • 1 for Comparison result is always the same

I have no clue how this PR fixed that alert :-)

@stweil
Copy link
Member

stweil commented Oct 28, 2019

unittest also needs fixed include statements.

e1bae15#diff-ee6e88ad125acd6b96556b3373ed48d7

What about unittest/applybox_test.cc (and some more)?

@amitdo
Copy link
Collaborator Author

amitdo commented Oct 28, 2019

The include statements in include/tesseract don't need the added tesseract/.

At least some Google projects do what I did. I'm not sure what's the right thing to do here.
https://github.com/google/leveldb/blob/master/include/leveldb/cache.h#L23

@amitdo
Copy link
Collaborator Author

amitdo commented Oct 28, 2019

@amitdo
Copy link
Collaborator Author

amitdo commented Oct 28, 2019

What about unittest/applybox_test.cc (and some more)?

My hacky python script searches for files with *.cpp or *.h.

That's why it missed *.cc ...

@lgtm-com
Copy link

lgtm-com bot commented Oct 28, 2019

This pull request fixes 1 alert when merging d390bfd into cede5b3 - view on LGTM.com

fixed alerts:

  • 1 for Comparison result is always the same

@zdenop
Copy link
Contributor

zdenop commented Oct 29, 2019

I am fine with this change.
Also there is a need to move tesseractmain.cpp from api directory as it is not part of API (to progs?)...

@stweil
Copy link
Member

stweil commented Oct 29, 2019

Also there is a need to move tesseractmain.cpp from api directory as it is not part of API (to progs?)...

I would not mix this with the current pull request. One could also argue that tesseractmain.cpp is an example of using the API, so it can stay there.

@stweil
Copy link
Member

stweil commented Oct 29, 2019

The include statements in include/tesseract don't need the added tesseract/.

At least some Google projects do what I did. I'm not sure what's the right thing to do here.
https://github.com/google/leveldb/blob/master/include/leveldb/cache.h#L23

That are more examples of recursive Makefiles. They are not wrong, but they have several disadvantages. Parallel builds using more than one CPU are much slower with recursions. Additional recursive make processes need more RAM.

That's why I would like to move the autoconf builds away from recursive builds. The cmake and sw builds already use a flat build model.

@zdenop
Copy link
Contributor

zdenop commented Oct 29, 2019

I agree not to include it to this PR, but when we are "moving sources", it would be nice to make all known changes "together", so we could have stable source tree for some time ;-). IMO using examples instead of progs for tesseractmain.cpp would be misleading because tesseract executable is needed for training.

Maybe it would make sense to move tesseract library to separate repository and include it to tesseract repository as submodule. This should make easier to include tesseact library to other projects (e.g. wrappers)

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
@lgtm-com
Copy link

lgtm-com bot commented Oct 29, 2019

This pull request fixes 1 alert when merging 26ba7e2 into cede5b3 - view on LGTM.com

fixed alerts:

  • 1 for Comparison result is always the same

@stweil
Copy link
Member

stweil commented Oct 29, 2019

I fixed Travis CI and the unittest code now, but Appveyor CI still fails. @egorpugin, @zdenop, can we merge the pull request nevertheless and fix cppan.yml and sw.cpp later? Other changes to be done later:

  • Rename tesseract/tess_version.h to tesseract/version.h
  • Use flat autoconf make for include/tesseract instead of recursive make
  • Maybe replace #include "tesseract/*.h" by #include <tesseract/*.h>

@amitdo
Copy link
Collaborator Author

amitdo commented Oct 29, 2019

#594
Egor suggested to move the programs to 'tools', 'tools/training'.

About a non-recursive make build:
#974

@egorpugin egorpugin merged commit aeb98d9 into tesseract-ocr:master Oct 29, 2019
@amitdo amitdo deleted the move-headers2 branch October 29, 2019 09:49
@egorpugin
Copy link
Contributor

+1 for Makefile.am removal from include/tesseract

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants