From cc30b361cd6e7bbfe313f610cd057a4426664f2b Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Wed, 4 Nov 2020 02:08:42 -0700 Subject: add more arguments to behave more like gcc --- crowbar_reference_compiler/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'crowbar_reference_compiler') 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) -- cgit v1.2.3