scripts/wrap/__main__.py: use new wdev.py to find C# compiler csc.exe on windows.
authorJulian Smith <[email protected]>
Fri, 17 Mar 2023 13:12:42 +0000 (13:12 +0000)
committerJulian Smith <[email protected]>
Fri, 24 Mar 2023 14:10:45 +0000 (14:10 +0000)
This avoids using the previous hard-coded csc.exe path.

scripts/wrap/__main__.py

index ab98f3be77d99174e2097fad3735428203fc93d3..314eddcb5db6b0253bca1b6af6d4c767ac6b442f 100644 (file)
@@ -1875,6 +1875,8 @@ def csharp_settings(build_dirs):
     csc: C# compiler.
     mono: C# interpreter ("" on Windows).
     mupdf_cs: MuPDF C# code.
+
+    E.g. on Windows `csc` can be: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/Roslyn/csc.exe
     '''
     # On linux requires:
     #   sudo apt install mono-devel
@@ -1886,7 +1888,12 @@ def csharp_settings(build_dirs):
     # which might be because of mixing gcc and clang?
     #
     if state.state_.windows:
-        csc = '"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/Roslyn/csc.exe"'
+        import wdev
+        vs = wdev.WindowsVS()
+        jlib.log('{vs.description_ml()=}')
+        csc = vs.csc
+        jlib.log('{csc=}')
+        assert csc, f'Unable to find csc.exe'
         mono = ''
     else:
         mono = 'mono'
@@ -2475,7 +2482,7 @@ def main2():
                     jlib.build(
                             ('test-csharp.cs', mupdf_cs),
                             out,
-                            f'{csc} -out:{{OUT}} {{IN}}',
+                            f'"{csc}" -out:{{OUT}} {{IN}}',
                             )
                     if state.state_.windows:
                         out_rel = os.path.relpath( out, build_dirs.dir_so)
@@ -2506,7 +2513,7 @@ def main2():
                 jlib.build(
                         ('scripts/mupdfwrap_gui.cs', mupdf_cs),
                         out,
-                        f'{csc} -unsafe {references}  -out:{{OUT}} {{IN}}'
+                        f'"{csc}" -unsafe {references}  -out:{{OUT}} {{IN}}'
                         )
                 if state.state_.windows:
                     # Don't know how to mimic Unix's LD_LIBRARY_PATH, so for