Class: R::Target
Overview
The base target class.
It has simple building logic and a way to register targets. All targets should inherit from this class.
Direct Known Subclasses
C::TargetTag, L::C::TargetCSource, L::Test::TargetTest, TargetSmart, TargetSource
Constant Summary collapse
- @@symbolcounter =
Shouldn’t repeat very often.
rand(2**160)
Instance Method Summary collapse
-
#build ⇒ void
Build.
-
#clean? ⇒ Boolean
Is this target up to date?.
-
#description ⇒ String?
Description.
-
#hash_input ⇒ String
Return a hash of this target.
- #hash_output(t) ⇒ Object
- #hash_outputs(t = output) ⇒ Object
- #hash_self ⇒ Object
-
#input ⇒ Set<Pathname>
Inputs.
-
#output ⇒ Set<Pathname>
Outputs.
-
#register ⇒ void
Register this target.
Instance Method Details
#build ⇒ void
This method returns an undefined value.
Build.
This is a simple build method. It calls #build_dependancies then #build_self. Either or both of these methods can be overwritten to customize the build or this function can be overwritten to have more control.
180 181 182 183 184 185 |
# File 'lib/rub/r/target.rb', line 180 def build build_dependancies build_self nil end |
#clean? ⇒ Boolean
Is this target up to date?
116 117 118 |
# File 'lib/rub/r/target.rb', line 116 def clean? false end |
#description ⇒ String?
Description.
Shown for :help.
100 101 102 |
# File 'lib/rub/r/target.rb', line 100 def description nil end |
#hash_input ⇒ String
Return a hash of this target.
This hash should represent a unique build environment and change if anything in that environment does. This includes, but is not limited to:
-
Input files.
-
Output files.
-
Build commands.
130 131 132 133 134 135 136 |
# File 'lib/rub/r/target.rb', line 130 def hash_input Digest::SHA1.digest( ( input.map{|i| R::get_target(i).hash_output(i) } ).join ) end |
#hash_output(t) ⇒ Object
139 140 141 142 143 144 145 146 |
# File 'lib/rub/r/target.rb', line 139 def hash_output(t) if t.is_a? Symbol @@symbolcounter++ "symbol-#{@@symbolcounter.to_s(16)}" # Never clean. else Digest::SHA1.file(t).to_s end end |
#hash_outputs(t = output) ⇒ Object
148 149 150 |
# File 'lib/rub/r/target.rb', line 148 def hash_outputs(t = output) Digest::SHA1.digest(t.map{|o| hash_output(o)}.join) end |
#hash_self ⇒ Object
152 153 154 |
# File 'lib/rub/r/target.rb', line 152 def hash_self Digest::SHA1.digest(hash_input+hash_outputs) end |
#input ⇒ Set<Pathname>
Inputs
85 86 87 |
# File 'lib/rub/r/target.rb', line 85 def input Set.new end |
#output ⇒ Set<Pathname>
Outputs
92 93 94 |
# File 'lib/rub/r/target.rb', line 92 def output Set.new end |
#register ⇒ void
This method returns an undefined value.
Register this target.
Registers this target as building it’s #outputs.
109 110 111 112 113 |
# File 'lib/rub/r/target.rb', line 109 def register output.each do |d| R.set_target(d, self) end end |