statcheck/makedepends
2024-09-01 20:23:34 -04:00

41 lines
1.3 KiB
Python
Executable file

#!/usr/bin/env python3
#
# Copyright (C) 2024 Simon Howard
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version. This program is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
from glob import glob
import os
from os.path import exists, join
import sys
from common import *
depends_file = sys.argv[1]
dependencies = {}
for filename in glob("expected/**/*.txt", recursive=True):
lmp_file = filename.replace("expected/", "demos/").replace(".txt", ".lmp")
cfg = read_config(lmp_file)
depends = [join("iwads", cfg["iwad"])]
pwad = cfg.get("pwad")
if pwad is not None:
depends.append(os.path.join("extract", pwad))
out_file = filename.replace("expected/", "output/")
dependencies[out_file] = depends
with open(depends_file, "w") as f:
for out_file, depends in sorted(dependencies.items()):
out_file = out_file.replace("#", "\\#")
f.write("%s: %s\n" % (
out_file, " ".join(depends),
))