Integrated Asymptote compilation into makefile.
This commit is contained in:
parent
e2d477640f
commit
4a103f6dba
2 changed files with 25 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,4 +3,5 @@
|
||||||
|
|
||||||
/src/**/*.dxf
|
/src/**/*.dxf
|
||||||
/src/**/*.stl
|
/src/**/*.stl
|
||||||
|
/src/**/*.pdf
|
||||||
/src/**/*.d
|
/src/**/*.d
|
||||||
|
|
|
||||||
32
Makefile
32
Makefile
|
|
@ -2,16 +2,18 @@
|
||||||
INKSCAPE := inkscape
|
INKSCAPE := inkscape
|
||||||
OPENSCAD := openscad
|
OPENSCAD := openscad
|
||||||
PYTHON := python2
|
PYTHON := python2
|
||||||
|
ASYMPTOTE := asy
|
||||||
|
|
||||||
# Settings affecting the compiled results. You can overwrite these in a file called settings.mk in the same directory as this makefile. See readme.creole.
|
# Settings affecting the compiled results. You can overwrite these in a file called settings.mk in the same directory as this makefile. See readme.creole.
|
||||||
DXF_FLATNESS := 0.1
|
DXF_FLATNESS := 0.1
|
||||||
FLAT_SCAD_FILES :=
|
FLAT_SCAD_FILES :=
|
||||||
|
ASY_SVG_FILES :=
|
||||||
|
|
||||||
# Non-file goals.
|
# Non-file goals.
|
||||||
.PHONY: all clean generated dxf stl
|
.PHONY: all clean generated dxf stl asy pdf
|
||||||
|
|
||||||
# Goal to build Everything. Also generates files which aren't compiled to anything else. Deined here to make it the default goal.
|
# Goal to build Everything. Also generates files which aren't compiled to anything else. Deined here to make it the default goal.
|
||||||
all: generated dxf stl
|
all: generated dxf stl asy pdf
|
||||||
|
|
||||||
# Include the configuration files.
|
# Include the configuration files.
|
||||||
-include config.mk settings.mk
|
-include config.mk settings.mk
|
||||||
|
|
@ -26,14 +28,11 @@ PYTHON_CMD := PYTHONPATH="support:$$PYTHONPATH" $(PYTHON)
|
||||||
GENERATED_FILES := $(addsuffix .scad,$(basename $(shell ./generate_sources.sh)))
|
GENERATED_FILES := $(addsuffix .scad,$(basename $(shell ./generate_sources.sh)))
|
||||||
|
|
||||||
# All visible files in the src directory that either exist or can be generated. Ignore files whose names contain spaces.
|
# All visible files in the src directory that either exist or can be generated. Ignore files whose names contain spaces.
|
||||||
SRC_FILES := $(GENERATED_FILES) $(shell find src -not \( \( -name '.*' -or -name '* *' \) -prune \))
|
SRC_FILES := $(GENERATED_FILES) $(shell find src -type f -not \( \( -name '.*' -or -name '* *' \) -prune \))
|
||||||
|
|
||||||
# Source files whose names start with `_' are not compiled directly but may be used from other source files.
|
# Source files whose names start with `_' are not compiled directly but may be used from other source files.
|
||||||
COMPILED_SRC_FILES := $(foreach i,$(SRC_FILES),$(if $(filter-out _%,$(notdir $(i))),$(i)))
|
COMPILED_SRC_FILES := $(foreach i,$(SRC_FILES),$(if $(filter-out _%,$(notdir $(i))),$(i)))
|
||||||
|
|
||||||
# Makefiles which are generated while compiling to record dependencies.
|
|
||||||
DEPENDENCY_FILES := $(foreach i,.scad,$(patsubst %$i,%.d,$(filter %$i,$(COMPILED_SRC_FILES))))
|
|
||||||
|
|
||||||
# STL files produced from OpenSCAD files.
|
# STL files produced from OpenSCAD files.
|
||||||
SCAD_STL_FILES := $(patsubst %.scad,%.stl,$(filter-out $(FLAT_SCAD_FILES),$(filter %.scad,$(COMPILED_SRC_FILES))))
|
SCAD_STL_FILES := $(patsubst %.scad,%.stl,$(filter-out $(FLAT_SCAD_FILES),$(filter %.scad,$(COMPILED_SRC_FILES))))
|
||||||
|
|
||||||
|
|
@ -41,7 +40,15 @@ SCAD_STL_FILES := $(patsubst %.scad,%.stl,$(filter-out $(FLAT_SCAD_FILES),$(filt
|
||||||
SCAD_DXF_FILES := $(patsubst %.scad,%.dxf,$(filter %.scad,$(filter $(FLAT_SCAD_FILES),$(COMPILED_SRC_FILES))))
|
SCAD_DXF_FILES := $(patsubst %.scad,%.dxf,$(filter %.scad,$(filter $(FLAT_SCAD_FILES),$(COMPILED_SRC_FILES))))
|
||||||
|
|
||||||
# DXF files produced from SVG files. Ignore an SVG file if the same DXF file can also be produced from an OpenSCAD file. This is just to get reproducable builds without aborting it.
|
# DXF files produced from SVG files. Ignore an SVG file if the same DXF file can also be produced from an OpenSCAD file. This is just to get reproducable builds without aborting it.
|
||||||
SVG_DXF_FILES := $(filter-out $(SCAD_DXF_FILES),$(patsubst %.svg,%.dxf,$(filter %.svg,$(COMPILED_SRC_FILES))))
|
SVG_DXF_FILES := $(filter-out $(SCAD_DXF_FILES),$(patsubst %.svg,%.dxf,$(filter %.svg,$(filter-out $(ASY_SVG_FILES),$(COMPILED_SRC_FILES)))))
|
||||||
|
|
||||||
|
SVG_ASY_FILES := $(patsubst %.svg,%.asy,$(filter %.svg,$(filter $(ASY_SVG_FILES),$(COMPILED_SRC_FILES))))
|
||||||
|
|
||||||
|
# PDF files which can be generated from Asymptote files. We exclude SVG_ASY_FILES because they don't contain any drawing primitives and thus won't produce a PDF.
|
||||||
|
ASY_PDF_FILES := $(patsubst %.asy,%.pdf,$(filter %.asy,$(filter-out $(SVG_ASY_FILES), $(COMPILED_SRC_FILES))))
|
||||||
|
|
||||||
|
# Makefiles which are generated while compiling to record dependencies.
|
||||||
|
DEPENDENCY_FILES := $(foreach i,.scad,$(patsubst %$i,%.d,$(filter %$i,$(COMPILED_SRC_FILES))))
|
||||||
|
|
||||||
# Files that may be used from OpenSCAD files and thus must exist before OpenSCAD is called.
|
# Files that may be used from OpenSCAD files and thus must exist before OpenSCAD is called.
|
||||||
SCAD_ORDER_DEPS := $(filter %.scad %.dxf,$(GENERATED_FILES)) $(SVG_DXF_FILES)
|
SCAD_ORDER_DEPS := $(filter %.scad %.dxf,$(GENERATED_FILES)) $(SVG_DXF_FILES)
|
||||||
|
|
@ -51,17 +58,22 @@ GLOBAL_DEPS := Makefile $(wildcard config.mk settings.mk)
|
||||||
|
|
||||||
# Everything^-1.
|
# Everything^-1.
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(GENERATED_FILES) $(SVG_DXF_FILES) $(SCAD_DXF_FILES) $(SCAD_STL_FILES) $() $(DEPENDENCY_FILES)
|
rm -rf $(GENERATED_FILES) $(SVG_DXF_FILES) $(SCAD_DXF_FILES) $(SCAD_STL_FILES) $(SVG_ASY_FILES) $(ASY_PDF_FILES) $(DEPENDENCY_FILES)
|
||||||
|
|
||||||
# Goals to build the project up to a specific step.
|
# Goals to build the project up to a specific step.
|
||||||
generated: $(GENERATED_FILES)
|
generated: $(GENERATED_FILES)
|
||||||
dxf: $(SVG_DXF_FILES) $(SCAD_DXF_FILES)
|
dxf: $(SVG_DXF_FILES) $(SCAD_DXF_FILES)
|
||||||
stl: $(SCAD_STL_FILES)
|
stl: $(SCAD_STL_FILES)
|
||||||
|
pdf: $(ASY_PDF_FILES)
|
||||||
|
asy: $(SVG_ASY_FILES)
|
||||||
|
|
||||||
# Rule to convert an SVG file to a DXF file.
|
# Rule to convert an SVG file to a DXF file.
|
||||||
$(SVG_DXF_FILES): %.dxf: %.svg $(GLOBAL_DEPS)
|
$(SVG_DXF_FILES): %.dxf: %.svg $(GLOBAL_DEPS)
|
||||||
$(PYTHON_CMD) -m inkscape $< $@
|
$(PYTHON_CMD) -m inkscape $< $@
|
||||||
|
|
||||||
|
$(SVG_ASY_FILES): %.asy: %.svg $(GLOBAL_DEPS)
|
||||||
|
$(PYTHON_CMD) -m inkscape $< $@
|
||||||
|
|
||||||
# Rule to compile an OpenSCAD file to a DXF file.
|
# Rule to compile an OpenSCAD file to a DXF file.
|
||||||
$(SCAD_DXF_FILES): %.dxf: %.scad $(GLOBAL_DEPS) | $(SCAD_ORDER_DEPS)
|
$(SCAD_DXF_FILES): %.dxf: %.scad $(GLOBAL_DEPS) | $(SCAD_ORDER_DEPS)
|
||||||
$(PYTHON_CMD) -m openscad $< $@ $*.d
|
$(PYTHON_CMD) -m openscad $< $@ $*.d
|
||||||
|
|
@ -70,6 +82,10 @@ $(SCAD_DXF_FILES): %.dxf: %.scad $(GLOBAL_DEPS) | $(SCAD_ORDER_DEPS)
|
||||||
$(SCAD_STL_FILES): %.stl: %.scad $(GLOBAL_DEPS) | $(SCAD_ORDER_DEPS)
|
$(SCAD_STL_FILES): %.stl: %.scad $(GLOBAL_DEPS) | $(SCAD_ORDER_DEPS)
|
||||||
$(PYTHON_CMD) -m openscad $< $@ $*.d
|
$(PYTHON_CMD) -m openscad $< $@ $*.d
|
||||||
|
|
||||||
|
# Rule to export an SVG file to an Asymptote file.
|
||||||
|
$(ASY_PDF_FILES): %.pdf: %.asy $(GLOBAL_DEPS) $(COMPILED_SRC_FILES) $(SVG_ASY_FILES)
|
||||||
|
ASYMPTOTE_DIR=$$(dirname $@) $(ASYMPTOTE) -f pdf -o $@ $<
|
||||||
|
|
||||||
# Rule for automaticaly generated OpenSCAD files.
|
# Rule for automaticaly generated OpenSCAD files.
|
||||||
$(GENERATED_FILES): generate_sources.sh $(GLOBAL_DEPS)
|
$(GENERATED_FILES): generate_sources.sh $(GLOBAL_DEPS)
|
||||||
./generate_sources.sh $@
|
./generate_sources.sh $@
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue