scripts/wrap/: added support for building with tesseract.
authorJulian Smith <[email protected]>
Thu, 31 Aug 2023 14:54:39 +0000 (15:54 +0100)
committerRobin Watts <[email protected]>
Thu, 31 Aug 2023 17:46:53 +0000 (18:46 +0100)
We build base C library with tesseract if build directory contains
`-tesseract-`.

scripts/wrap/__main__.py
scripts/wrap/state.py

index 0b49dea14441b18d48411439426f60a07fe1eec2..684d2e17905db28f45529dd447f4b48721f659b5 100644 (file)
@@ -1233,6 +1233,9 @@ def _get_m_command( build_dirs, j=None):
                 suffix = '.so'
                 build_prefix += f'{flag}-'
                 in_prefix = False
+            elif flag == 'tesseract':
+                make_args += ' HAVE_LEPTONICA=yes HAVE_TESSERACT=yes'
+                build_prefix += f'{flag}-'
             else:
                 if not in_prefix:
                     raise Exception( f'Unrecognised flag {flag!r} in {flags!r} in {build_dirs.dir_so!r}')
@@ -1588,11 +1591,15 @@ def build( build_dirs, swig_command, args, vs_upgrade):
                     #
                     win32_infix = _windows_vs_upgrade( vs_upgrade, build_dirs, devenv)
                     jlib.log(f'Building mupdfcpp.dll by running devenv ...')
+                    build = f'{windows_build_type}Python'
+                    if 'tesseract' in dir_so_flags:
+                        build += 'Tesseract'
+                    build += f'|{build_dirs.cpu.windows_config}'
                     command = (
                             f'cd {build_dirs.dir_mupdf}&&'
                             f'"{devenv}"'
                             f' platform/{win32_infix}/mupdf.sln'
-                            f' /Build "{windows_build_type}Python|{build_dirs.cpu.windows_config}"'
+                            f' /Build "{build}"'
                             f' /Project mupdfcpp'
                             )
                     jlib.system(command, verbose=1, out='log')
index bd070010f00963aa36c01d3c2bcca6a6f7a1b384..a9956c08686eb4aa030eaf11022ef81ef910891e 100644 (file)
@@ -334,12 +334,11 @@ class BuildDirs:
                 jlib.log('Adding suffix to {leaf!r}: {suffix!r}')
                 self.dir_so += suffix
                 leaf = os.path.basename(self.dir_so)
-            m = re.match( 'shared-([a-z]+)(-(x[0-9]+))?(-py([0-9.]+))?$', leaf)
+            m = re.search( '-(x[0-9]+)-py([0-9.]+)$', leaf)
             #log(f'self.dir_so={self.dir_so} {os.path.basename(self.dir_so)} m={m}')
             assert m, f'Failed to parse dir_so={self.dir_so!r} - should be *-x32|x64-pyA.B'
-            assert m.group(3), f'No cpu in self.dir_so: {self.dir_so}'
-            self.cpu = Cpu( m.group(3))
-            self.python_version = m.group(5)
+            self.cpu = Cpu( m.group(1))
+            self.python_version = m.group(2)
             #jlib.log('{self.cpu=} {self.python_version=} {dir_so=}')
         else:
             # Use Python we are running under.