Files
integration/luprex/add-compile-commands.py

28 lines
640 B
Python
Raw Normal View History

2025-06-16 21:32:40 -04:00
import sys, os, json
from pathlib import Path
LUPREXDIR=os.path.dirname(os.path.abspath(sys.argv[0]))
2025-06-16 21:32:40 -04:00
JSONFILE=sys.argv[1]
COMPILE=sys.argv[2]
FLAGS=sys.argv[3]
OBJPAT=sys.argv[4]
CPAT=sys.argv[5]
OBJECTS=sys.argv[6:]
2025-06-16 21:32:40 -04:00
JSON = json.loads(Path(JSONFILE).read_text())
for base in OBJECTS:
obj = LUPREXDIR + "/" + OBJPAT.replace("FILE", base)
file = LUPREXDIR + "/" + CPAT.replace("FILE", base)
flags = FLAGS.replace("-I./", f"-I{LUPREXDIR}/")
command = f"{COMPILE} {obj} {flags} {file}"
JSON.append({"file": file, "command": command, "directory": LUPREXDIR })
Path(JSONFILE).write_text(json.dumps(JSON, indent=4))