sw.cpp 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. void build(Solution &s)
  2. {
  3. auto &tess = s.addProject("google.tesseract", "master");
  4. tess += Git("https://github.com/tesseract-ocr/tesseract", "", "{v}");
  5. auto &libtesseract = tess.addTarget<LibraryTarget>("libtesseract");
  6. {
  7. libtesseract.setChecks("libtesseract");
  8. libtesseract.ExportAllSymbols = true;
  9. libtesseract.PackageDefinitions = true;
  10. libtesseract += cpp14;
  11. libtesseract += "include/.*"_rr;
  12. libtesseract += "src/.*"_rr;
  13. libtesseract -= "src/lstm/.*\\.cc"_rr;
  14. libtesseract -= "src/training/.*"_rr;
  15. libtesseract -=
  16. "src/api/tesseractmain.cpp",
  17. "src/viewer/svpaint.cpp";
  18. libtesseract.Public += "include"_idir;
  19. libtesseract.Protected +=
  20. "src/opencl"_id,
  21. "src/ccmain"_id,
  22. "src/api"_id,
  23. "src/dict"_id,
  24. "src/viewer"_id,
  25. "src/wordrec"_id,
  26. "src/ccstruct"_id,
  27. "src/cutil"_id,
  28. "src/textord"_id,
  29. "src/ccutil"_id,
  30. "src/lstm"_id,
  31. "src/classify"_id,
  32. "src/arch"_id,
  33. "src/training"_id;
  34. if (libtesseract.getCompilerType() == CompilerType::MSVC ||
  35. libtesseract.getCompilerType() == CompilerType::ClangCl)
  36. {
  37. libtesseract += "__SSE4_1__"_def;
  38. libtesseract.CompileOptions.push_back("-arch:AVX2");
  39. // openmp
  40. //if (libtesseract.getOptions()["openmp"] == "true")
  41. if (0)
  42. {
  43. if (libtesseract.getCompilerType() == CompilerType::MSVC)
  44. libtesseract.CompileOptions.push_back("-openmp");
  45. else
  46. libtesseract.CompileOptions.push_back("-fopenmp");
  47. libtesseract += "_OPENMP=201107"_def;
  48. if (libtesseract.getBuildSettings().Native.ConfigurationType == ConfigurationType::Debug)
  49. libtesseract += "vcompd.lib"_slib;
  50. else
  51. libtesseract += "vcomp.lib"_slib;
  52. }
  53. }
  54. auto win_or_mingw =
  55. libtesseract.getBuildSettings().TargetOS.Type == OSType::Windows ||
  56. libtesseract.getBuildSettings().TargetOS.Type == OSType::Mingw
  57. ;
  58. // check fma flags
  59. libtesseract -= "src/arch/dotproductfma.cpp";
  60. if (libtesseract.getBuildSettings().TargetOS.Type != OSType::Windows)
  61. {
  62. libtesseract["src/arch/dotproductavx.cpp"].args.push_back("-mavx");
  63. libtesseract["src/arch/dotproductsse.cpp"].args.push_back("-msse4.1");
  64. libtesseract["src/arch/intsimdmatrixsse.cpp"].args.push_back("-msse4.1");
  65. libtesseract["src/arch/intsimdmatrixavx2.cpp"].args.push_back("-mavx2");
  66. }
  67. if (!win_or_mingw)
  68. libtesseract += "pthread"_slib;
  69. libtesseract.Public += "HAVE_CONFIG_H"_d;
  70. libtesseract.Public += "_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS=1"_d;
  71. libtesseract.Public += "HAVE_LIBARCHIVE"_d;
  72. libtesseract.Interface += sw::Shared, "TESS_IMPORTS"_d;
  73. libtesseract.Private += sw::Shared, "TESS_EXPORTS"_d;
  74. libtesseract.Public += "org.sw.demo.danbloomberg.leptonica"_dep;
  75. libtesseract.Public += "org.sw.demo.libarchive.libarchive"_dep;
  76. if (win_or_mingw)
  77. {
  78. libtesseract.Public += "ws2_32.lib"_slib;
  79. libtesseract.Protected += "NOMINMAX"_def;
  80. }
  81. libtesseract.Variables["TESSERACT_MAJOR_VERSION"] = libtesseract.Variables["PACKAGE_MAJOR_VERSION"];
  82. libtesseract.Variables["TESSERACT_MINOR_VERSION"] = libtesseract.Variables["PACKAGE_MINOR_VERSION"];
  83. libtesseract.Variables["TESSERACT_MICRO_VERSION"] = libtesseract.Variables["PACKAGE_PATCH_VERSION"];
  84. libtesseract.Variables["TESSERACT_VERSION_STR"] = "master";
  85. libtesseract.configureFile("include/tesseract/version.h.in", "tesseract/version.h");
  86. }
  87. //
  88. auto &tesseract = tess.addExecutable("tesseract");
  89. tesseract += cpp14;
  90. tesseract += "src/api/tesseractmain.cpp";
  91. tesseract += libtesseract;
  92. //
  93. auto &tessopt = tess.addStaticLibrary("tessopt");
  94. tessopt += cpp14;
  95. tessopt += "src/training/tessopt.*"_rr;
  96. tessopt.Public += libtesseract;
  97. //
  98. auto &common_training = tess.addStaticLibrary("common_training");
  99. common_training += cpp14;
  100. common_training +=
  101. "src/training/commandlineflags.cpp",
  102. "src/training/commandlineflags.h",
  103. "src/training/commontraining.cpp",
  104. "src/training/commontraining.h",
  105. "src/training/ctc.cpp",
  106. "src/training/ctc.h",
  107. "src/training/errorcounter.cpp",
  108. "src/training/errorcounter.h",
  109. "src/training/intfeaturedist.cpp",
  110. "src/training/intfeaturedist.h",
  111. "src/training/intfeaturemap.cpp",
  112. "src/training/intfeaturemap.h",
  113. "src/training/mastertrainer.cpp",
  114. "src/training/mastertrainer.h",
  115. "src/training/networkbuilder.cpp",
  116. "src/training/networkbuilder.h",
  117. "src/training/sampleiterator.cpp",
  118. "src/training/sampleiterator.h",
  119. "src/training/trainingsampleset.cpp",
  120. "src/training/trainingsampleset.h";
  121. common_training.Public += tessopt;
  122. //
  123. auto &unicharset_training = tess.addStaticLibrary("unicharset_training");
  124. unicharset_training += cpp14;
  125. unicharset_training +=
  126. "src/training/fileio.*"_rr,
  127. "src/training/icuerrorcode.*"_rr,
  128. "src/training/icuerrorcode.h",
  129. "src/training/lang_model_helpers.*"_rr,
  130. "src/training/lstmtester.*"_rr,
  131. "src/training/lstmtrainer.*"_rr,
  132. "src/training/normstrngs.*"_rr,
  133. "src/training/unicharset_training_utils.*"_rr,
  134. "src/training/validat.*"_rr;
  135. unicharset_training.Public += common_training;
  136. unicharset_training.Public += "org.sw.demo.unicode.icu.i18n"_dep;
  137. //
  138. #define ADD_EXE(n, ...) \
  139. auto &n = tess.addExecutable(#n); \
  140. n += cpp14; \
  141. n += "src/training/" #n ".*"_rr; \
  142. n.Public += __VA_ARGS__; \
  143. n
  144. ADD_EXE(ambiguous_words, libtesseract);
  145. ADD_EXE(classifier_tester, common_training);
  146. ADD_EXE(combine_lang_model, unicharset_training);
  147. ADD_EXE(combine_tessdata, libtesseract);
  148. ADD_EXE(cntraining, common_training);
  149. ADD_EXE(dawg2wordlist, libtesseract);
  150. ADD_EXE(mftraining, common_training) += "src/training/mergenf.*"_rr;
  151. ADD_EXE(shapeclustering, common_training);
  152. ADD_EXE(unicharset_extractor, unicharset_training);
  153. ADD_EXE(wordlist2dawg, libtesseract);
  154. ADD_EXE(lstmeval, unicharset_training);
  155. ADD_EXE(lstmtraining, unicharset_training);
  156. ADD_EXE(set_unicharset_properties, unicharset_training);
  157. ADD_EXE(text2image, unicharset_training);
  158. text2image += cpp14;
  159. text2image +=
  160. "src/training/boxchar.cpp",
  161. "src/training/boxchar.h",
  162. "src/training/degradeimage.cpp",
  163. "src/training/degradeimage.h",
  164. "src/training/icuerrorcode.h",
  165. "src/training/ligature_table.cpp",
  166. "src/training/ligature_table.h",
  167. "src/training/normstrngs.cpp",
  168. "src/training/normstrngs.h",
  169. "src/training/pango_font_info.cpp",
  170. "src/training/pango_font_info.h",
  171. "src/training/stringrenderer.cpp",
  172. "src/training/stringrenderer.h",
  173. "src/training/text2image.cpp",
  174. "src/training/tlog.cpp",
  175. "src/training/tlog.h",
  176. "src/training/util.h";
  177. text2image.Public += "org.sw.demo.gnome.pango.pangocairo"_dep;
  178. }
  179. void check(Checker &c)
  180. {
  181. auto &s = c.addSet("libtesseract");
  182. s.checkFunctionExists("getline");
  183. s.checkIncludeExists("dlfcn.h");
  184. s.checkIncludeExists("inttypes.h");
  185. s.checkIncludeExists("limits.h");
  186. s.checkIncludeExists("malloc.h");
  187. s.checkIncludeExists("memory.h");
  188. s.checkIncludeExists("stdbool.h");
  189. s.checkIncludeExists("stdint.h");
  190. s.checkIncludeExists("stdlib.h");
  191. s.checkIncludeExists("string.h");
  192. s.checkIncludeExists("sys/ipc.h");
  193. s.checkIncludeExists("sys/shm.h");
  194. s.checkIncludeExists("sys/stat.h");
  195. s.checkIncludeExists("sys/types.h");
  196. s.checkIncludeExists("sys/wait.h");
  197. s.checkIncludeExists("tiffio.h");
  198. s.checkIncludeExists("unistd.h");
  199. s.checkTypeSize("long long int");
  200. s.checkTypeSize("mbstate_t");
  201. s.checkTypeSize("off_t");
  202. s.checkTypeSize("size_t");
  203. s.checkTypeSize("void *");
  204. s.checkTypeSize("wchar_t");
  205. s.checkTypeSize("_Bool");
  206. {
  207. auto &c = s.checkSymbolExists("snprintf");
  208. c.Parameters.Includes.push_back("stdio.h");
  209. }
  210. }
Tip!

Press p or to see the previous file or, n or to see the next file