diff --git a/hardware/Rakefile b/hardware/Rakefile index 79744e7..5e00e7c 100644 --- a/hardware/Rakefile +++ b/hardware/Rakefile @@ -43,26 +43,28 @@ task :default => [:version,:print,:notes,:photo,:gerber] desc "create release file" release = "hardware-release_v#{version}.tar.gz" task :release => release -CLOBBER.include(release) if File.exist? release +CLOBBER.include(release) desc "set version in schematic and layout" -task :version => targets.collect{|target| [target[:vsch],target[:vpcb]]}.flatten +versions = targets.collect{|target| [target[:vsch],target[:vpcb]]}.flatten +task :version => versions +CLEAN.include(versions) targets.each do |target| - CLEAN.include(target[:vsch]) if File.exist? target[:vsch] - CLEAN.include(target[:vpcb]) if File.exist? target[:vpcb] - CLOBBER.include("#{target[:name]}_*.sch") if File.exist? "#{target[:name]}_*.sch" - CLOBBER.include("#{target[:name]}_*.pcb")) if File.exist? "#{target[:name]}_*.pcb" + CLOBBER.include("#{target[:name]}_*.sch") + CLOBBER.include("#{target[:name]}_*.pcb") end -=begin + desc "print schematic and layout (as pdf)" -task :print => ["#{target}_schematic.pdf","#{target}_layout.pdf"] -CLEAN.include("#{target}_schematic.pdf") -CLEAN.include("#{target}_layout.pdf") +prints = targets.collect{|target| ["#{target[:name]}_schematic.pdf","#{target[:name]}_layout.pdf"]}.flatten +task :print => prints +CLEAN.include(prints) desc "export notes from schematic" -task :notes => "notes.txt" -CLOBBER.include("notes.txt") +notes = targets.collect{|target| "#{target[:name]}_notes.txt"} +task :notes => notes +CLEAN.include(notes) +=begin desc "verify schematic attributes" task :verify => vsch do |t| ["value","footprint"].each do |attribute| @@ -85,20 +87,23 @@ desc "convert schematic to pcb layout" task :sch2pcb => vsch do |t| sh "gsch2pcb #{t.prerequisites[0]} --elements-dir #{File.dirname(__FILE__)}/lib/footprints --skip-m4 --output-name #{target}" end +=end -PHOTOS = ["#{target}_layout-top.png","#{target}_layout-bottom.png"] +photos = targets.collect{|target| ["#{target[:name]}_layout-top.png","#{target[:name]}_layout-bottom.png"]}.flatten desc "render layout" -task :photo => PHOTOS -CLOBBER.include(PHOTOS) +task :photo => photos +CLOBBER.include(photos) -GERBERS = [".top.gbr",".topmask.gbr",".toppaste.gbr",".topsilk.gbr",".bottom.gbr",".bottommask.gbr",".bottompaste.gbr",".bottomsilk.gbr",".outline.gbr",".fab.gbr",".plated-drill.cnc",".unplated-drill.cnc"].collect{|suffix| target+suffix} desc "export gerber" -task :gerber => GERBERS -CLOBBER.include(GERBERS) +GERBERS = [".top.gbr",".topmask.gbr",".toppaste.gbr",".topsilk.gbr",".bottom.gbr",".bottommask.gbr",".bottompaste.gbr",".bottomsilk.gbr",".outline.gbr",".fab.gbr",".plated-drill.cnc",".unplated-drill.cnc"] +gerbers = targets.collect{|target| GERBERS.collect{|suffix| target[:name]+suffix}}.flatten +task :gerber => gerbers +CLOBBER.include(gerbers) desc "reformat gerber and drill output (some programs like LPKF CircuitPro have difficulties with gEDA pcb output)" -task :reformat => GERBERS do - GERBERS.each do |gerber| +task :reformat => gerbers do + gerbers.each do |gerber| + next unless File.exist? gerber if gerber.end_with? ".gbr" then sh "gerbv --export=rs274x --output=#{gerber} #{gerber}" elsif gerber.end_with? ".cnc" then @@ -106,7 +111,6 @@ task :reformat => GERBERS do end end end -=end # ================ # helper functions @@ -147,7 +151,7 @@ def bom2(schematic, attributes) end return to_return end -CLEAN.include("attribs") if File.exist? "attribs" +CLEAN.include("attribs") # =============== # file generation @@ -163,7 +167,7 @@ targets.each do |target| # the date sh "sed -i 's/\\(date=\\)\\$Date\\$/\\1#{date}/' #{t.name}" # the revision - sh "sed -i 's/\\(revision=\\)\\$Revision\\$/\\1#{targert[:sch_rev]}/' #{t.name}" + sh "sed -i 's/\\(revision=\\)\\$Revision\\$/\\1#{target[:sch_rev]}/' #{t.name}" end end @@ -183,53 +187,61 @@ targets.each do |target| end end end -=begin + desc "generate printable version (PDF) of schematic" -file "#{target}_schematic.pdf" => vsch do |t| - sh "gaf export -f pdf -c -o #{t.name} #{t.prerequisites.join(' ')} 2> /dev/null" +targets.each do |target| + file "#{target[:name]}_schematic.pdf" => target[:vsch] do |t| + sh "gaf export -f pdf -c -o #{t.name} #{t.prerequisites.join(' ')} 2> /dev/null" + end end desc "generate printable documentation (PDF) from layout" -file "#{target}_layout.pdf" => vpcb do |t| - sh "pcb -x ps --psfile #{t.name}.ps #{t.prerequisites.join(' ')} 2> /dev/null" - sh "ps2pdf #{t.name}.ps #{t.name} 2> /dev/null" - sh "rm #{t.name}.ps 2> /dev/null" +targets.each do |target| + file "#{target[:name]}_layout.pdf" => target[:vpcb] do |t| + sh "pcb -x ps --psfile #{t.name}.ps #{t.prerequisites.join(' ')} 2> /dev/null" + sh "ps2pdf #{t.name}.ps #{t.name} 2> /dev/null" + sh "rm #{t.name}.ps 2> /dev/null" + end end desc "generate note file from schematic, listing the 'note' attributes from elements" -file "notes.txt" => vsch do |t| - notes_data = bom2(t.prerequisites[0],"note") - File.open(t.name,"w") do |notes_file| - notes_data.each do |note| - next if note["note"]=="unknown" - notes_file.puts "#{note[:refdes]*','}:\n#{note["note"]}\n\n" +targets.each do |target| + file "#{target[:name]}_notes.txt" => target[:vsch] do |t| + notes_data = bom2(t.prerequisites[0],"note") + File.open(t.name,"w") do |notes_file| + notes_data.each do |note| + next if note["note"]=="unknown" + notes_file.puts "#{note[:refdes]*','}:\n#{note["note"]}\n\n" + end end end end desc "generate photo realistic picture from layout (front side)" -file "#{target}_layout-top.png" => vpcb do |t| -# sh "pcb -x png --dpi 600 --format PNG --photo-mode --outfile #{target}_layout-top.png #{t.prerequisites.join(' ')}" - sh "pcb -x png --format PNG --photo-mode --outfile #{target}_layout-top.png #{t.prerequisites.join(' ')}" -end - -desc "generate photo realistic picture from layout (bottom side)" -file "#{target}_layout-bottom.png" => vpcb do |t| -# sh "pcb -x png --dpi 600 --format PNG --photo-mode --photo-flip-x --outfile #{target}_layout-bottom.png #{t.prerequisites.join(' ')}" - sh "pcb -x png --format PNG --photo-mode --photo-flip-x --outfile #{target}_layout-bottom.png #{t.prerequisites.join(' ')}" -end - -desc "export gerber (and drill) files from layout" -GERBERS.each do |gerber| - file gerber => vpcb do |t| - puts "make #{t.name}" - sh "pcb -x gerber --gerberfile #{target} --all-layers #{t.prerequisites.join(' ')}" +targets.each do |target| + file "#{target[:name]}_layout-top.png" => target[:vpcb] do |t| + sh "pcb -x png --dpi 600 --format PNG --photo-mode --outfile #{t.name} #{t.prerequisites.join(' ')}" + end +end + +desc "generate photo realistic picture from layout (bottom side)" +targets.each do |target| + file "#{target[:name]}_layout-bottom.png" => target[:vpcb] do |t| + sh "pcb -x png --dpi 600 --format PNG --photo-mode --photo-flip-x --outfile #{t.name} #{t.prerequisites.join(' ')}" + end +end + +desc "export gerber (and drill) files from layout" +targets.each do |target| + GERBERS.each do |suffix| + file target[:name]+suffix => target[:vpcb] do |t| + sh "pcb -x gerber --gerberfile #{target[:name]} --all-layers #{t.prerequisites.join(' ')}" + end end end -ATTACHMENTS = ["cern_ohl_v_1_2_howto.pdf","CHANGES.txt","LICENSE.txt","PRODUCT.txt"] desc "create archive with release files" -file "hardware-release_v#{version}.tar.gz" => ATTACHMENTS+["lib",vsch,vpcb,"notes.txt","#{target}_schematic.pdf","#{target}_layout.pdf","#{target}_layout-top.png","#{target}_layout-bottom.png"]+GERBERS do |t| +ATTACHMENTS = ["cern_ohl_v_1_2_howto.pdf","CHANGES.txt","LICENSE.txt","PRODUCT.txt"] +file release => prints+notes+photos+gerbers+ATTACHMENTS do |t| sh "tar -acf '#{t.name}' #{t.prerequisites.join(' ')}" end -=end diff --git a/hardware/cern_ohl_v_1_2_howto.pdf b/hardware/cern_ohl_v_1_2_howto.pdf new file mode 100644 index 0000000..feec817 Binary files /dev/null and b/hardware/cern_ohl_v_1_2_howto.pdf differ