added versioning in pcb layout
This commit is contained in:
parent
58273f9930
commit
54414cc9af
26
pcb/Rakefile
26
pcb/Rakefile
|
@ -8,14 +8,20 @@ require 'rake/clean'
|
|||
target = "led-controller"
|
||||
# schema
|
||||
sch = "#{target}.sch"
|
||||
# pcb layout
|
||||
pcb = "#{target}.pcb"
|
||||
# project version, read from "version" file
|
||||
version = IO.read("version").chomp
|
||||
# current date for stamping output
|
||||
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
|
||||
# pcb layout revision, based on the number of pcb commits)
|
||||
pcb_rev = `git log --pretty=oneline "#{pcb}" | wc -l`.chomp.to_i
|
||||
# schema name with version and revition
|
||||
vsch = "#{target}_v#{version}.#{sch_rev.to_s.rjust(3,'0')}.sch"
|
||||
# pcb layout name with version and revition
|
||||
vpcb = "#{target}_v#{version}.#{pcb_rev.to_s.rjust(3,'0')}.pcb"
|
||||
|
||||
# ==========
|
||||
# main tasks
|
||||
|
@ -23,8 +29,8 @@ vsch = "#{target}_v#{version}.#{sch_rev.to_s.rjust(3,'0')}.sch"
|
|||
|
||||
task :default => [:version,:print,:notes]
|
||||
|
||||
desc "set version in schematic"
|
||||
task :version => vsch
|
||||
desc "set version in schematic and layout"
|
||||
task :version => [vsch,vpcb]
|
||||
CLEAN.include(vsch)
|
||||
CLOBBER.include("#{target}_*.sch")
|
||||
|
||||
|
@ -103,11 +109,21 @@ file vsch => sch do |t|
|
|||
sh "cp #{t.prerequisites.join(' ')} #{t.name}"
|
||||
# on \ is to prevent ruby interpreting it, th other is for sed
|
||||
# the version
|
||||
sh "sed -i 's/\\(version=\\)\\$Version\\$/\\1#{version}/' #{vsch}"
|
||||
sh "sed -i 's/\\(version=\\)\\$Version\\$/\\1#{version}/' #{t.name}"
|
||||
# the date
|
||||
sh "sed -i 's/\\(date=\\)\\$Date\\$/\\1#{date}/' #{vsch}"
|
||||
sh "sed -i 's/\\(date=\\)\\$Date\\$/\\1#{date}/' #{t.name}"
|
||||
# the revision
|
||||
sh "sed -i 's/\\(revision=\\)\\$Revision\\$/\\1#{sch_rev}/' #{vsch}"
|
||||
sh "sed -i 's/\\(revision=\\)\\$Revision\\$/\\1#{sch_rev}/' #{t.name}"
|
||||
end
|
||||
|
||||
file vpcb => pcb do |t|
|
||||
sh "cp #{t.prerequisites.join(' ')} #{t.name}"
|
||||
# on \ is to prevent ruby interpreting it, th other is for sed
|
||||
# the version and revision
|
||||
version_revision = "v#{version}.#{pcb_rev.to_s.rjust(3,'0')}"
|
||||
sh "sed -i 's/\\$version\\$/#{version_revision}/' #{t.name}"
|
||||
# the date
|
||||
sh "sed -i 's/\\$date\\$/#{date}/' #{t.name}"
|
||||
end
|
||||
|
||||
file "#{target}_schematic.pdf" => vsch do |t|
|
||||
|
|
Loading…
Reference in New Issue