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