chiark / gitweb /
filamentspool, Makefile: automatic toplevels
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 16 Sep 2012 13:15:16 +0000 (14:15 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 16 Sep 2012 13:15:16 +0000 (14:15 +0100)
.gitignore
Makefile
filamentspool-armdoveclippin.scad [deleted file]
filamentspool-armend.scad [deleted file]
filamentspool-cup.scad [deleted file]
filamentspool-cupclip.scad [deleted file]
filamentspool.scad
toplevel-find [new file with mode: 0755]
toplevel-make [new file with mode: 0755]

index 5f3a3f4b2a2e219c52ebd2361b3f5030a6c2cd5e..77d64ee137a40c0a4abbe2d331a41ce7c18b6340 100644 (file)
@@ -3,3 +3,4 @@
 light-bracket.stl
 *.aside
 *.stl
 light-bracket.stl
 *.aside
 *.stl
+*,*.scad
index d31e0a909e4c5747a1d7de2e86e11c6066e512d6..af3f76d779b9c460164c520595c1c90477859616 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,11 @@ SKEINFORGE=python $(HRR)/reprappro-software.git/skeinforge/skeinforge_applicatio
 
 CONFIG=slic3r-config.ini
 
 
 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
 default:
 
 %.stl:         %.scad
@@ -20,3 +25,8 @@ default:
                ./$^ >$@.new && mv -f $@.new $@
 
 dovecliptest.stl: doveclip.scad
                ./$^ >$@.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 (file)
index 036b958..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-include <filamentspool.scad>
-ArmDoveClipPin();
diff --git a/filamentspool-armend.scad b/filamentspool-armend.scad
deleted file mode 100644 (file)
index fa64261..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-include <filamentspool.scad>
-ArmEnd();
diff --git a/filamentspool-cup.scad b/filamentspool-cup.scad
deleted file mode 100644 (file)
index 2459828..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-include <filamentspool.scad>
-FilamentCup();
diff --git a/filamentspool-cupclip.scad b/filamentspool-cupclip.scad
deleted file mode 100644 (file)
index f377b31..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-include <filamentspool.scad>
-CupSecuringClip();
index 14740f26f709841e44dee680efe9a4bdc0fd37d5..487d853b0645b524d5d6ca1f7dc8a0f8aa016b39 100644 (file)
@@ -62,7 +62,7 @@ totalwidth = armendwallthick*2 + channelwidth;
 totalheight = channeldepth + armendbasethick;
 stalkwidth = prongwidth + prongstalkxwidth;
 
 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);
   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;
   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(){
   wingswidth = wingspoke*2 + overclipthick*2 + overcliproundr*2 + totalwidth;
   difference(){
     union(){
@@ -181,11 +181,11 @@ module CupSecuringClip(){
   }
 }
 
   }
 }
 
-module ArmDoveClipPin(){
+module ArmDoveClipPin(){ ////toplevel
   DoveClipPin(h=doveclipheight);
 }
 
   DoveClipPin(h=doveclipheight);
 }
 
-module Hub(){
+module Hub(){ ////toplevel
   difference(){
     cylinder($fn=60, h=hublthick, r=hubbigrad);
     translate([0,0,-1])
   difference(){
     cylinder($fn=60, h=hublthick, r=hubbigrad);
     translate([0,0,-1])
diff --git a/toplevel-find b/toplevel-find
new file mode 100755 (executable)
index 0000000..227bb73
--- /dev/null
@@ -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 (<F>) {
+      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 (executable)
index 0000000..2df668b
--- /dev/null
@@ -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 <<END or die $!;
+include <$base.scad>
+$obj();
+END
+close STDOUT or die $!;