@@ -3,7 +3,8 @@ name: Build
33on : [push]
44
55jobs :
6- build :
6+ # Linux, MacOS
7+ build-unix :
78 name : ${{ matrix.config.name }}
89 runs-on : ${{ matrix.config.os }}
910 defaults :
@@ -13,77 +14,191 @@ jobs:
1314 fail-fast : false
1415 matrix :
1516 config :
16- - os : windows-latest
17- name : ' Windows 32'
18- output : ' libtesseract32.dll'
19- cmake_args : ' -G "Visual Studio 16 2019" -A Win32'
20- sw_args : ' -platform x86 -win-mt'
21-
22- - os : windows-latest
23- name : ' Windows 64'
24- output : ' libtesseract64.dll'
25- cmake_args : ' -G "Visual Studio 16 2019"'
26- sw_args : ' -platform x64 -win-mt'
27-
2817 - os : ubuntu-20.04
2918 name : ' Linux 64'
3019 output : ' libtesseract64.so'
3120 cmake_args : ' -G "Unix Makefiles"'
32- sw_args : ' -platform x64'
21+ sw_args : ' -platform x64'
3322
3423 - os : macos-latest
3524 name : ' MacOS 64'
3625 output : ' libtesseract64.dylib'
3726 cmake_args : ' -G "Unix Makefiles"'
3827 sw_args : ' -platform x64 -os macos-10.13'
39-
28+
4029 steps :
413042- with :
43- submodules : true
44-
45- - uses : egorpugin/sw-action@master
46-
31+
4732 - name : Cache
4833 id : cache
49- 34+ 35+ with :
36+ key : ${{ matrix.config.name }}${{ matrix.config.sw_args }}
37+ path : |
38+ libs
39+ headers
40+
41+ - name : Download Python
42+ 5043 with :
51- path : storage
52- key : ${{ matrix.config.os }}${{ matrix.config.sw_args }}
44+ python-version : ' 3.9'
45+
46+ - name : Download Tesseract
47+ if : steps.cache.outputs.cache-hit != 'true'
48+ 49+ with :
50+ repository : tesseract-ocr/tesseract
51+ path : tesseract
52+
53+ - name : Download sw
54+ if : steps.cache.outputs.cache-hit != 'true'
55+ uses : egorpugin/sw-action@master
5356
5457 - name : Build Tesseract
58+ working-directory : tesseract
5559 if : steps.cache.outputs.cache-hit != 'true'
5660 run : |
57- ./sw build ${{ matrix.config.sw_args }} -storage-dir=storage -static -static-dependencies -config r org.sw.demo.google.tesseract.tesseract-master
61+ mv -f ../sw.cpp sw.cpp
62+ ../sw ${{ matrix.config.sw_args }} -storage-dir=storage -static -static-dependencies -config r build
63+
64+ - name : Find
65+ shell : python
66+ run : |
67+ import os
68+ from pathlib import Path
69+ from distutils.file_util import copy_file
70+
71+ libs = ['leptonica', 'zstd', 'png', 'jpeg', 'zlib', 'jbig', 'tiff', 'openjpeg' ,'webp', 'libtesseract', 'lzma', 'gif']
72+
73+ os.makedirs('libs', exist_ok=True)
74+ os.makedirs('headers/tesseract', exist_ok=True)
75+
76+ for filename in list(Path('tesseract').glob('**/*.a')):
77+ for lib in libs:
78+ if lib in str(filename):
79+ copy_file(filename, os.path.join('libs', os.path.basename(filename)))
80+
81+ for filename in list(Path('tesseract').glob('**/include/tesseract/*.h')) + list(Path('tesseract').glob('**/tesseract/version.h')):
82+ copy_file(filename, os.path.join('headers/tesseract', os.path.basename(filename)))
83+
84+ for filename in list(Path('libs').glob('**/*')) + list(Path('headers').glob('**/*')):
85+ print(filename)
5886
59- - name : Extract Headers & Libraries
87+ - name : Build Plugin
6088 continue-on-error : true
6189 run : |
62- mkdir -p libs
63- mkdir -p headers/tesseract
64- mkdir -p headers/leptonica
90+ cmake -S . ${{ matrix.config.cmake_args }}
91+ cmake --build . --config Release
6592
66- find "storage/pkg/" -name "*.a" -exec cp "{}" "libs" \;
67- find "storage/pkg/" -name "*.lib" -exec cp "{}" "libs" \;
93+ 94+ with :
95+ path : ${{ matrix.config.output }}
96+
97+ # Windows
98+ build-windows :
99+ name : ${{ matrix.config.name }}
100+ runs-on : ${{ matrix.config.os }}
101+ defaults :
102+ run :
103+ shell : bash
104+ strategy :
105+ fail-fast : false
106+ matrix :
107+ config :
108+ - os : windows-latest
109+ name : ' Windows 32'
110+ output : ' libtesseract32.dll'
111+ cmake_args : ' -G "MinGW Makefiles"'
112+ sw_args : ' -compiler=gcc -os mingw -platform x86 -win-mt'
113+
114+ - os : windows-latest
115+ name : ' Windows 64'
116+ output : ' libtesseract64.dll'
117+ cmake_args : ' -G "MinGW Makefiles"'
118+ sw_args : ' -compiler=gcc -os mingw -platform x64 -win-mt'
119+
120+ steps :
121+ 122+
123+ - name : Cache
124+ id : cache
125+ 126+ with :
127+ key : ${{ matrix.config.name }}${{ matrix.config.sw_args }}
128+ path : |
129+ libs
130+ headers
131+
132+ - name : Download Python
133+ 134+ with :
135+ python-version : ' 3.9'
68136
69- tesseract=$(find "storage/pkg/" -name "baseapi.h" -exec dirname {} \; -quit)
70- find "$tesseract" -name "*.h*" -exec cp "{}" headers/tesseract/ \;
71- find "storage/pkg/" -wholename "*tesseract/version.h" -exec cp "{}" headers/tesseract/ \;
137+ - name : Dependencies - Windows 64
138+ if : matrix.config.name == 'Windows 64'
139+ uses : msys2/setup-msys2@v2
140+ with :
141+ msystem : MINGW64
142+ install : mingw-w64-x86_64-gcc mingw-w64-x86_64-make mingw-w64-x86_64-cmake
143+ update : false
72144
73- leptonica=$(find "storage/pkg/" -name "*leptonica*" -exec dirname {} \; -quit)/../../../../
74- find "$leptonica" -name "*.h" -exec cp "{}" headers/leptonica/ \;
145+ - name : Dependencies - Windows 32
146+ if : matrix.config.name == 'Windows 32'
147+ uses : msys2/setup-msys2@v2
148+ with :
149+ msystem : MINGW32
150+ install : mingw-w64-i686-gcc mingw-w64-i686-make mingw-w64-i686-cmake
151+ update : false
75152
76- # Delete crap that causes linking errors
77- rm libs/*xxHash*
78- rm libs/*boost.thread*
153+ - name : Download Tesseract
154+ if : steps.cache.outputs.cache-hit != 'true'
155+ 156+ with :
157+ repository : tesseract-ocr/tesseract
158+ path : tesseract
159+
160+ - name : Download sw
161+ if : steps.cache.outputs.cache-hit != 'true'
162+ uses : egorpugin/sw-action@master
79163
164+ - name : Build Tesseract
165+ working-directory : tesseract
166+ shell : msys2 {0}
167+ if : steps.cache.outputs.cache-hit != 'true'
168+ run : |
169+ mv -f ../sw.cpp sw.cpp
170+ ../sw ${{ matrix.config.sw_args }} -storage-dir=storage -static -static-dependencies -config r build
171+
172+ - name : Find
173+ shell : python
174+ run : |
175+ import os
176+ from pathlib import Path
177+ from distutils.file_util import copy_file
178+
179+ libs = ['leptonica', 'zstd', 'png', 'jpeg', 'zlib', 'jbig', 'tiff', 'openjpeg' ,'webp', 'libtesseract', 'lzma', 'gif']
180+
181+ os.makedirs('libs', exist_ok=True)
182+ os.makedirs('headers/tesseract', exist_ok=True)
183+
184+ for filename in list(Path('tesseract').glob('**/*.lib')):
185+ for lib in libs:
186+ if lib in str(filename):
187+ copy_file(filename, os.path.join('libs', os.path.basename(filename)))
188+
189+ for filename in list(Path('tesseract').glob('**/include/tesseract/*.h')) + list(Path('tesseract').glob('**/tesseract/version.h')):
190+ copy_file(filename, os.path.join('headers/tesseract', os.path.basename(filename)))
191+
192+ for filename in list(Path('libs').glob('**/*')) + list(Path('headers').glob('**/*')):
193+ print(filename)
194+
80195 - name : Build Plugin
81196 continue-on-error : true
197+ shell : msys2 {0}
82198 run : |
83199 cmake -S . ${{ matrix.config.cmake_args }}
84- cmake --build . --config Release
85- find . -name libtesseract.binary -exec cp "{}" ${{ matrix.config.output }} \;
86-
87- 200+ cmake --build . --config Release
201+
202+ 88203 with :
89204 path : ${{ matrix.config.output }}
0 commit comments