Support the --debug=memory option on Windows. (Baptiste Lepilleur)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 12 Feb 2006 13:03:27 +0000 (13:03 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 12 Feb 2006 13:03:27 +0000 (13:03 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1418 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Debug.py
test/option/debug-memory.py

index 754768df20e45197f164b0f073e0e49245529969..1407e3ff76621d8e08c8c47544da7c4e435548c0 100644 (file)
@@ -126,6 +126,11 @@ RELEASE 0.97 - XXX
 
   - Add x64 support for Microsoft Visual Studio 8.
 
+  From Baptiste Lepilleur:
+
+  - Support the --debug=memory option on Windows when the Python version
+    has the win32process and win32api modules.
+
   From Christian Maaser:
 
   - Add support for Visual Studio Express Editions.
index bb49dbd3c8f003195d022c43ab1e288e6b2869a2..cc97fe028ae57424a185d6b9720b7d10fcf7330b 100644 (file)
@@ -98,8 +98,17 @@ else:
     try:
         import resource
     except ImportError:
-        def memory():
-            return 0
+        try:
+            import win32process
+            import win32api
+        except ImportError:
+            def memory():
+                return 0
+        else:
+            def memory():
+                process_handle = win32api.GetCurrentProcess()
+                memory_info = win32process.GetProcessMemoryInfo( process_handle )
+                return memory_info['PeakWorkingSetSize']
     else:
         def memory():
             res = resource.getrusage(resource.RUSAGE_SELF)
index 0a2875f45dab3e63f71c0e47b7ada8746252c0fd..9ed674e27470248984556c245dab326f5ca48ee6 100644 (file)
@@ -39,8 +39,12 @@ test = TestSCons.TestSCons()
 try:
     import resource
 except ImportError:
-    x = "Python version has no 'resource' module; skipping tests.\n"
-    test.skip_test(x)
+    try:
+        import win32process
+        import win32api
+    except ImportError:
+        x = "Python version has no 'resource' or 'win32api/win32process' module; skipping tests.\n"
+        test.skip_test(x)