aboutsummaryrefslogtreecommitdiff
path: root/crowbar_reference_compiler
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2020-11-04 02:08:42 -0700
committerMelody Horn <melody@boringcactus.com>2020-11-04 02:08:42 -0700
commitcc30b361cd6e7bbfe313f610cd057a4426664f2b (patch)
treee745d55b10fbb122efda1c81abaee76be1ae0855 /crowbar_reference_compiler
parent338049020a17831e68b6a437bb038d8f10bfc45e (diff)
downloadreference-compiler-cc30b361cd6e7bbfe313f610cd057a4426664f2b.tar.gz
reference-compiler-cc30b361cd6e7bbfe313f610cd057a4426664f2b.zip
add more arguments to behave more like gcc
Diffstat (limited to 'crowbar_reference_compiler')
-rw-r--r--crowbar_reference_compiler/__init__.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/crowbar_reference_compiler/__init__.py b/crowbar_reference_compiler/__init__.py
index d4e7430..c348104 100644
--- a/crowbar_reference_compiler/__init__.py
+++ b/crowbar_reference_compiler/__init__.py
@@ -14,6 +14,9 @@ def main():
args.add_argument('--stop-at-parse-tree', action='store_true')
args.add_argument('--stop-at-qbe-ssa', action='store_true')
args.add_argument('-S', '--stop-at-assembly', action='store_true')
+ args.add_argument('-c', '--stop-at-object', action='store_true')
+ args.add_argument('-D', '--define-constant', help='define a constant with some literal value')
+ args.add_argument('-I', '--include-dir', help='folder to look for included headers within')
args.add_argument('-o', '--out', help='output file')
args.add_argument('input', help='input file')
@@ -38,20 +41,23 @@ def main():
# TODO bundle the qbe binary or something
qbe_result = subprocess.run(['qbe', '-'], input=ssa, capture_output=True, text=True)
if qbe_result.returncode != 0:
- if args.out is None:
- args.out = args.input.replace('.cro', '.s')
print(qbe_result.stderr, file=sys.stderr)
sys.exit(1)
asm = qbe_result.stdout
if args.stop_at_assembly:
if args.out is None:
- args.out = args.input.replace('.cro', '.o')
+ args.out = args.input.replace('.cro', '.s')
with open(args.out, 'w', encoding='utf-8') as output_file:
output_file.write(asm)
return
if args.out is None:
args.out = args.input.replace('.cro', '.out')
# TODO don't assume gcc is always the right thing
+ extra_gcc_flags = []
+ if args.stop_at_object:
+ if args.out is None:
+ args.out = args.input.replace('.cro', '.o')
+ extra_gcc_flags.append('-c')
gcc_result = subprocess.run(['gcc', '-x', 'assembler', '-o', args.out, '-'], input=asm, text=True)
sys.exit(gcc_result.returncode)