[llvm-commits] [llvm] r143782 - /llvm/trunk/utils/llvm-build/llvmbuild/main.py

Daniel Dunbar daniel at zuster.org
Fri Nov 4 21:07:49 PDT 2011


Author: ddunbar
Date: Fri Nov  4 23:07:49 2011
New Revision: 143782

URL: http://llvm.org/viewvc/llvm-project?rev=143782&view=rev
Log:
utils/llvm-build: Ensure output directory exists for tools which write various fragments.

Modified:
    llvm/trunk/utils/llvm-build/llvmbuild/main.py

Modified: llvm/trunk/utils/llvm-build/llvmbuild/main.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/llvm-build/llvmbuild/main.py?rev=143782&r1=143781&r2=143782&view=diff
==============================================================================
--- llvm/trunk/utils/llvm-build/llvmbuild/main.py (original)
+++ llvm/trunk/utils/llvm-build/llvmbuild/main.py Fri Nov  4 23:07:49 2011
@@ -31,6 +31,17 @@
     # The only quoting we currently perform is for ':', to support msys users.
     return value.replace(":", "\\:")
 
+def make_install_dir(path):
+    """
+    make_install_dir(path) -> None
+
+    Create the given directory path for installation, including any parents.
+    """
+
+    # os.makedirs considers it an error to be called with an existant path.
+    if not os.path.exists(path):
+        os.makedirs(path)
+
 ###
 
 class LLVMProjectInfo(object):
@@ -276,6 +287,7 @@
                                      for _,_,deps in entries) + 1
 
         # Write out the library table.
+        make_install_dir(os.path.dirname(output_path))
         f = open(output_path, 'w')
         print >>f, """\
 //===- llvm-build generated file --------------------------------*- C++ -*-===//
@@ -360,6 +372,7 @@
         dependencies = list(self.get_fragment_dependencies())
 
         # Write out the CMake fragment.
+        make_install_dir(os.path.dirname(output_path))
         f = open(output_path, 'w')
 
         # Write the header.
@@ -419,6 +432,7 @@
         dependencies = list(self.get_fragment_dependencies())
 
         # Write out the Makefile fragment.
+        make_install_dir(os.path.dirname(output_path))
         f = open(output_path, 'w')
 
         # Write the header.





More information about the llvm-commits mailing list