Daniel Dunbar | ad5e012 | 2011-11-03 17:56:03 +0000 | [diff] [blame^] | 1 | import os |
| 2 | |
| 3 | def main(): |
| 4 | from optparse import OptionParser, OptionGroup |
| 5 | parser = OptionParser("usage: %prog [options]") |
| 6 | parser.add_option("", "--source-root", dest="source_root", metavar="PATH", |
| 7 | help="Path to the LLVM source (inferred if not given)", |
| 8 | action="store", default=None) |
| 9 | (opts, args) = parser.parse_args() |
| 10 | |
| 11 | # Determine the LLVM source path, if not given. |
| 12 | source_root = opts.source_root |
| 13 | if source_root: |
| 14 | if not os.path.exists(os.path.join(source_root, 'lib', 'VMCore', |
| 15 | 'Function.cpp')): |
| 16 | parser.error('invalid LLVM source root: %r' % source_root) |
| 17 | else: |
| 18 | llvmbuild_path = os.path.dirname(__file__) |
| 19 | llvm_build_path = os.path.dirname(llvmbuild_path) |
| 20 | utils_path = os.path.dirname(llvm_build_path) |
| 21 | source_root = os.path.dirname(utils_path) |
| 22 | if not os.path.exists(os.path.join(source_root, 'lib', 'VMCore', |
| 23 | 'Function.cpp')): |
| 24 | parser.error('unable to infer LLVM source root, please specify') |
| 25 | |
| 26 | if __name__=='__main__': |
| 27 | main() |