Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import os, sys
- import subprocess
- from optparse import OptionParser
- compiler = "pipoca"
- assembler = "yasm"
- linker = "gcc"
- def exec_wait(args, err):
- try:
- subprocess.check_call(args, stdout=subprocess.PIPE)
- except subprocess.CalledProcessError:
- error(err)
- def check_file_exists(f, err):
- if not os.path.isfile(f):
- error(err)
- def error(s):
- print "error: %s" % (s)
- sys.exit()
- def check_args():
- usage = "usage: %prog [options] example.pip -o example"
- parser = OptionParser(usage=usage, version="%prog 0.1")
- parser.add_option("-o", "--output", dest="filename",
- help="writes the program to prog", metavar="prog")
- global options, args
- (options, args) = parser.parse_args()
- if len(sys.argv) < 2 or len(args) < 1:
- parser.print_help()
- sys.exit()
- def compile():
- global file
- file = args[0]
- # check for the program and the compiler
- check_file_exists(file, "file '%s' not found or does not exist" % (file))
- check_file_exists(compiler, "compiler '%s' not found or does not exist" % (compiler))
- # compile the program
- exec_wait(["pipoca", file], "error compiling '%s'" % (file))
- def assembly():
- # check for the assembler
- # assembly it
- #exec_wait(["yasm
- pass
- def link():
- pass
- def main():
- check_args()
- compile()
- assembly()
- link()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement