[Lldb-commits] [lldb] r155590 - /lldb/trunk/examples/darwin/heap_find/heap.py

Greg Clayton gclayton at apple.com
Wed Apr 25 14:23:07 PDT 2012


Author: gclayton
Date: Wed Apr 25 16:23:07 2012
New Revision: 155590

URL: http://llvm.org/viewvc/llvm-project?rev=155590&view=rev
Log:
Make the libheap.dylib build into a consistent temp directory so it can be reused between lldb invocations. Also add the module name into the directory path that is used to store the target triple specific build of libheap.dylib.

Also added code that will rebuild libheap.dylib if heap_find.cpp is newer that libheap.dylib.


Modified:
    lldb/trunk/examples/darwin/heap_find/heap.py

Modified: lldb/trunk/examples/darwin/heap_find/heap.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/darwin/heap_find/heap.py?rev=155590&r1=155589&r2=155590&view=diff
==============================================================================
--- lldb/trunk/examples/darwin/heap_find/heap.py (original)
+++ lldb/trunk/examples/darwin/heap_find/heap.py Wed Apr 25 16:23:07 2012
@@ -26,21 +26,25 @@
         global g_libheap_dylib_dir
         global g_libheap_dylib_dict
         triple = lldb.target.triple
-        if triple not in g_libheap_dylib_dict:
+        if triple in g_libheap_dylib_dict:
+            libheap_dylib_path = g_libheap_dylib_dict[triple]
+        else:
             if not g_libheap_dylib_dir:
-                g_libheap_dylib_dir = tempfile.mkdtemp()
-            triple_dir = g_libheap_dylib_dir + '/' + triple
+                g_libheap_dylib_dir = tempfile.gettempdir() + '/lldb-dylibs'
+            triple_dir = g_libheap_dylib_dir + '/' + triple + '/' + __name__
             if not os.path.exists(triple_dir):
-                os.mkdir(triple_dir)
+                os.makedirs(triple_dir)
             libheap_dylib_path = triple_dir + '/libheap.dylib'
             g_libheap_dylib_dict[triple] = libheap_dylib_path
-        libheap_dylib_path = g_libheap_dylib_dict[triple]
-        if not os.path.exists(libheap_dylib_path):
-            heap_code_directory = os.path.dirname(__file__) + '/heap'
+        heap_code_directory = os.path.dirname(__file__) + '/heap'
+        heap_source_file = heap_code_directory + '/heap_find.cpp'
+        # Check if the dylib doesn't exist, or if "heap_find.cpp" is newer than the dylib
+        if not os.path.exists(libheap_dylib_path) or os.stat(heap_source_file).st_mtime > os.stat(libheap_dylib_path).st_mtime:
+            # Remake the dylib
             make_command = '(cd "%s" ; make EXE="%s" ARCH=%s)' % (heap_code_directory, libheap_dylib_path, string.split(triple, '-')[0])
-            #print make_command
+            # print make_command
             make_output = commands.getoutput(make_command)
-            #print make_output
+            # print make_output
         if os.path.exists(libheap_dylib_path):
             libheap_dylib_spec = lldb.SBFileSpec(libheap_dylib_path)
             if lldb.target.FindModule(libheap_dylib_spec):





More information about the lldb-commits mailing list