Skip to content

Commit

Permalink
Add sw build system script (future cppan replacement).
Browse files Browse the repository at this point in the history
  • Loading branch information
egorpugin committed Nov 19, 2018
1 parent def7cdd commit b1e2004
Show file tree
Hide file tree
Showing 2 changed files with 191 additions and 1 deletion.
190 changes: 190 additions & 0 deletions sw.cpp
@@ -0,0 +1,190 @@
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;

libtesseract.Public += "HAVE_CONFIG_H"_d;
libtesseract.Public += "WINDLLNAME=\"tesseract\""_d;
libtesseract.Public += "_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS=1"_d;
libtesseract.Interface += sw::Shared, "TESS_IMPORTS"_d;
libtesseract.Private += sw::Shared, "TESS_EXPORTS"_d;

libtesseract.Public += "org.sw.demo.danbloomberg.leptonica-1"_dep;

if (s.Settings.TargetOS.Type == OSType::Windows)
libtesseract.Public += "ws2_32.lib"_l;

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__

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);
mftraining += "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");
}
}
2 changes: 1 addition & 1 deletion test
Submodule test updated 40 files
+0 −2 .gitignore
+0 −54 langtests/README.md
+0 −52 langtests/counttestset.sh
+0 −18 langtests/deva_setup.sh
+0 −18 langtests/deva_test.sh
+0 −24 langtests/frk_setup.sh
+0 −13 langtests/frk_test.sh
+0 −8 langtests/reports/4_best_Devanagari.summary
+0 −2 langtests/reports/4_best_frk.summary
+0 −8 langtests/reports/4_best_int_Devanagari.summary
+0 −2 langtests/reports/4_best_int_frk.summary
+0 −8 langtests/reports/4_best_int_san.summary
+0 −8 langtests/reports/4_best_san.summary
+0 −8 langtests/reports/4_fast_Devanagari.summary
+0 −2 langtests/reports/4_fast_Fraktur.summary
+0 −2 langtests/reports/4_fast_frk.summary
+0 −8 langtests/reports/4_fast_san.summary
+0 −8 langtests/reports/4_plus10k_san.summary
+0 −8 langtests/reports/4_plus20k_san.summary
+0 −8 langtests/reports/4_plus30k_san.summary
+0 −8 langtests/reports/4_plus40k_san.summary
+0 −105 langtests/runlangtests.sh
+0 −61 langtests/runtestset.sh
+0 −114 testing/eng_beam.unicharset
+0 −94 unlvtests/README.md
+0 −68 unlvtests/counttestset.sh
+0 −53 unlvtests/reorgdata.sh
+0 −1 unlvtests/reports/1995.bus.3B.sum
+0 −1 unlvtests/reports/1995.doe3.3B.sum
+0 −1 unlvtests/reports/1995.mag.3B.sum
+0 −1 unlvtests/reports/1995.news.3B.sum
+0 −9 unlvtests/reports/2.03.summary
+0 −9 unlvtests/reports/2.04.summary
+0 −2 unlvtests/reports/4_best_int_spa.summary
+0 −2 unlvtests/reports/4_best_spa.summary
+0 −9 unlvtests/reports/4_fast_eng.summary
+0 −2 unlvtests/reports/4_fast_spa.summary
+0 −135 unlvtests/runalltests.sh
+0 −109 unlvtests/runalltests_spa.sh
+0 −80 unlvtests/runtestset.sh

2 comments on commit b1e2004

@stweil
Copy link
Contributor

@stweil stweil commented on b1e2004 Nov 22, 2018

Choose a reason for hiding this comment

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

@egorpugin, were the changes for the test submodule intentional? You reverted some commits there.

@egorpugin
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. No, they were not. I'll revert.

Please sign in to comment.