mirror of
https://github.com/michaelcmartin/Ophis.git
synced 2025-01-08 07:30:16 +00:00
Exit with exit code 1 if there were errors, 0 otherwise.
This commit is contained in:
parent
0b020a827b
commit
5fc504c6c1
@ -1,10 +1,10 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from os.path import realpath, dirname, join
|
||||
from sys import argv, path
|
||||
from sys import argv, exit, path
|
||||
|
||||
path.insert(0, join(dirname(realpath(argv[0])), '..', 'src'))
|
||||
|
||||
import Ophis.Main
|
||||
|
||||
Ophis.Main.run_ophis(argv[1:])
|
||||
exit(Ophis.Main.run_ophis(argv[1:]))
|
||||
|
@ -20,7 +20,12 @@ import Ophis.Opcodes
|
||||
|
||||
|
||||
def run_all():
|
||||
"Transforms the source infiles to a binary outfile."
|
||||
"""Transforms the source infiles to a binary outfile.
|
||||
|
||||
Returns a shell-style exit code: 1 if there were errors, 0 if there
|
||||
were no errors.
|
||||
|
||||
"""
|
||||
Err.count = 0
|
||||
z = Ophis.Frontend.parse(Ophis.CmdLine.infiles)
|
||||
env = Ophis.Environment.Environment()
|
||||
@ -69,7 +74,7 @@ def run_all():
|
||||
if outfile == '-':
|
||||
output = sys.stdout
|
||||
if sys.platform == "win32":
|
||||
# We can't dump our binary in test mode; that would be
|
||||
# We can't dump our binary in text mode; that would be
|
||||
# disastrous. So, we'll do some platform-specific
|
||||
# things here to force our stdout to binary mode.
|
||||
import msvcrt
|
||||
@ -82,10 +87,13 @@ def run_all():
|
||||
output.flush()
|
||||
if outfile != '-':
|
||||
output.close()
|
||||
return 0
|
||||
except IOError:
|
||||
print>>sys.stderr, "Could not write to " + outfile
|
||||
return 1
|
||||
else:
|
||||
Err.report()
|
||||
return 1
|
||||
|
||||
|
||||
def run_ophis(args):
|
||||
@ -98,8 +106,8 @@ def run_ophis(args):
|
||||
Ophis.Opcodes.opcodes.update(Ophis.Opcodes.c02extensions)
|
||||
|
||||
Ophis.CorePragmas.reset()
|
||||
run_all()
|
||||
return run_all()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run_ophis(sys.argv[1:])
|
||||
sys.exit(run_ophis(sys.argv[1:]))
|
||||
|
Loading…
Reference in New Issue
Block a user