[pypy-svn] r40939 - pypy/dist/pypy/translator/cli

antocuni at codespeak.net antocuni at codespeak.net
Wed Mar 21 15:30:43 CET 2007


Author: antocuni
Date: Wed Mar 21 15:30:42 2007
New Revision: 40939

Modified:
   pypy/dist/pypy/translator/cli/rte.py
   pypy/dist/pypy/translator/cli/sdk.py
Log:
When on windows, try to find if mono is installed and in that case use
its ilasm2 for assembling files, because the one shipped with
Microsoft CLR can't compile pypy-cli.



Modified: pypy/dist/pypy/translator/cli/rte.py
==============================================================================
--- pypy/dist/pypy/translator/cli/rte.py	(original)
+++ pypy/dist/pypy/translator/cli/rte.py	Wed Mar 21 15:30:42 2007
@@ -5,7 +5,6 @@
 
 import os
 import os.path
-import platform
 import shutil
 
 import py

Modified: pypy/dist/pypy/translator/cli/sdk.py
==============================================================================
--- pypy/dist/pypy/translator/cli/sdk.py	(original)
+++ pypy/dist/pypy/translator/cli/sdk.py	Wed Mar 21 15:30:42 2007
@@ -1,3 +1,4 @@
+import os.path
 import platform
 import py
 
@@ -39,7 +40,48 @@
     CSC = 'gmcs'
     PEVERIFY = 'peverify' # it's not part of mono, but we get a meaningful skip message
 
-if platform.system() == 'Windows':
-    SDK = MicrosoftSDK
-else:
-    SDK = MonoSDK
+def key_as_dict(handle):
+    import _winreg
+    i = 0
+    res = {}
+    while True:
+        try:
+            name, value, type_ = _winreg.EnumValue(handle, i)
+            res[name] = value
+            i += 1
+        except WindowsError:
+            break
+    return res
+
+def find_mono_on_windows():
+    if platform.system() != 'Windows':
+        return None
+    import _winreg
+    try:
+        hMono = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "Software\\Novell\\Mono")
+    except WindowsError: # mono seems not installed
+        return None
+
+    mono = key_as_dict(hMono)
+    mono_version = mono.get('DefaultCLR', None)
+    if mono_version is None:
+        return None
+    hMono.Close()
+
+    hMono_data = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "Software\\Novell\\Mono\\%s" % mono_version)
+    mono_data = key_as_dict(hMono_data)
+    mono_dir = str(mono_data['SdkInstallRoot'])
+    return os.path.join(mono_dir, 'bin')
+
+def get_default_SDK():
+    if platform.system() == 'Windows':
+        SDK = MicrosoftSDK
+        # if present, use mono ilasm2 instead of MS ilasm
+        mono_bin = find_mono_on_windows()
+        if mono_bin is not None:
+            SDK.ILASM = os.path.join(mono_bin, 'ilasm2.bat')
+    else:
+        SDK = MonoSDK
+    return SDK
+
+SDK = get_default_SDK()



More information about the Pypy-commit mailing list