Skip to content

Commit 4fb2035

Browse files
committed
Disable CPU extensions (SSE, AVX)
1 parent 6539962 commit 4fb2035

File tree

5 files changed

+128
-18
lines changed

5 files changed

+128
-18
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818
output: 'libtesseract32.dll'
1919
cmake_args: '-G "Visual Studio 16 2019" -A Win32'
2020
sw_args: '-platform x86 -win-mt'
21-
platform: 'x32'
2221

2322
- os: windows-latest
2423
name: 'Windows 64'
@@ -40,37 +39,43 @@ jobs:
4039

4140
steps:
4241
- uses: actions/checkout@v2
42+
with:
43+
submodules: true
44+
4345
- uses: egorpugin/sw-action@master
44-
46+
4547
- name: Cache
4648
id: cache
4749
uses: actions/[email protected]
4850
with:
4951
path: storage
50-
key: ${{ matrix.config.name }}${{ matrix.config.sw_args }}
52+
key: ${{ matrix.config.os }}${{ matrix.config.sw_args }}
5153

5254
- name: Build Tesseract
5355
if: steps.cache.outputs.cache-hit != 'true'
5456
run: |
55-
./sw build ${{ matrix.config.sw_args }} -storage-dir=storage -static -static-dependencies -config r org.sw.demo.google.tesseract.tesseract-master
56-
57+
mv -f sw.cpp tesseract/sw.cpp
58+
./sw ${{ matrix.config.sw_args }} -d tesseract -storage-dir ../storage -static -static-dependencies -config r build
59+
mv tesseract storage/pkg
60+
5761
- name: Extract Headers & Libraries
62+
continue-on-error: true
5863
run: |
5964
mkdir -p libs
65+
mkdir -p headers/tesseract
66+
mkdir -p headers/leptonica
67+
6068
find "storage/pkg/" -name "*.a" -exec cp "{}" "libs" \;
6169
find "storage/pkg/" -name "*.lib" -exec cp "{}" "libs" \;
6270
63-
mkdir -p leptonica
64-
leptonica=$(find "storage/pkg/" -name "allheaders.h" -exec dirname {} \; -quit)
65-
find "$leptonica" -name "*.h*" -exec cp "{}" leptonica/ \;
66-
find "storage/pkg/" -name "*endianness.h*" -exec cp "{}" leptonica/ \;
71+
find "storage/pkg/tesseract/include" -name "*.h" -exec cp "{}" headers/tesseract/ \;
72+
find "storage/pkg/tesseract" -name "version.h" -exec cp "{}" headers/tesseract/ \; -quit
6773
68-
mkdir -p tesseract
69-
tesseract=$(find "storage/pkg/" -name "baseapi.h" -exec dirname {} \; -quit)
70-
find "$tesseract" -name "*.h*" -exec cp "{}" tesseract/ \;
71-
find "storage/pkg/" -wholename "*tesseract/version.h" -exec cp "{}" tesseract/ \;
74+
leptonica=$(find "storage/pkg/" -name "*leptonica*" -exec dirname {} \; -quit)/../../../../
75+
find "$leptonica" -name "*.h" -exec cp "{}" headers/leptonica/ \;
7276
7377
- name: Build Plugin
78+
continue-on-error: true
7479
run: |
7580
cmake -S . ${{ matrix.config.cmake_args }}
7681
cmake --build . --config Release

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "tesseract"]
2+
path = tesseract
3+
url = https://github.com/tesseract-ocr/tesseract

CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
cmake_minimum_required(VERSION 3.15)
22
project(Tesseract DESCRIPTION "tesseract")
33

4-
SET(CMAKE_BUILD_TYPE Release)
54
SET(CMAKE_CXX_STANDARD 20)
65
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Minimum OS X deployment version" FORCE)
76

87
# ----------------------------- LINKER -----------------------------
98

10-
file(GLOB TESSERACT_LIBRARIES
11-
"libs/*.a"
12-
"libs/*.lib"
9+
file(
10+
GLOB TESSERACT_LIBRARIES
11+
"libs/*.a"
12+
"libs/*.lib"
1313
)
1414

1515
IF(WIN32)
@@ -31,7 +31,7 @@ set(SOURCE_LIST
3131
)
3232

3333
set(INCLUDE_DIRECTORIES
34-
.
34+
headers
3535
)
3636

3737
# ---------------------------- COMPILE ----------------------------

sw.cpp

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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+
6+
auto &libtesseract = tess.addTarget<LibraryTarget>("libtesseract");
7+
{
8+
libtesseract.setChecks("libtesseract");
9+
10+
libtesseract.ExportAllSymbols = true;
11+
libtesseract.PackageDefinitions = true;
12+
13+
libtesseract += cpp14;
14+
15+
libtesseract += "include/.*"_rr;
16+
libtesseract += "src/.*"_rr;
17+
libtesseract -= "src/lstm/.*\\.cc"_rr;
18+
libtesseract -= "src/training/.*"_rr;
19+
20+
libtesseract -=
21+
"src/api/tesseractmain.cpp",
22+
"src/viewer/svpaint.cpp";
23+
24+
libtesseract.Public += "include"_idir;
25+
libtesseract.Protected +=
26+
"src/opencl"_id,
27+
"src/ccmain"_id,
28+
"src/api"_id,
29+
"src/dict"_id,
30+
"src/viewer"_id,
31+
"src/wordrec"_id,
32+
"src/ccstruct"_id,
33+
"src/cutil"_id,
34+
"src/textord"_id,
35+
"src/ccutil"_id,
36+
"src/lstm"_id,
37+
"src/classify"_id,
38+
"src/arch"_id,
39+
"src/training"_id;
40+
41+
auto win_or_mingw =
42+
libtesseract.getBuildSettings().TargetOS.Type == OSType::Windows ||
43+
libtesseract.getBuildSettings().TargetOS.Type == OSType::Mingw
44+
;
45+
46+
libtesseract -= "src/arch/dotproductfma.cpp";
47+
libtesseract -= "src/arch/dotproductavx.cpp";
48+
libtesseract -= "src/arch/dotproductsse.cpp";
49+
libtesseract -= "src/arch/intsimdmatrixsse.cpp";
50+
libtesseract -= "src/arch/intsimdmatrixavx2.cpp";
51+
52+
if (!win_or_mingw)
53+
libtesseract += "pthread"_slib;
54+
55+
libtesseract.Public += "HAVE_CONFIG_H"_d;
56+
libtesseract.Public += "_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS=1"_d;
57+
libtesseract.Public += "HAVE_LIBARCHIVE"_d;
58+
libtesseract.Interface += sw::Shared, "TESS_IMPORTS"_d;
59+
libtesseract.Private += sw::Shared, "TESS_EXPORTS"_d;
60+
61+
libtesseract.Public += "org.sw.demo.danbloomberg.leptonica"_dep;
62+
libtesseract.Public += "org.sw.demo.libarchive.libarchive"_dep;
63+
64+
if (win_or_mingw)
65+
{
66+
libtesseract.Public += "ws2_32.lib"_slib;
67+
libtesseract.Protected += "NOMINMAX"_def;
68+
}
69+
70+
libtesseract.Variables["TESSERACT_MAJOR_VERSION"] = libtesseract.Variables["PACKAGE_MAJOR_VERSION"];
71+
libtesseract.Variables["TESSERACT_MINOR_VERSION"] = libtesseract.Variables["PACKAGE_MINOR_VERSION"];
72+
libtesseract.Variables["TESSERACT_MICRO_VERSION"] = libtesseract.Variables["PACKAGE_PATCH_VERSION"];
73+
libtesseract.Variables["TESSERACT_VERSION_STR"] = "master";
74+
libtesseract.configureFile("include/tesseract/version.h.in", "tesseract/version.h");
75+
}
76+
}
77+
78+
void check(Checker &c)
79+
{
80+
auto &s = c.addSet("libtesseract");
81+
s.checkFunctionExists("getline");
82+
s.checkIncludeExists("dlfcn.h");
83+
s.checkIncludeExists("inttypes.h");
84+
s.checkIncludeExists("memory.h");
85+
s.checkIncludeExists("stdint.h");
86+
s.checkIncludeExists("stdlib.h");
87+
s.checkIncludeExists("string.h");
88+
s.checkIncludeExists("sys/stat.h");
89+
s.checkIncludeExists("sys/types.h");
90+
s.checkIncludeExists("tiffio.h");
91+
s.checkIncludeExists("unistd.h");
92+
s.checkTypeSize("long long int");
93+
s.checkTypeSize("size_t");
94+
s.checkTypeSize("void *");
95+
s.checkTypeSize("wchar_t");
96+
{
97+
auto &c = s.checkSymbolExists("snprintf");
98+
c.Parameters.Includes.push_back("stdio.h");
99+
}
100+
}
101+

tesseract

Submodule tesseract added at b19e3ee

0 commit comments

Comments
 (0)