lambda-calculus/build-all.py
2025-01-13 20:36:07 -06:00

59 lines
916 B
Python
Executable file

#!/usr/bin/env python3
import subprocess;
import time;
import atexit;
import os;
import pickle;
PICKLEFILE = ".build-all.db"
try:
with open(PICKLEFILE, "rb") as stream:
ftimes = pickle.load(stream);
except:
ftimes = dict();
def dumpftimes():
with open(PICKLEFILE, "wb") as stream:
pickle.dump(ftimes, stream);
atexit.register(dumpftimes);
buildtypes = set();
for x in os.listdir("buildtypes"):
buildtype = x[:-4];
if buildtype not in ftimes:
ftimes[buildtype] = time.time();
buildtypes.add(buildtype);
for buildtype in sorted(buildtypes, key = lambda x: -ftimes[x]):
print("\033[32m" f"$ make buildtype={buildtype}" "\033[0m");
result = subprocess.run(["make", f"buildtype={buildtype}"]);
if result.returncode:
ftimes[buildtype] = time.time();
print("subcommand failed!");
exit(1);