Created
January 20, 2021 13:23
-
-
Save speshak/1da7fac746fc58ab5d9168f349ec5bde to your computer and use it in GitHub Desktop.
OScad Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#################################### | |
# Common Makefile snippets | |
# | |
# Most simple projects can just include this file and supply nothing else | |
# More complex projects may need to define additional targets | |
#################################### | |
oscad := /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD | |
sources=$(shell find . -type f -name \*.scad -not -name \*.inc.scad) | |
stls=$(patsubst %.scad,%.stl,$(sources)) | |
pngs=$(patsubst %.scad,%.png,$(sources)) | |
# All builds will get the current revision, it's up to the models to do something with it | |
GIT_VERSION := $(shell git describe --tags --always) | |
all: $(stls) | |
.PHONY: pngs | |
pngs: $(pngs) | |
.PHONY: clean | |
clean: | |
-rm $(stls) $(pngs) *.d | |
%.stl: %.scad | |
$(oscad) -o $@ -D 'git_rev="$(GIT_VERSION)"' $< | |
# Create PNG of object | |
%.png: %.scad | |
$(oscad) -o $@ -D 'git_rev="$(GIT_VERSION)"' --autocenter --viewall --colorscheme "Tomorrow Night" --imgsize 1024,1024 $< | |
## Search for scad includes | |
# This builds a .d file for each scad that lists all of the files that the scad | |
# includes. This does not follow second level deps. | |
%.d: %.scad | |
echo "$(patsubst %.scad,%.stl,$<) $@: $(shell perl -n -e 'print "$$1 " if /^\s*include\s+\<(.*)\>;/' $<)" > $@ | |
include $(sources:.scad=.d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include ../common.mk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment