-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
143 lines (118 loc) · 4.54 KB
/
Makefile
File metadata and controls
143 lines (118 loc) · 4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# Name of scad file without the extension:
TARGETNAME=keystone_panel
# scad files that are included (include or use)
DEPS =
DEPS+=wallbox.scad
DEPS+=SlottedHole.scad
DEPS+=RoundCornersCube.scad
# Results
OUTPUTDIR=STL
IMAGEDIR =PNG
OPENSCAD ?= openscad-nightly --enable=manifold --enable=lazy-union
#--enable=fast-csg-trust-corefinement
#OPENSCAD ?= openscad
# Hopefully there is no need to change something below
###########################################################
# openscad options
#Options=-D "WhatToPrint=\"$(WhatToPrint)\""
SHOW_MODULES=-D "ShowModules=1"
IMAGE_SIZE=--imgsize 1024,1024 --viewall
CAMERA=--camera=0,0,0,45,0,130,500
AUTOCENTER=--autocenter
VIEW=--view axes
PNG_CMDS =$(SHOW_MODULES)
PNG_CMDS += $(IMAGE_SIZE)
PNG_CMDS += $(CAMERA)
PNG_CMDS += $(AUTOCENTER)
#PNG_CMDS += $(VIEW)
###########################################################
# internal variables
REV =svn_rev
###########################################################
# do we have dfLibscad and do we use automatic versioning?
AUTO_REF:= $(wildcard $(REV).tmpl)
USE_LIB := $(findstring dfLibscad,$(DEPS))
# Using my super customizer?
SUPER_CUSTOMIZER:= $(wildcard customizer/*.yaml)
###########################################################
ifeq ($(strip $(AUTO_REF)),)
else
DEPS+=$(REV).scad
endif
TARGETS_STL = $(addprefix $(OUTPUTDIR)/, $(addprefix $(TARGETNAME)_,$(addsuffix .stl, $(PARTS_STL))))
TARGETS_PNG = $(addprefix $(IMAGEDIR)/, $(addprefix $(TARGETNAME)_,$(addsuffix .png, $(PARTS_PNG))))
JSON = $(TARGETNAME).json
#DEP = -d $(TARGETNAME).d # for now turned off
ifeq ($(strip $(SUPER_CUSTOMIZER)),)
###########################################################
# retrive the parts list from the json file
# Note: The trick with OPENBRACE is to avoid issues with syntax coloring in vs-code
OPENBRACE={
RAW_PARTS_PNG = $(shell grep ': $(OPENBRACE)' $(JSON) | grep -v parameterSets | grep -v 'design default values')
RAW_PARTS_STL = $(shell grep ': $(OPENBRACE)' $(JSON) | grep -v parameterSets | grep -v 'design default values' | grep -v PNG)
# remove unwanted characters
PARTS_PNG = $(subst ",, $(subst : $(OPENBRACE),,$(RAW_PARTS_PNG)))
PARTS_STL = $(subst ",, $(subst : $(OPENBRACE),,$(RAW_PARTS_STL)))
###########################################################
else
PARTS_PNG = $(shell openscadcustomizer.py --directory customizer --list)
PARTS_STL = $(filter-out %PNG, $(PARTS_PNG))
endif
all: png stl
stl : $(TARGETS_STL)
png : $(TARGETS_PNG)
$(TARGETS_STL) : $(DEPS) $(JSON) Makefile | version dir_build
$(TARGETS_PNG) : $(DEPS) $(JSON) Makefile | version dir_build
%.stl: $(TARGETNAME).scad
$(OPENSCAD) $(DEP) -p "$(JSON)" -P $(subst $(OUTPUTDIR)/$(TARGETNAME)_,,$(@:.stl=)) $(Options) $< -o $(subst $(TARGETNAME)_,,$(@))
%.png: $(TARGETNAME).scad
$(OPENSCAD) $(DEP) -p "$(JSON)" -P $(subst $(IMAGEDIR)/$(TARGETNAME)_,,$(@:.png=)) $(PNG_CMDS) -D "png=true" $(Options) $< -o $(subst $(TARGETNAME)_,,$(@))
dir_build:
@mkdir -p $(OUTPUTDIR)
@mkdir -p $(IMAGEDIR)
.PHONY:
%.scad: %.tmpl
SubWCRev . $< $@
ifeq ($(strip $(AUTO_REF)),)
version: | libversion
@echo "no automatic version generated"
else
.PHONY:
.ONESHELL:
version $(REV).scad: $(REV).tmpl | libversion
SubWCRev . $(REV).tmpl $(REV).scad
endif
ifeq ($(strip $(USE_LIB)),)
libversion:
# echo nothing to do
else
libversion:
cd dfLibscad && bash UpdateRevision.sh
endif
# Super customizer
ifeq ($(strip $(SUPER_CUSTOMIZER)),)
customizer:
# echo nothing to do
else
$(JSON): $(SUPER_CUSTOMIZER) | Makefile
openscadcustomizer.py --directory customizer -o $@
endif
clean:
-rm -rf $(OUTPUTDIR)
-rm -rf $(IMAGEDIR)
-rm $(REV).scad
debug:
@echo TARGETNAME=$(TARGETNAME)
@echo DEPS=$(DEPS)
@echo RAW_PARTS_PNG=$(RAW_PARTS_PNG)
@echo PARTS_PNG=$(PARTS_PNG)
@echo RAW_PARTS_STL=$(RAW_PARTS_STL)
@echo PARTS_STL=$(PARTS_STL)
@echo AUTO_REF=$(AUTO_REF)
@echo USE_LIB=$(USE_LIB)
@echo SUPER_CUSTOMIZER=$(SUPER_CUSTOMIZER)
@echo JSON=$(JSON)
# Copyright (C) 2021 Dieter Fauth
# 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 3 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
# Contact: dieter.fauth at web.de