aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2020-05-15 18:11:58 -0700
committerNicholas Noll <nbnoll@eml.cc>2020-05-15 18:11:58 -0700
commitfa25c8f3df6791727b9384c9b405c996ac68b8ab (patch)
treea7a2a627b0deb612472138f389fe533761a01f0e /bin
parent05aeef535ac60ccca81fe58bc6a0152ca80bc211 (diff)
feat: added buffered io to libn
Diffstat (limited to 'bin')
-rwxr-xr-xbin/initmk14
1 files changed, 12 insertions, 2 deletions
diff --git a/bin/initmk b/bin/initmk
index 77fcfd7..141764d 100755
--- a/bin/initmk
+++ b/bin/initmk
@@ -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)