From fcd425d28e0fd254673250e4c5d13db7b98aab48 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Sep 2012 14:15:16 +0100 Subject: [PATCH 1/1] filamentspool, Makefile: automatic toplevels --- .gitignore | 1 + Makefile | 10 ++++++++++ filamentspool-armdoveclippin.scad | 2 -- filamentspool-armend.scad | 2 -- filamentspool-cup.scad | 2 -- filamentspool-cupclip.scad | 2 -- filamentspool.scad | 10 +++++----- toplevel-find | 12 ++++++++++++ toplevel-make | 10 ++++++++++ 9 files changed, 38 insertions(+), 13 deletions(-) delete mode 100644 filamentspool-armdoveclippin.scad delete mode 100644 filamentspool-armend.scad delete mode 100644 filamentspool-cup.scad delete mode 100644 filamentspool-cupclip.scad create mode 100755 toplevel-find create mode 100755 toplevel-make diff --git a/.gitignore b/.gitignore index 5f3a3f4..77d64ee 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ light-bracket.stl *.aside *.stl +*,*.scad diff --git a/Makefile b/Makefile index d31e0a9..af3f76d 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,11 @@ SKEINFORGE=python $(HRR)/reprappro-software.git/skeinforge/skeinforge_applicatio CONFIG=slic3r-config.ini +AUTO_TOPLEVELS := $(foreach m, filamentspool, $(shell ./toplevel-find $m)) + +scads: $(addsuffix .scad, $(AUTO_TOPLEVELS)) +stls: $(addsuffix .stl, $(AUTO_TOPLEVELS)) + default: %.stl: %.scad @@ -20,3 +25,8 @@ default: ./$^ >$@.new && mv -f $@.new $@ dovecliptest.stl: doveclip.scad + +%.scad: toplevel-make Makefile toplevel-find + @echo ' write $@' + ./$< $@ >$@.new + @mv -f $@.new $@ diff --git a/filamentspool-armdoveclippin.scad b/filamentspool-armdoveclippin.scad deleted file mode 100644 index 036b958..0000000 --- a/filamentspool-armdoveclippin.scad +++ /dev/null @@ -1,2 +0,0 @@ -include -ArmDoveClipPin(); diff --git a/filamentspool-armend.scad b/filamentspool-armend.scad deleted file mode 100644 index fa64261..0000000 --- a/filamentspool-armend.scad +++ /dev/null @@ -1,2 +0,0 @@ -include -ArmEnd(); diff --git a/filamentspool-cup.scad b/filamentspool-cup.scad deleted file mode 100644 index 2459828..0000000 --- a/filamentspool-cup.scad +++ /dev/null @@ -1,2 +0,0 @@ -include -FilamentCup(); diff --git a/filamentspool-cupclip.scad b/filamentspool-cupclip.scad deleted file mode 100644 index f377b31..0000000 --- a/filamentspool-cupclip.scad +++ /dev/null @@ -1,2 +0,0 @@ -include -CupSecuringClip(); diff --git a/filamentspool.scad b/filamentspool.scad index 14740f2..487d853 100644 --- a/filamentspool.scad +++ b/filamentspool.scad @@ -62,7 +62,7 @@ totalwidth = armendwallthick*2 + channelwidth; totalheight = channeldepth + armendbasethick; stalkwidth = prongwidth + prongstalkxwidth; -module ArmEnd(length=120){ +module ArmEnd(length=120){ ////toplevel translate([ratchettoothsmoothr, channelwidth/2, -armendbasethick]) { rotate([0,0,-90]) DoveClipPairBase(h=doveclipheight); @@ -122,7 +122,7 @@ module FilamentCupCup(){ } } -module FilamentCup() { +module FilamentCup() { ////toplevel FilamentCupHandle(); dx = cupbigrad + prongwidth; @@ -168,7 +168,7 @@ module CupSecuringClipSolidSmooth(xrad=0, xdepth=0){ } } -module CupSecuringClip(){ +module CupSecuringClip(){ ////toplevel wingswidth = wingspoke*2 + overclipthick*2 + overcliproundr*2 + totalwidth; difference(){ union(){ @@ -181,11 +181,11 @@ module CupSecuringClip(){ } } -module ArmDoveClipPin(){ +module ArmDoveClipPin(){ ////toplevel DoveClipPin(h=doveclipheight); } -module Hub(){ +module Hub(){ ////toplevel difference(){ cylinder($fn=60, h=hublthick, r=hubbigrad); translate([0,0,-1]) diff --git a/toplevel-find b/toplevel-find new file mode 100755 index 0000000..227bb73 --- /dev/null +++ b/toplevel-find @@ -0,0 +1,12 @@ +#!/usr/bin/perl -w +use strict; +@ARGV==1 or die; +my $base = $ARGV[0]; +$base =~ m/^\-/ and die; +open F, "$base.scad" or die $!; +while () { + next unless m#^\s*module\s+(\w+)\b.*////toplevel\b#; + print "$base,$1\n" or die $!; +} +close F or die $!; +close STDOUT or die $!; diff --git a/toplevel-make b/toplevel-make new file mode 100755 index 0000000..2df668b --- /dev/null +++ b/toplevel-make @@ -0,0 +1,10 @@ +#!/usr/bin/perl -w +use strict; +die unless @ARGV==1; +die unless $ARGV[0] =~ m/^(.+),(\w+)(?:\..*)?/; +my ($base,$obj) = ($1,$2); +print < +$obj(); +END +close STDOUT or die $!; -- 2.30.2