2018-11-23 06:47:02 +08:00
|
|
|
void build(Solution &s)
|
|
|
|
{
|
|
|
|
auto &tess = s.addProject("google.tesseract", "master");
|
|
|
|
tess += Git("https://github.com/tesseract-ocr/tesseract", "", "{v}");
|
|
|
|
|
2020-12-26 08:48:57 +08:00
|
|
|
auto cppstd = cpp17;
|
|
|
|
|
2018-11-23 06:47:02 +08:00
|
|
|
auto &libtesseract = tess.addTarget<LibraryTarget>("libtesseract");
|
|
|
|
{
|
|
|
|
libtesseract.setChecks("libtesseract");
|
|
|
|
|
|
|
|
libtesseract.PackageDefinitions = true;
|
|
|
|
|
2020-12-26 08:48:57 +08:00
|
|
|
libtesseract += cppstd;
|
2020-01-26 05:36:50 +08:00
|
|
|
|
2020-12-31 21:31:10 +08:00
|
|
|
libtesseract += "TESS_API"_api;
|
2020-02-20 18:44:07 +08:00
|
|
|
libtesseract += "include/.*"_rr;
|
2020-01-26 04:03:16 +08:00
|
|
|
libtesseract += "src/.*"_rr;
|
2019-10-29 18:27:12 +08:00
|
|
|
libtesseract -= "src/lstm/.*\\.cc"_rr;
|
|
|
|
libtesseract -= "src/training/.*"_rr;
|
2019-10-11 05:46:23 +08:00
|
|
|
|
2018-11-23 06:47:02 +08:00
|
|
|
libtesseract -=
|
|
|
|
"src/api/tesseractmain.cpp",
|
|
|
|
"src/viewer/svpaint.cpp";
|
|
|
|
|
2019-10-29 19:57:32 +08:00
|
|
|
libtesseract.Public += "include"_idir;
|
2019-10-29 18:27:12 +08:00
|
|
|
libtesseract.Protected +=
|
2018-11-23 06:47:02 +08:00
|
|
|
"src/opencl"_id,
|
|
|
|
"src/ccmain"_id,
|
|
|
|
"src/api"_id,
|
|
|
|
"src/dict"_id,
|
|
|
|
"src/viewer"_id,
|
|
|
|
"src/wordrec"_id,
|
|
|
|
"src/ccstruct"_id,
|
|
|
|
"src/cutil"_id,
|
|
|
|
"src/textord"_id,
|
|
|
|
"src/ccutil"_id,
|
|
|
|
"src/lstm"_id,
|
|
|
|
"src/classify"_id,
|
2019-08-13 01:05:33 +08:00
|
|
|
"src/arch"_id,
|
|
|
|
"src/training"_id;
|
2018-11-23 06:47:02 +08:00
|
|
|
|
2019-05-13 06:54:23 +08:00
|
|
|
if (libtesseract.getCompilerType() == CompilerType::MSVC ||
|
|
|
|
libtesseract.getCompilerType() == CompilerType::ClangCl)
|
2019-01-16 00:12:46 +08:00
|
|
|
{
|
2019-04-08 03:59:38 +08:00
|
|
|
libtesseract += "__SSE4_1__"_def;
|
|
|
|
libtesseract.CompileOptions.push_back("-arch:AVX2");
|
2020-02-19 21:08:51 +08:00
|
|
|
|
|
|
|
// openmp
|
|
|
|
//if (libtesseract.getOptions()["openmp"] == "true")
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
if (libtesseract.getCompilerType() == CompilerType::MSVC)
|
|
|
|
libtesseract.CompileOptions.push_back("-openmp");
|
|
|
|
else
|
|
|
|
libtesseract.CompileOptions.push_back("-fopenmp");
|
|
|
|
libtesseract += "_OPENMP=201107"_def;
|
|
|
|
if (libtesseract.getBuildSettings().Native.ConfigurationType == ConfigurationType::Debug)
|
|
|
|
libtesseract += "vcompd.lib"_slib;
|
|
|
|
else
|
|
|
|
libtesseract += "vcomp.lib"_slib;
|
|
|
|
}
|
2020-01-26 04:03:16 +08:00
|
|
|
}
|
|
|
|
|
2020-03-17 22:57:10 +08:00
|
|
|
auto win_or_mingw =
|
|
|
|
libtesseract.getBuildSettings().TargetOS.Type == OSType::Windows ||
|
|
|
|
libtesseract.getBuildSettings().TargetOS.Type == OSType::Mingw
|
|
|
|
;
|
|
|
|
|
2020-01-26 04:03:16 +08:00
|
|
|
// check fma flags
|
|
|
|
libtesseract -= "src/arch/dotproductfma.cpp";
|
|
|
|
|
|
|
|
if (libtesseract.getBuildSettings().TargetOS.Type != OSType::Windows)
|
|
|
|
{
|
|
|
|
libtesseract["src/arch/dotproductavx.cpp"].args.push_back("-mavx");
|
|
|
|
libtesseract["src/arch/dotproductsse.cpp"].args.push_back("-msse4.1");
|
|
|
|
libtesseract["src/arch/intsimdmatrixsse.cpp"].args.push_back("-msse4.1");
|
|
|
|
libtesseract["src/arch/intsimdmatrixavx2.cpp"].args.push_back("-mavx2");
|
2019-01-16 00:12:46 +08:00
|
|
|
}
|
2020-03-17 22:57:10 +08:00
|
|
|
if (!win_or_mingw)
|
|
|
|
libtesseract += "pthread"_slib;
|
2019-01-16 00:12:46 +08:00
|
|
|
|
2018-11-23 06:47:02 +08:00
|
|
|
libtesseract.Public += "HAVE_CONFIG_H"_d;
|
|
|
|
libtesseract.Public += "_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS=1"_d;
|
2019-03-11 05:03:45 +08:00
|
|
|
libtesseract.Public += "HAVE_LIBARCHIVE"_d;
|
2018-11-23 06:47:02 +08:00
|
|
|
|
2019-09-26 05:34:36 +08:00
|
|
|
libtesseract.Public += "org.sw.demo.danbloomberg.leptonica"_dep;
|
2019-03-11 05:03:45 +08:00
|
|
|
libtesseract.Public += "org.sw.demo.libarchive.libarchive"_dep;
|
2018-11-23 06:47:02 +08:00
|
|
|
|
2020-03-17 22:57:10 +08:00
|
|
|
if (win_or_mingw)
|
2019-04-02 03:38:01 +08:00
|
|
|
{
|
2019-09-26 05:22:07 +08:00
|
|
|
libtesseract.Public += "ws2_32.lib"_slib;
|
2019-04-02 03:38:01 +08:00
|
|
|
libtesseract.Protected += "NOMINMAX"_def;
|
|
|
|
}
|
2018-11-23 06:47:02 +08:00
|
|
|
|
2020-12-30 07:10:25 +08:00
|
|
|
if (libtesseract.getCompilerType() == CompilerType::MSVC)
|
|
|
|
libtesseract.Protected.CompileOptions.push_back("-utf-8");
|
|
|
|
|
2018-11-23 06:47:02 +08:00
|
|
|
libtesseract.Variables["TESSERACT_MAJOR_VERSION"] = libtesseract.Variables["PACKAGE_MAJOR_VERSION"];
|
|
|
|
libtesseract.Variables["TESSERACT_MINOR_VERSION"] = libtesseract.Variables["PACKAGE_MINOR_VERSION"];
|
|
|
|
libtesseract.Variables["TESSERACT_MICRO_VERSION"] = libtesseract.Variables["PACKAGE_PATCH_VERSION"];
|
|
|
|
libtesseract.Variables["TESSERACT_VERSION_STR"] = "master";
|
2019-10-29 18:40:17 +08:00
|
|
|
libtesseract.configureFile("include/tesseract/version.h.in", "tesseract/version.h");
|
2018-11-23 06:47:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
auto &tesseract = tess.addExecutable("tesseract");
|
2020-12-28 04:00:28 +08:00
|
|
|
{
|
2020-12-28 07:32:36 +08:00
|
|
|
tesseract += cppstd;
|
|
|
|
tesseract += "src/api/tesseractmain.cpp";
|
|
|
|
tesseract += libtesseract;
|
2020-12-28 04:00:28 +08:00
|
|
|
}
|
2019-05-17 02:47:42 +08:00
|
|
|
|
2020-12-28 09:34:52 +08:00
|
|
|
auto &training = tess.addDirectory("training");
|
|
|
|
|
2019-05-17 02:47:42 +08:00
|
|
|
//
|
2020-12-28 09:34:52 +08:00
|
|
|
auto &tessopt = training.addStaticLibrary("tessopt");
|
2020-12-28 04:00:28 +08:00
|
|
|
{
|
2020-12-28 07:32:36 +08:00
|
|
|
tessopt += cppstd;
|
|
|
|
tessopt += "src/training/tessopt.*"_rr;
|
|
|
|
tessopt.Public += libtesseract;
|
2020-12-28 04:00:28 +08:00
|
|
|
}
|
2019-05-17 02:47:42 +08:00
|
|
|
|
|
|
|
//
|
2020-12-31 21:31:10 +08:00
|
|
|
auto &common_training = training.addLibrary("common_training");
|
2020-12-28 04:00:28 +08:00
|
|
|
{
|
2020-12-31 21:31:10 +08:00
|
|
|
common_training += "TESS_COMMON_TRAINING_API"_api;
|
2020-12-28 07:32:36 +08:00
|
|
|
common_training += cppstd;
|
2020-12-31 23:27:03 +08:00
|
|
|
common_training += "src/training/common/.*"_rr;
|
|
|
|
common_training.Public += "src/training/common"_idir;
|
2020-12-28 07:32:36 +08:00
|
|
|
common_training.Public += tessopt;
|
2020-12-28 04:00:28 +08:00
|
|
|
}
|
2019-05-17 02:47:42 +08:00
|
|
|
|
|
|
|
//
|
2020-12-31 21:31:10 +08:00
|
|
|
auto &unicharset_training = training.addLibrary("unicharset_training");
|
2020-12-28 04:00:28 +08:00
|
|
|
{
|
2020-12-31 21:31:10 +08:00
|
|
|
unicharset_training += "TESS_UNICHARSET_TRAINING_API"_api;
|
2020-12-28 07:32:36 +08:00
|
|
|
unicharset_training += cppstd;
|
2020-12-31 23:27:03 +08:00
|
|
|
unicharset_training += "src/training/unicharset/.*"_rr;
|
|
|
|
unicharset_training.Public += "src/training/unicharset"_idir;
|
2020-12-28 07:32:36 +08:00
|
|
|
unicharset_training.Public += common_training;
|
|
|
|
unicharset_training.Public += "org.sw.demo.unicode.icu.i18n"_dep;
|
2020-12-28 04:00:28 +08:00
|
|
|
}
|
2019-05-17 02:47:42 +08:00
|
|
|
|
2018-11-23 06:47:02 +08:00
|
|
|
//
|
2020-12-28 09:34:52 +08:00
|
|
|
#define ADD_EXE(n, ...) \
|
|
|
|
auto &n = training.addExecutable(#n); \
|
|
|
|
n += cppstd; \
|
|
|
|
n += "src/training/" #n ".*"_rr; \
|
|
|
|
n.Public += __VA_ARGS__; \
|
2019-01-16 00:12:46 +08:00
|
|
|
n
|
2018-11-23 06:47:02 +08:00
|
|
|
|
2020-12-31 21:31:10 +08:00
|
|
|
ADD_EXE(ambiguous_words, common_training);
|
2018-11-23 06:47:02 +08:00
|
|
|
ADD_EXE(classifier_tester, common_training);
|
|
|
|
ADD_EXE(combine_lang_model, unicharset_training);
|
2020-12-31 21:31:10 +08:00
|
|
|
ADD_EXE(combine_tessdata, common_training);
|
2018-11-23 06:47:02 +08:00
|
|
|
ADD_EXE(cntraining, common_training);
|
2020-12-31 21:31:10 +08:00
|
|
|
ADD_EXE(dawg2wordlist, common_training);
|
2019-01-16 00:12:46 +08:00
|
|
|
ADD_EXE(mftraining, common_training) += "src/training/mergenf.*"_rr;
|
2018-11-23 06:47:02 +08:00
|
|
|
ADD_EXE(shapeclustering, common_training);
|
|
|
|
ADD_EXE(unicharset_extractor, unicharset_training);
|
2020-12-31 21:31:10 +08:00
|
|
|
ADD_EXE(wordlist2dawg, common_training);
|
2018-11-23 06:47:02 +08:00
|
|
|
ADD_EXE(lstmeval, unicharset_training);
|
|
|
|
ADD_EXE(lstmtraining, unicharset_training);
|
|
|
|
ADD_EXE(set_unicharset_properties, unicharset_training);
|
2020-12-31 21:31:10 +08:00
|
|
|
ADD_EXE(merge_unicharsets, common_training);
|
2018-11-23 06:47:02 +08:00
|
|
|
|
2020-12-28 07:32:36 +08:00
|
|
|
//
|
2020-12-31 21:31:10 +08:00
|
|
|
auto &pango_training = training.addLibrary("pango_training");
|
2020-12-28 07:32:36 +08:00
|
|
|
{
|
2020-12-31 21:31:10 +08:00
|
|
|
pango_training += "TESS_PANGO_TRAINING_API"_api;
|
2020-12-28 07:32:36 +08:00
|
|
|
pango_training += cppstd;
|
2020-12-31 23:27:03 +08:00
|
|
|
pango_training += "src/training/pango/.*"_rr;
|
|
|
|
pango_training.Public += "src/training/pango"_idir;
|
2020-12-28 07:32:36 +08:00
|
|
|
pango_training.Public += unicharset_training;
|
|
|
|
pango_training.Public += "org.sw.demo.gnome.pango.pangocairo"_dep;
|
|
|
|
}
|
|
|
|
|
|
|
|
ADD_EXE(text2image, pango_training);
|
|
|
|
{
|
|
|
|
text2image += cppstd;
|
|
|
|
text2image +=
|
|
|
|
"src/training/degradeimage.cpp",
|
|
|
|
"src/training/degradeimage.h",
|
2020-12-31 23:37:13 +08:00
|
|
|
"src/training/text2image.cpp"
|
2020-12-28 07:32:36 +08:00
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2020-12-29 01:37:35 +08:00
|
|
|
if (!s.getExternalVariables()["with-tests"])
|
|
|
|
return;
|
|
|
|
|
2020-12-31 21:31:10 +08:00
|
|
|
// tests
|
2020-12-28 04:00:28 +08:00
|
|
|
{
|
2020-12-30 07:39:51 +08:00
|
|
|
auto &test = tess.addDirectory("test");
|
|
|
|
test.Scope = TargetScope::Test;
|
|
|
|
|
|
|
|
auto add_test = [&test, &s, &cppstd, &libtesseract, &pango_training](const String &name) -> decltype(auto)
|
|
|
|
{
|
|
|
|
auto &t = test.addTarget<ExecutableTarget>(name);
|
|
|
|
t += cppstd;
|
|
|
|
t += path("unittest/" + name + "_test.cc");
|
|
|
|
|
|
|
|
t += "SW_TESTING"_def;
|
|
|
|
|
|
|
|
auto datadir = test.SourceDir / "tessdata_unittest";
|
|
|
|
t += Definition("TESSBIN_DIR=\"" + ""s + "\"");
|
|
|
|
|
|
|
|
t += Definition("TESTING_DIR=\"" + to_printable_string(normalize_path(test.SourceDir / "test/testing")) + "\"");
|
|
|
|
t += Definition("TESTDATA_DIR=\"" + to_printable_string(normalize_path(test.SourceDir / "test/testdata")) + "\"");
|
|
|
|
|
|
|
|
t += Definition("LANGDATA_DIR=\"" + to_printable_string(normalize_path(datadir / "langdata_lstm")) + "\"");
|
|
|
|
t += Definition("TESSDATA_DIR=\"" + to_printable_string(normalize_path(datadir / "tessdata")) + "\"");
|
|
|
|
t += Definition("TESSDATA_BEST_DIR=\"" + to_printable_string(normalize_path(datadir / "tessdata_best")) + "\"");
|
|
|
|
|
|
|
|
// we push all deps to all tests simplify things
|
|
|
|
t += pango_training;
|
|
|
|
t += "org.sw.demo.google.googletest.gmock.main"_dep;
|
|
|
|
t += "org.sw.demo.google.googletest.gtest.main"_dep;
|
|
|
|
t += "org.sw.demo.google.abseil"_dep;
|
|
|
|
|
|
|
|
if (t.getCompilerType() == CompilerType::MSVC)
|
|
|
|
t.CompileOptions.push_back("-utf-8");
|
|
|
|
|
|
|
|
libtesseract.addTest(t, name);
|
|
|
|
|
|
|
|
return t;
|
|
|
|
};
|
|
|
|
|
|
|
|
Strings tests{
|
|
|
|
"apiexample",
|
|
|
|
"applybox",
|
|
|
|
"baseapi",
|
2020-12-31 04:35:17 +08:00
|
|
|
"baseapi_thread",
|
2020-12-30 07:39:51 +08:00
|
|
|
"bitvector",
|
|
|
|
"cleanapi",
|
|
|
|
"colpartition",
|
|
|
|
"commandlineflags",
|
|
|
|
"denorm",
|
|
|
|
"equationdetect",
|
|
|
|
"fileio",
|
|
|
|
"heap",
|
|
|
|
"imagedata",
|
|
|
|
"indexmapbidi",
|
|
|
|
"intfeaturemap",
|
|
|
|
"intsimdmatrix",
|
|
|
|
"lang_model",
|
|
|
|
"layout",
|
|
|
|
"ligature_table",
|
|
|
|
"linlsq",
|
|
|
|
"lstm_recode",
|
|
|
|
"lstm_squashed",
|
|
|
|
"lstm",
|
|
|
|
"lstmtrainer",
|
|
|
|
"loadlang",
|
|
|
|
"mastertrainer",
|
|
|
|
"matrix",
|
2020-12-31 04:35:17 +08:00
|
|
|
"networkio",
|
2020-12-30 07:39:51 +08:00
|
|
|
"normstrngs",
|
|
|
|
"nthitem",
|
|
|
|
"osd",
|
|
|
|
"pagesegmode",
|
|
|
|
"pango_font_info",
|
|
|
|
"paragraphs",
|
|
|
|
"params_model",
|
|
|
|
"progress",
|
|
|
|
"qrsequence",
|
|
|
|
"recodebeam",
|
|
|
|
"rect",
|
|
|
|
"resultiterator",
|
|
|
|
"scanutils",
|
|
|
|
"shapetable",
|
|
|
|
"stats",
|
|
|
|
"stringrenderer",
|
2020-12-31 04:35:17 +08:00
|
|
|
"stridemap",
|
2020-12-30 07:39:51 +08:00
|
|
|
"tablefind",
|
|
|
|
"tablerecog",
|
|
|
|
"tabvector",
|
2020-12-31 04:35:17 +08:00
|
|
|
"tatweel",
|
2020-12-30 07:39:51 +08:00
|
|
|
"textlineprojection",
|
|
|
|
"tfile",
|
|
|
|
"unichar",
|
|
|
|
"unicharcompress",
|
|
|
|
"unicharset",
|
|
|
|
"validate_grapheme",
|
|
|
|
"validate_indic",
|
|
|
|
"validate_khmer",
|
|
|
|
"validate_myanmar",
|
|
|
|
"validator",
|
|
|
|
};
|
|
|
|
for (auto t : tests)
|
|
|
|
add_test(t);
|
|
|
|
auto &dt = add_test("dawg");
|
|
|
|
dt += Definition("wordlist2dawg_prog=\"" + to_printable_string(normalize_path(wordlist2dawg.getOutputFile())) + "\"");
|
|
|
|
dt += Definition("dawg2wordlist_prog=\"" + to_printable_string(normalize_path(dawg2wordlist.getOutputFile())) + "\"");
|
|
|
|
}
|
2018-11-23 06:47:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void check(Checker &c)
|
|
|
|
{
|
|
|
|
auto &s = c.addSet("libtesseract");
|
|
|
|
s.checkFunctionExists("getline");
|
|
|
|
s.checkIncludeExists("dlfcn.h");
|
|
|
|
s.checkIncludeExists("inttypes.h");
|
|
|
|
s.checkIncludeExists("memory.h");
|
|
|
|
s.checkIncludeExists("stdint.h");
|
|
|
|
s.checkIncludeExists("stdlib.h");
|
|
|
|
s.checkIncludeExists("string.h");
|
|
|
|
s.checkIncludeExists("sys/stat.h");
|
|
|
|
s.checkIncludeExists("sys/types.h");
|
|
|
|
s.checkIncludeExists("tiffio.h");
|
|
|
|
s.checkIncludeExists("unistd.h");
|
|
|
|
s.checkTypeSize("long long int");
|
|
|
|
s.checkTypeSize("size_t");
|
|
|
|
s.checkTypeSize("void *");
|
|
|
|
s.checkTypeSize("wchar_t");
|
|
|
|
{
|
|
|
|
auto &c = s.checkSymbolExists("snprintf");
|
|
|
|
c.Parameters.Includes.push_back("stdio.h");
|
|
|
|
}
|
|
|
|
}
|
2020-01-26 08:48:39 +08:00
|
|
|
|