| 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() |