build: Stub out llvm-build utility tool.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 3 Nov 2011 17:56:03 +0000 (17:56 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 3 Nov 2011 17:56:03 +0000 (17:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143620 91177308-0d34-0410-b5e6-96231b3b80d8

utils/llvm-build/README.txt [new file with mode: 0644]
utils/llvm-build/llvm-build [new file with mode: 0755]
utils/llvm-build/llvmbuild/__init__.py [new file with mode: 0644]
utils/llvm-build/llvmbuild/main.py [new file with mode: 0644]

diff --git a/utils/llvm-build/README.txt b/utils/llvm-build/README.txt
new file mode 100644 (file)
index 0000000..b6bcaae
--- /dev/null
@@ -0,0 +1,5 @@
+==============================
+ llvm-build - LLVM Build Tool
+==============================
+
+`llvm-build` is a tool for helping build the LLVM project.
diff --git a/utils/llvm-build/llvm-build b/utils/llvm-build/llvm-build
new file mode 100755 (executable)
index 0000000..7377e3d
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/env python
+
+import llvmbuild
+
+if __name__ == '__main__':
+   llvmbuild.main()
diff --git a/utils/llvm-build/llvmbuild/__init__.py b/utils/llvm-build/llvmbuild/__init__.py
new file mode 100644 (file)
index 0000000..7760218
--- /dev/null
@@ -0,0 +1 @@
+from main import main
diff --git a/utils/llvm-build/llvmbuild/main.py b/utils/llvm-build/llvmbuild/main.py
new file mode 100644 (file)
index 0000000..0d990a7
--- /dev/null
@@ -0,0 +1,27 @@
+import os
+
+def main():
+    from optparse import OptionParser, OptionGroup
+    parser = OptionParser("usage: %prog [options]")
+    parser.add_option("", "--source-root", dest="source_root", metavar="PATH",
+                      help="Path to the LLVM source (inferred if not given)",
+                      action="store", default=None)
+    (opts, args) = parser.parse_args()
+
+    # Determine the LLVM source path, if not given.
+    source_root = opts.source_root
+    if source_root:
+        if not os.path.exists(os.path.join(source_root, 'lib', 'VMCore',
+                                           'Function.cpp')):
+            parser.error('invalid LLVM source root: %r' % source_root)
+    else:
+        llvmbuild_path = os.path.dirname(__file__)
+        llvm_build_path = os.path.dirname(llvmbuild_path)
+        utils_path = os.path.dirname(llvm_build_path)
+        source_root = os.path.dirname(utils_path)
+        if not os.path.exists(os.path.join(source_root, 'lib', 'VMCore',
+                                           'Function.cpp')):
+            parser.error('unable to infer LLVM source root, please specify')
+
+if __name__=='__main__':
+    main()