diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..38c2f45 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +scad/*.gen.scad diff --git a/Makefile b/Makefile index 8a2cdba..f6f73e6 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,12 @@ # Makefile for keygen # Executables -SCAD = OPENSCADPATH=src:build openscad +SCAD = openscad POLY = PYTHONPATH=/usr/share/inkscape/extensions bin/paths2openscad.py -SCAD_DIR = src +SCAD_DIR = scad SVG_DIR = resources -POLY_DIR = build -STL_DIR = build +POLY_DIR = scad JSON_DIR = build # Files to include @@ -17,9 +16,6 @@ SCAD_SRC = $(SCAD_DIR)/schlage.scad # Generated polygon files POLY_OBJ = $(patsubst $(SVG_DIR)/%.svg,$(POLY_DIR)/%.gen.scad,$(SVG_SRC)) -# Generated STL -STL_OBJ = # populated in .d files - # Generated JSON files JSON_OBJ = $(patsubst $(SCAD_DIR)/%.scad,$(JSON_DIR)/%.json,$(SCAD_SRC)) @@ -27,19 +23,13 @@ POLYFLAGS = SCADFLAGS = # Targets -all: stl $(JSON_DIR)/keys.json +all: $(JSON_DIR)/keys.json poly poly: $(POLY_OBJ) -$(STL_DIR)/%.d: $(SCAD_DIR)/%.scad - bin/parse.py $< $(STL_DIR)/$*.d $(JSON_DIR)/$*.json $(JSON_DIR)/%.json: $(SCAD_DIR)/%.scad - bin/parse.py $< $(STL_DIR)/$*.d $(JSON_DIR)/$*.json + bin/parse.py $< $@ $(POLY_DIR)/%.gen.scad: $(SVG_DIR)/%.svg $(POLY) $(POLYFLAGS) --fname $@ $< $(JSON_DIR)/keys.json: $(JSON_OBJ) bin/json_merge.py $^ >$(JSON_DIR)/keys.json clean: - -rm -f $(POLY_DIR)/*.gen.scad $(STL_DIR)/*.stl $(STL_DIR)/*.d $(JSON_DIR)/*.json - -include $(patsubst $(SCAD_DIR)/%.scad,$(STL_DIR)/%.d,$(SCAD_SRC)) - -stl: $(STL_OBJ) + -rm -f $(POLY_DIR)/*.gen.scad $(JSON_DIR)/*.json diff --git a/bin/parse.py b/bin/parse.py index 259d8cf..e3d3bbb 100755 --- a/bin/parse.py +++ b/bin/parse.py @@ -8,8 +8,7 @@ import string import itertools scad_fn = sys.argv[1] -d_fn = sys.argv[2] -json_fn = sys.argv[3] +json_fn = sys.argv[2] with open(scad_fn) as f: scad_text = f.read() @@ -41,27 +40,9 @@ d = d.strip() os = json.loads(os) ws = json.loads(ws) -def sanitize(s): - return "".join([c for c in s.lower() if c in string.ascii_lowercase + string.digits]) - -all_keys = [(n, o, w) for o in os for w in ws] - -def stl_filename(n, o, w): - return "$(STL_DIR)/{n_s}_{o_s}_{w_s}.stl".format(n_s=sanitize(n), o_s=sanitize(o), w_s=sanitize(w)) - -all_keys_makefile = ["{stl_fn}: {scad_fn} {deps}\n\t$(SCAD) $(SCADFLAGS) -D 'outline=\"{o}\"' -D 'warding=\"{w}\"' {scad_fn} -o $@" - .format(n=n, o=o, w=w, - scad_fn=scad_fn, stl_fn=stl_filename(n, o, w), deps=" ".join(["$(POLY_DIR)/{}".format(r) for r in poly_reqs])) - for (n, o, w) in all_keys] -all_stl = [stl_filename(n, o, w) for (n, o, w) in all_keys] -all_keys_makefile.append("STL_OBJ += {}".format(" \\\n ".join(all_stl))) - -with open(d_fn, "w") as f: - print("\n".join(all_keys_makefile), file=f -) - json_obj = { "name": n, + "filename": scad_fn, "description": d, "outlines": os, "wardings": ws diff --git a/src/fm.scad b/scad/fm.scad similarity index 100% rename from src/fm.scad rename to scad/fm.scad diff --git a/src/keygen.scad b/scad/keygen.scad similarity index 100% rename from src/keygen.scad rename to scad/keygen.scad diff --git a/src/schlage.scad b/scad/schlage.scad similarity index 100% rename from src/schlage.scad rename to scad/schlage.scad