print("Error: This script only supports Python 3")
sys.exit(5)
parser=argparse.ArgumentParser(description='Setup the project. This creates the necessary symbolic links in the LLVM source code and adds the entries into the right CMakeList.txt. Also initialises the configuration for the run.py script.')
parser.add_argument('--llvm-path',help='path to the LLVM build directory, containing a file bin/opt.')
parser.add_argument('--llvm-src',help='path to the LLVM source directory, containing lib/Analysis ')
parser.add_argument('--clang-path',help='path to the clang build direcotry, containing a file bin/clang')
parser.add_argument('--xcode',action='store_true',help='for builds using xcode')
parser.add_argument("file",help="run only the specfied files",nargs='*')
parser.add_argument("-n",dest='only_print',help="only print the commands, do not execute anything",action="store_true")
parser.add_argument("-v",dest='show_output',help="show output on stdout",action="store_true")
parser.add_argument("--cfg",dest='view_cfg',help="show llvm control flow graph",action="store_true")
parser.add_argument("--make",dest='do_make',help="call make before executing the script",action="store_true")
parser.add_argument("--only-make",dest='do_make_only',help="only call make, do not execute any samples",action="store_true")
parser.add_argument("--gdb",dest='do_gdb',help="open the gdb debugger for the specified file",action="store_true")# might not work with mac OS try lldb
parser.add_argument("--lldb",dest='do_lldb',help="open the lldb debugger for the specified file",action="store_true")
parser.add_argument("--run-test",dest='run_test',help="run the test for SimpleInterval",action="store_true")
parser.add_argument("--use-cxx",metavar='path',dest='use_cxx',help="use as c++ compiler when building the test")
args=parser.parse_args()
# If no files are specified, set it to all .c files in current directory
files=args.file
ifargs.run_test:
iffiles:
print('Error: you are trying to both run the test and a file. This does not really make sense.')
sys.exit(4)
elifargs.do_gdb:
iflen(files)!=1:
print('Error: you are trying to run the debugger on multiple files. This does not really make sense, just specify a single one.')
print('In a moment, gdb is going to read in the symbols of opt. As you might notice, that takes a long time. So, here is a tip: Just restart the program using r (no need to specify arguments). Even if you rebuild the project, that is in a shared library and will thus be reloaded the next time you start the program.')