diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/initmk | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -1,5 +1,6 @@ #!/bin/python +import os import sys NAME = "rules.mk" @@ -10,7 +11,7 @@ TEMPLATE = """include share/push.mk SRCS_$(d) := $(wildcard $(d)/*.c) LIBS_$(d) := BINS_$(d) := -TSTS_$(d) := +TSTS_$(d) := $(wildcard $(d)/*_test.c:.c=.test) include share/pop.mk @@ -28,8 +29,17 @@ $(BINS_$(d)): $(OBJS_$(d)) include share/pop.mk""" if __name__ == "__main__": + if len(sys.argv) == 2: + dir = sys.argv[1] + if not os.path.exists(dir): + raise ValueError(f"path '{dir}' does not exist") + path = f"{dir}/{NAME}" + elif len(sys.argv) > 2: + raise ValueError("only one argument is accepted") + else: + path = NAME try: - with open(NAME, 'x') as makefile: + with open(path, 'x') as makefile: makefile.write(f"{TEMPLATE}\n") except: print("rules.mk already present", file=sys.stderr) |