add multiple target capability. for now names are read, and task version has been adapted
This commit is contained in:
parent
b5a6f73251
commit
4690936c91
|
@ -4,26 +4,34 @@ require 'rake/clean'
|
||||||
# project variables
|
# project variables
|
||||||
# =================
|
# =================
|
||||||
|
|
||||||
# main name used if filename
|
# main names used for filenames
|
||||||
target = IO.read("name").split("\n")[0]
|
names = IO.read("name").split("\n").select {|target| !target.empty?}
|
||||||
raise "define project name in 'name' file" unless target
|
raise "define project name(s) in 'name' file" if names.empty?
|
||||||
# schema
|
|
||||||
sch = "#{target}.sch"
|
|
||||||
# pcb layout
|
|
||||||
pcb = "#{target}.pcb"
|
|
||||||
# project version, read from "version" file
|
# project version, read from "version" file
|
||||||
version = IO.read("version").split("\n")[0]
|
version = IO.read("version").split("\n")[0]
|
||||||
raise "define project version in 'version' file" unless version
|
raise "define project version in 'version' file" unless version
|
||||||
# current date for stamping output
|
# current date for stamping output
|
||||||
date = Time.now.strftime("%Y-%m-%d")
|
date = Time.now.strftime("%Y-%m-%d")
|
||||||
# schematic revision, based on the number of schematic commits)
|
|
||||||
sch_rev = `git log --pretty=oneline "#{sch}" | wc -l`.chomp.to_i
|
# create targets for each name
|
||||||
# pcb layout revision, based on the number of pcb commits)
|
targets = []
|
||||||
pcb_rev = `git log --pretty=oneline "#{pcb}" | wc -l`.chomp.to_i
|
names.each do |name|
|
||||||
# schema name with version and revition
|
# schema
|
||||||
vsch = "#{target}_v#{version}.#{sch_rev.to_s.rjust(3,'0')}.sch"
|
sch = "#{name}.sch"
|
||||||
# pcb layout name with version and revition
|
# pcb layout
|
||||||
vpcb = "#{target}_v#{version}.#{pcb_rev.to_s.rjust(3,'0')}.pcb"
|
pcb = "#{name}.pcb"
|
||||||
|
# schematic revision, based on the number of schematic commits
|
||||||
|
sch_rev = `git log --pretty=oneline "#{sch}" | wc -l`.chomp.to_i
|
||||||
|
# pcb layout revision, based on the number of pcb commits
|
||||||
|
pcb_rev = pcbs.collect {|pcb| `git log --pretty=oneline "#{pcb}" | wc -l`.chomp.to_i}
|
||||||
|
# schema name with version and revition
|
||||||
|
vsch = "#{name}_v#{version}.#{sch_rev.to_s.rjust(3,'0')}.sch"
|
||||||
|
# pcb layout name with version and revition
|
||||||
|
vpcb = "#{name}_v#{version}.#{pcb_rev.to_s.rjust(3,'0')}.pcb"
|
||||||
|
# add to targets
|
||||||
|
targets << { name: name, sch: sch, pcb: pcb, sch_rev: sch_rev, pcb_rev: pcb_rev, vsch: vsch, vpcb: vpcb }
|
||||||
|
end
|
||||||
|
|
||||||
# ==========
|
# ==========
|
||||||
# main tasks
|
# main tasks
|
||||||
|
@ -37,11 +45,13 @@ task :release => "hardware-release_v#{version}.tar.gz"
|
||||||
CLOBBER.include("hardware-release_v#{version}.tar.gz")
|
CLOBBER.include("hardware-release_v#{version}.tar.gz")
|
||||||
|
|
||||||
desc "set version in schematic and layout"
|
desc "set version in schematic and layout"
|
||||||
task :version => [vsch,vpcb]
|
task :version => targets.collect{|target| [target[:vsch],target[:vpcb]}.flatten
|
||||||
CLEAN.include(vsch)
|
targets.each do |target|
|
||||||
CLEAN.include(vpcb)
|
CLEAN.include(target[:vsch])
|
||||||
CLOBBER.include("#{target}_*.sch")
|
CLEAN.include(target[:vpcb])
|
||||||
CLOBBER.include("#{target}_*.pcb")
|
CLOBBER.include("#{target[:name]}_*.sch")
|
||||||
|
CLOBBER.include("#{target[:name]}_*.pcb")
|
||||||
|
end
|
||||||
|
|
||||||
desc "print schematic and layout (as pdf)"
|
desc "print schematic and layout (as pdf)"
|
||||||
task :print => ["#{target}_schematic.pdf","#{target}_layout.pdf"]
|
task :print => ["#{target}_schematic.pdf","#{target}_layout.pdf"]
|
||||||
|
@ -142,29 +152,33 @@ CLEAN.include("attribs")
|
||||||
# ===============
|
# ===============
|
||||||
|
|
||||||
desc "copy schematic to version it: include version, revision, and date"
|
desc "copy schematic to version it: include version, revision, and date"
|
||||||
file vsch => sch do |t|
|
tagerts.each do |target|
|
||||||
sh "cp #{t.prerequisites.join(' ')} #{t.name}"
|
file tagert[:vsch] => target[:sch] do |t|
|
||||||
# on \ is to prevent ruby interpreting it, th other is for sed
|
sh "cp #{t.prerequisites.join(' ')} #{t.name}"
|
||||||
# the version
|
# on \ is to prevent ruby interpreting it, th other is for sed
|
||||||
sh "sed -i 's/\\(version=\\)\\$Version\\$/\\1#{version}/' #{t.name}"
|
# the version
|
||||||
# the date
|
sh "sed -i 's/\\(version=\\)\\$Version\\$/\\1#{version}/' #{t.name}"
|
||||||
sh "sed -i 's/\\(date=\\)\\$Date\\$/\\1#{date}/' #{t.name}"
|
# the date
|
||||||
# the revision
|
sh "sed -i 's/\\(date=\\)\\$Date\\$/\\1#{date}/' #{t.name}"
|
||||||
sh "sed -i 's/\\(revision=\\)\\$Revision\\$/\\1#{sch_rev}/' #{t.name}"
|
# the revision
|
||||||
|
sh "sed -i 's/\\(revision=\\)\\$Revision\\$/\\1#{sch_rev}/' #{t.name}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "copy layout to version it: include version, date, and run teardrops when available"
|
desc "copy layout to version it: include version, date, and run teardrops when available"
|
||||||
file vpcb => pcb do |t|
|
tagerts.each do |target|
|
||||||
sh "cp #{t.prerequisites.join(' ')} #{t.name}"
|
file tagert[:vpcb] => target[:pcb] do |t|
|
||||||
# on \ is to prevent ruby interpreting it, th other is for sed
|
sh "cp #{t.prerequisites.join(' ')} #{t.name}"
|
||||||
# the version and revision
|
# on \ is to prevent ruby interpreting it, th other is for sed
|
||||||
version_revision = "v#{version}.#{pcb_rev.to_s.rjust(3,'0')}"
|
# the version and revision
|
||||||
sh "sed -i 's/\\$version\\$/#{version_revision}/' #{t.name}"
|
version_revision = "v#{version}.#{pcb_rev.to_s.rjust(3,'0')}"
|
||||||
# the date
|
sh "sed -i 's/\\$version\\$/#{version_revision}/' #{t.name}"
|
||||||
sh "sed -i 's/\\$date\\$/#{date}/' #{t.name}"
|
# the date
|
||||||
# run teardrop for vias and pins
|
sh "sed -i 's/\\$date\\$/#{date}/' #{t.name}"
|
||||||
if File.exist? "#{Dir.home}/.pcb/plugins/teardrops.so" then
|
# run teardrop for vias and pins
|
||||||
sh "pcb --action-string \"djopt(splitlines) Teardrops() s() q()\" #{t.name}"
|
if File.exist? "#{Dir.home}/.pcb/plugins/teardrops.so" then
|
||||||
|
sh "pcb --action-string \"djopt(splitlines) Teardrops() s() q()\" #{t.name}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue