added bom capability
This commit is contained in:
parent
9c8932198e
commit
04eb3a2b78
|
@ -44,11 +44,11 @@ end
|
|||
# ==========
|
||||
|
||||
desc "main building task"
|
||||
task :default => [:version,:print,:notes,:gerber]
|
||||
task :default => [:version,:print,:notes,:bom,:gerber]
|
||||
|
||||
desc "create release file"
|
||||
release = "hardware-release_v#{version}.tar.gz"
|
||||
task :release => [:gerber,:photo,release]
|
||||
task :release => [:default,:photo,release]
|
||||
CLOBBER.include(release)
|
||||
|
||||
desc "set version in schematic and layout"
|
||||
|
@ -70,6 +70,11 @@ notes = targets.collect{|target| "#{target[:name]}_notes.txt"}
|
|||
task :notes => notes
|
||||
CLEAN.include(notes)
|
||||
|
||||
desc "export BOMs from schematic"
|
||||
boms = targets.collect{|target| "#{target[:name]}_bom.csv"}
|
||||
task :bom => boms
|
||||
CLEAN.include(boms)
|
||||
|
||||
=begin
|
||||
desc "verify schematic attributes"
|
||||
task :verify => vsch do |t|
|
||||
|
@ -144,7 +149,7 @@ end
|
|||
def bom2(schematic, attributes)
|
||||
to_return = []
|
||||
# force attributes to be an array
|
||||
attributes = case attributes.class
|
||||
attributes = case attributes
|
||||
when String
|
||||
[attributes]
|
||||
when Array
|
||||
|
@ -154,8 +159,10 @@ def bom2(schematic, attributes)
|
|||
end
|
||||
# generate bom2
|
||||
list = `gnetlist -g bom2 -Oattribs=#{attributes*','} -q -o - #{schematic}`
|
||||
list.encode!("UTF-8","ISO-8859-1")
|
||||
list.gsub!(/(\d[Mkmµ]?)\?/,'\1Ω')
|
||||
# parse bom2
|
||||
csv = CSV.parse(list,:col_sep => ":")
|
||||
csv = CSV.parse(list,{:col_sep => ":"})
|
||||
csv[1..-1].each do |row|
|
||||
line = {}
|
||||
row.each_index do |col|
|
||||
|
@ -230,6 +237,21 @@ targets.each do |target|
|
|||
end
|
||||
end
|
||||
|
||||
desc "generate BOM file from schematic"
|
||||
targets.each do |target|
|
||||
file "#{target[:name]}_bom.csv" => target[:vsch] do |t|
|
||||
attributes = ["category","device","value","description","manufacturer","manufacturer-id","digikey-id","farnell-id","mouser-id"]
|
||||
bom_data = bom2(t.prerequisites[0],attributes)
|
||||
CSV.open(t.name, "wb") do |csv|
|
||||
all_attributes = ["refdes","qty"]+attributes
|
||||
csv << all_attributes
|
||||
bom_data.each do |line|
|
||||
csv << all_attributes.collect{|attribute| line[attribute]}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "generate photo realistic picture from layout (front side)"
|
||||
targets.each do |target|
|
||||
file "#{target[:name]}_layout-top.png" => target[:vpcb] do |t|
|
||||
|
@ -247,7 +269,7 @@ end
|
|||
desc "create archive with release files"
|
||||
SOURCES = targets.collect{|target| [target[:sch],target[:pcb]]}.flatten
|
||||
ATTACHMENTS = ["cern_ohl_v_1_2_howto.pdf","CHANGES.txt","LICENSE.txt","PRODUCT.txt"]
|
||||
file release => SOURCES+prints+notes+photos+ATTACHMENTS do |t|
|
||||
file release => SOURCES+prints+notes+boms+photos+ATTACHMENTS do |t|
|
||||
gerbers = Dir.entries(".").select{|file| file.end_with? ".gbr" or file.end_with? ".cnc"}
|
||||
sh "tar -acf '#{t.name}' #{(t.prerequisites+gerbers).join(' ')}"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue