Merge remote-tracking branch 'hw-template/master'

This commit is contained in:
Kevin Redon 2014-03-26 13:04:45 +01:00
commit 4939d8ff30
2 changed files with 67 additions and 55 deletions

View File

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

Binary file not shown.