summaryrefslogtreecommitdiff
path: root/scripts/dietcc
diff options
context:
space:
mode:
authorMatthew Sotoudeh <matthew@masot.net>2023-07-26 10:53:27 -0700
committerMatthew Sotoudeh <matthew@masot.net>2023-07-26 10:53:27 -0700
commitf35b7e32809c5d54850ce75c4dad1a8598235cf0 (patch)
treea741ac273b8109db35b2abd59423a5efe6293a04 /scripts/dietcc
parent36fc249a02eb0ef32d3bc1d4e596683b64b1eb5f (diff)
simplify code a fair bit
Diffstat (limited to 'scripts/dietcc')
-rwxr-xr-xscripts/dietcc13
1 files changed, 11 insertions, 2 deletions
diff --git a/scripts/dietcc b/scripts/dietcc
index 110a647..540d168 100755
--- a/scripts/dietcc
+++ b/scripts/dietcc
@@ -127,6 +127,16 @@ def final_cleanup_pass(dietc, meta):
return dietc
+def make_external_pass(command):
+ def pass_(dietc, meta):
+ with tempfile.TemporaryDirectory() as tmpdir:
+ t_file = open(f"{tmpdir}/file.c", "wb")
+ t_file.write(dietc)
+ t_file.flush()
+ return check_result(subprocess.run(f"{command} {t_file.name}",
+ shell=True, capture_output=True))
+ return pass_
+
PASSES = [preprocess_pass,
strip_after_preprocess_pass,
dietc_pass,
@@ -136,11 +146,10 @@ def main():
args = list(map(shlex.quote, sys.argv[1:]))
args.insert(0, f"-I{dietc_dir}/scripts/stdincludes")
# first, parse out any DietC passes
- dietc_passes = []
while "--dietc-pass" in args:
i = args.index("--dietc-pass")
args.pop(i)
- dietc_passes.append(args.pop(i))
+ PASSES.insert(-1, make_external_pass(args.pop(i)))
# then process all of the C files
out_dir = tempfile.TemporaryDirectory()
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback