Class: Bake::Blocks::Block
- Inherits:
-
Object
- Object
- Bake::Blocks::Block
- Defined in:
- lib/blocks/block.rb
Instance Attribute Summary collapse
-
#circularCheck ⇒ Object
Returns the value of attribute circularCheck.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#inDeps ⇒ Object
Returns the value of attribute inDeps.
-
#lib_elements ⇒ Object
readonly
Returns the value of attribute lib_elements.
-
#library ⇒ Object
readonly
Returns the value of attribute library.
-
#projectDir ⇒ Object
readonly
Returns the value of attribute projectDir.
-
#projectName ⇒ Object
readonly
Returns the value of attribute projectName.
-
#result ⇒ Object
Returns the value of attribute result.
-
#visited ⇒ Object
Returns the value of attribute visited.
Class Method Summary collapse
Instance Method Summary collapse
- #add_lib_element(elem) ⇒ Object
- #callDeps(method) ⇒ Object
- #callSteps(method) ⇒ Object
- #childs ⇒ Object
- #clean ⇒ Object
- #convPath(dir, elem = nil) ⇒ Object
- #dependencies ⇒ Object
- #execute ⇒ Object
- #executeStep(step, method) ⇒ Object
- #exits ⇒ Object
- #exitSteps ⇒ Object
-
#initialize(config, referencedConfigs) ⇒ Block
constructor
A new instance of Block.
- #mainSteps ⇒ Object
- #parents ⇒ Object
- #postSteps ⇒ Object
- #preSteps ⇒ Object
- #set_library(library) ⇒ Object
- #startup ⇒ Object
- #startupSteps ⇒ Object
Constructor Details
#initialize(config, referencedConfigs) ⇒ Block
Returns a new instance of Block.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/blocks/block.rb', line 57 def initialize(config, referencedConfigs) @inDeps = false @circularCheck @visited = false @library = nil @config = config @referencedConfigs = referencedConfigs @projectName = config.parent.name @configName = config.name @projectDir = config.get_project_dir @@block_counter = 0 @result = true @lib_elements = Bake::LibElements.calcLibElements(self) end |
Instance Attribute Details
#circularCheck ⇒ Object
Returns the value of attribute circularCheck.
19 20 21 |
# File 'lib/blocks/block.rb', line 19 def circularCheck @circularCheck end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
18 19 20 |
# File 'lib/blocks/block.rb', line 18 def config @config end |
#inDeps ⇒ Object
Returns the value of attribute inDeps.
19 20 21 |
# File 'lib/blocks/block.rb', line 19 def inDeps @inDeps end |
#lib_elements ⇒ Object (readonly)
Returns the value of attribute lib_elements.
18 19 20 |
# File 'lib/blocks/block.rb', line 18 def lib_elements @lib_elements end |
#library ⇒ Object (readonly)
Returns the value of attribute library.
18 19 20 |
# File 'lib/blocks/block.rb', line 18 def library @library end |
#projectDir ⇒ Object (readonly)
Returns the value of attribute projectDir.
18 19 20 |
# File 'lib/blocks/block.rb', line 18 def projectDir @projectDir end |
#projectName ⇒ Object (readonly)
Returns the value of attribute projectName.
18 19 20 |
# File 'lib/blocks/block.rb', line 18 def projectName @projectName end |
#result ⇒ Object
Returns the value of attribute result.
19 20 21 |
# File 'lib/blocks/block.rb', line 19 def result @result end |
#visited ⇒ Object
Returns the value of attribute visited.
19 20 21 |
# File 'lib/blocks/block.rb', line 19 def visited @visited end |
Class Method Details
.block_counter ⇒ Object
122 123 124 |
# File 'lib/blocks/block.rb', line 122 def self.block_counter @@block_counter += 1 end |
.reset_block_counter ⇒ Object
126 127 128 |
# File 'lib/blocks/block.rb', line 126 def self.reset_block_counter @@block_counter = 0 end |
.set_num_projects(num) ⇒ Object
130 131 132 |
# File 'lib/blocks/block.rb', line 130 def self.set_num_projects(num) @@num_projects = num end |
Instance Method Details
#add_lib_element(elem) ⇒ Object
73 74 75 |
# File 'lib/blocks/block.rb', line 73 def add_lib_element(elem) @lib_elements[2000000000] = [elem] end |
#callDeps(method) ⇒ Object
158 159 160 161 162 163 164 165 |
# File 'lib/blocks/block.rb', line 158 def callDeps(method) depResult = true dependencies.each do |dep| depResult = (ALL_BLOCKS[dep].send(method) and depResult) break if not depResult and Bake..stopOnFirstError end return depResult end |
#callSteps(method) ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/blocks/block.rb', line 167 def callSteps(method) preSteps.each do |step| @result = executeStep(step, method) if @result return false if not @result and Bake..stopOnFirstError end mainSteps.each do |step| @result = executeStep(step, method) if @result return false if not @result and Bake..stopOnFirstError end postSteps.each do |step| @result = executeStep(step, method) if @result return false if not @result and Bake..stopOnFirstError end return @result end |
#childs ⇒ Object
45 46 47 |
# File 'lib/blocks/block.rb', line 45 def childs @childs ||= [] end |
#clean ⇒ Object
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/blocks/block.rb', line 213 def clean return true if (@visited) @visited = true depResult = callDeps(:clean) return false if not depResult and Bake..stopOnFirstError if Bake..verbose >= 2 Bake.formatter.printAdditionalInfo "**** Cleaning #{Block.block_counter} of #{@@num_projects}: #{@projectName} (#{@configName}) ****" end @result = callSteps(:clean) if Bake..clobber Dir.chdir(@projectDir) do if File.exist?".bake" puts "Deleting folder .bake" if Bake..verbose >= 2 FileUtils.rm_rf(".bake") end end end return (depResult && @result) end |
#convPath(dir, elem = nil) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/blocks/block.rb', line 77 def convPath(dir, elem=nil) if dir.respond_to?("name") d = dir.name elem = dir else d = dir end return d if Bake..no_autodir inc = d.split("/") if (inc[0] == @projectName) res = inc[1..-1].join("/") # within self res = "." if res == "" elsif @referencedConfigs.include?(inc[0]) dirOther = @referencedConfigs[inc[0]].first.parent.get_project_dir res = File.rel_from_to_project(@projectDir, dirOther, false) postfix = inc[1..-1].join("/") res = res + "/" + postfix if postfix != "" else if (inc[0] != "..") return d if File.exists?(@projectDir + "/" + d) # e.g. "include" # check if dir exists without Project.meta entry Bake..roots.each do |r| absIncDir = r+"/"+d if File.exists?(absIncDir) res = File.rel_from_to_project(@projectDir,absIncDir,false) if not res.nil? return res end end end else if elem and Bake..verbose >= 2 Bake.formatter.printInfo("\"..\" in path name found", elem) end end res = d # relative from self as last resort end res end |
#dependencies ⇒ Object
41 42 43 |
# File 'lib/blocks/block.rb', line 41 def dependencies @dependencies ||= [] end |
#execute ⇒ Object
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/blocks/block.rb', line 187 def execute if (@inDeps) if Bake..verbose >= 1 Bake.formatter.printWarning("Circular dependency found including project #{@projectName} with config #{@configName}", @config) end return true end return true if (@visited) @visited = true @inDeps = true depResult = callDeps(:execute) @inDeps = false return false if not depResult and Bake..stopOnFirstError Bake::IDEInterface.instance.set_build_info(@projectName, @configName) if Bake..verbose >= 1 Bake.formatter.printAdditionalInfo "**** Building #{Block.block_counter} of #{@@num_projects}: #{@projectName} (#{@configName}) ****" end @result = callSteps(:execute) return (depResult && @result) end |
#executeStep(step, method) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/blocks/block.rb', line 134 def executeStep(step, method) begin @result = step.send(method) && @result rescue Bake::SystemCommandFailed => scf @result = false ProcessHelper.killProcess(true) rescue SystemExit => exSys @result = false ProcessHelper.killProcess(true) rescue Exception => ex1 @result = false if not Bake::IDEInterface.instance.get_abort Bake.formatter.printError("Error: #{ex1.message}") puts ex1.backtrace if Bake..debug end end if Bake::IDEInterface.instance.get_abort raise AbortException.new end return @result end |
#exits ⇒ Object
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/blocks/block.rb', line 255 def exits return true if (@visited) @visited = true depResult = callDeps(:exits) if Bake..verbose >= 1 and not exitSteps.empty? Bake.formatter.printAdditionalInfo "**** Exiting #{@projectName} (#{@configName}) ****" end exitSteps.each do |step| @result = executeStep(step, :exitStep) && @result end return (depResult && @result) end |
#exitSteps ⇒ Object
37 38 39 |
# File 'lib/blocks/block.rb', line 37 def exitSteps @exitSteps ||= [] end |
#mainSteps ⇒ Object
29 30 31 |
# File 'lib/blocks/block.rb', line 29 def mainSteps @mainSteps ||= [] end |
#parents ⇒ Object
49 50 51 |
# File 'lib/blocks/block.rb', line 49 def parents @parents ||= [] end |
#postSteps ⇒ Object
33 34 35 |
# File 'lib/blocks/block.rb', line 33 def postSteps @postSteps ||= [] end |
#preSteps ⇒ Object
25 26 27 |
# File 'lib/blocks/block.rb', line 25 def preSteps @preSteps ||= [] end |
#set_library(library) ⇒ Object
53 54 55 |
# File 'lib/blocks/block.rb', line 53 def set_library(library) @library = library end |
#startup ⇒ Object
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/blocks/block.rb', line 238 def startup return true if (@visited) @visited = true depResult = callDeps(:startup) if Bake..verbose >= 1 and not startupSteps.empty? Bake.formatter.printAdditionalInfo "**** Starting up #{@projectName} (#{@configName}) ****" end startupSteps.each do |step| @result = executeStep(step, :startupStep) && @result end return (depResult && @result) end |
#startupSteps ⇒ Object
21 22 23 |
# File 'lib/blocks/block.rb', line 21 def startupSteps @startupSteps ||= [] end |