scripts/wrap/: make use of jlib.system()'s support for multiline commands.
authorJulian Smith <[email protected]>
Fri, 14 Jun 2024 21:05:10 +0000 (22:05 +0100)
committerRobin Watts <[email protected]>
Tue, 23 Jul 2024 19:02:02 +0000 (20:02 +0100)
Also fix --test-cpp, need to build with -DNDEBUG.

scripts/wrap/__main__.py
scripts/wrap/swig.py

index 854e848df2e79738d7643f7c1d097d8a6fa3b5b3..736b9378ccfc6c322600741e57e1583623bc9b86 100644 (file)
@@ -1701,7 +1701,7 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
                                         -I {include1}
                                         -I {include2}
                                         {cpp_file}
-                                    ''').strip().replace( '\n', ' \\\n')
+                                    ''')
                             jlib.build(
                                     [include1, include2, cpp_file],
                                     o_file,
@@ -1719,7 +1719,7 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
                                     -I {include2}
                                     {" ".join(o_files)}
                                     {link_l_flags(libmupdf)}
-                                ''').strip().replace( '\n', ' \\\n')
+                                ''')
                                 )
                         jlib.build(
                                 [include1, include2] + o_files,
@@ -1744,7 +1744,7 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
                                     -I {include2}
                                     {cpp_files_text}
                                     {link_l_flags(libmupdf)}
-                                ''').strip().replace( '\n', ' \\\n')
+                                ''')
                                 )
                         command_was_run = jlib.build(
                                 [include1, include2] + cpp_files,
@@ -1781,7 +1781,7 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
                                         -I {include2}
                                         -o {ofile}
                                         {cpp_file}
-                                    ''').strip().replace( '\n', ' \\\n')
+                                    ''')
                                     )
                             jlib.build(
                                     [include1, include2, cpp_file],
@@ -1816,7 +1816,7 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
                                     -o {libmupdfcpp_so}
                                     {' '.join(ofiles)}
                                     {' '.join(alibs)}
-                                ''').strip().replace( '\n', ' \\\n')
+                                ''')
                         jlib.build(
                                 ofiles + alibs,
                                 libmupdfcpp_so,
@@ -2079,7 +2079,7 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
                                         {flags_link2}
                                         {link_l_flags( [libmupdf, libmupdfcpp])}
                                         -Wno-deprecated-declarations
-                                    ''').strip().replace( '\n', ' \\\n')
+                                    ''')
                             )
                             infiles = [
                                     cpp2_path,
@@ -2130,7 +2130,7 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
                                     -Wno-deprecated-declarations
                                     -Wno-free-nonheap-object
                                     -DSWIG_PYTHON_SILENT_MEMLEAK
-                                ''').strip().replace( '\n', ' \\\n')
+                                ''')
                                 )
                         infiles = [
                                 cpp_path,
@@ -2154,7 +2154,7 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
                                     -shared
                                     {flags_link}
                                     {link_l_flags( sos)}
-                                ''').strip().replace( '\n', ' \\\n')
+                                ''')
                                 )
                         infiles = [
                                 o_file,
@@ -2188,7 +2188,7 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
                                     -DSWIG_PYTHON_SILENT_MEMLEAK
                                     {flags_link}
                                     {link_l_flags( sos)}
-                                ''').strip().replace( '\n', ' \\\n')
+                                ''')
                                 )
                         infiles = [
                                 cpp_path,
@@ -2730,8 +2730,7 @@ def main2():
                         f' -I {build_dirs.dir_mupdf}/include'
                         f' -I {build_dirs.dir_mupdf}/platform/c++/include'
                         )
-                # Enable asserts in this test.
-                cpp_flags = build_dirs.cpp_flags.replace( '-DNDEBUG', '')
+                cpp_flags = build_dirs.cpp_flags
                 if state.state_.windows:
                     win32_infix = _windows_vs_upgrade( vs_upgrade, build_dirs, devenv=None)
                     windows_build_type = build_dirs.windows_build_type()
@@ -2746,7 +2745,7 @@ def main2():
                                 /link
                                 {lib}
                                 /out:{exe}
-                            ''').replace('\n', ' ')
+                            ''')
                     jlib.system(command, verbose=1)
                     path = os.environ.get('PATH')
                     env_extra = dict(PATH = f'{build_dirs.dir_so}{os.pathsep}{path}' if path else build_dirs.dir_so)
@@ -2770,7 +2769,7 @@ def main2():
                                 {includes}
                                 {src}
                                 {link_l_flags( [libmupdf, libmupdfcpp])}
-                            ''').replace('\n', '\\\n')
+                            ''')
                     jlib.system(command, verbose=1)
                     jlib.system( 'pwd', verbose=1)
                     if state.state_.macos:
index 60ae490551d90777b90f1f94751e9e7b03661f96..2f2f3dc9426341f55d6eb4b945fbf9f132ec1b88 100644 (file)
@@ -1789,9 +1789,7 @@ def build_swig(
             # include/mupdf/fitz/heap.h. Otherwise swig's preprocessor seems to
             # ignore #undef's in include/mupdf/fitz/heap-imp.h then complains
             # about redefinition of macros in include/mupdf/fitz/heap.h.
-            command = (
-                    textwrap.dedent(
-                    f'''
+            command = (f'''
                     "{swig_command}"
                         {"-D_WIN32" if state_.windows else ""}
                         -c++
@@ -1810,8 +1808,7 @@ def build_swig(
                         -ignoremissing
                         -DMUPDF_FITZ_HEAP_H
                         {swig_i}
-                    ''').strip().replace( '\n', "" if state_.windows else " \\\n")
-                    )
+                    ''')
             return command
 
         def modify_py( rebuilt, swig_py, do_enums):
@@ -1889,9 +1886,7 @@ def build_swig(
             # swig generated c dll reference to a c sharp project".
             #
             dllimport = 'mupdfcsharp.dll'
-        command = (
-                textwrap.dedent(
-                f'''
+        command = (f'''
                 "{swig_command}"
                     {"-D_WIN32" if state_.windows else ""}
                     -c++
@@ -1911,8 +1906,8 @@ def build_swig(
                     -ignoremissing
                     -DMUPDF_FITZ_HEAP_H
                     {os.path.relpath(swig_i)}
-                ''').strip().replace( '\n', "" if state_.windows else "\\\n")
-                )
+                ''')
+
         rebuilt = jlib.build(
                 (swig_i, include1, include2),
                 (f'{outdir}/mupdf.cs', os.path.relpath(swig_cpp)),