Class: Bake::Blocks::Block
- Inherits:
-
Object
- Object
- Bake::Blocks::Block
- Defined in:
- lib/blocks/block.rb
Instance Attribute Summary collapse
-
#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.
-
#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
- #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
- #postSteps ⇒ Object
- #preSteps ⇒ Object
- #set_library(library) ⇒ Object
- #startup ⇒ Object
- #startupSteps ⇒ Object
Constructor Details
#initialize(config, referencedConfigs) ⇒ Block
Returns a new instance of Block.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/blocks/block.rb', line 49 def initialize(config, referencedConfigs) @inDeps = false @visited = false @library = nil @config = config @referencedConfigs = referencedConfigs @projectName = config.parent.name @configName = config.name @projectDir = config.get_project_dir @@block_counter = 0 @result = false @lib_elements = Bake::LibElements.calcLibElements(self) end |
Instance Attribute Details
#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 |
#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
113 114 115 |
# File 'lib/blocks/block.rb', line 113 def self.block_counter @@block_counter += 1 end |
.reset_block_counter ⇒ Object
117 118 119 |
# File 'lib/blocks/block.rb', line 117 def self.reset_block_counter @@block_counter = 0 end |
.set_num_projects(num) ⇒ Object
121 122 123 |
# File 'lib/blocks/block.rb', line 121 def self.set_num_projects(num) @@num_projects = num end |
Instance Method Details
#add_lib_element(elem) ⇒ Object
64 65 66 |
# File 'lib/blocks/block.rb', line 64 def add_lib_element(elem) @lib_elements[2000000000] = [elem] end |
#callDeps(method) ⇒ Object
146 147 148 149 150 151 152 153 |
# File 'lib/blocks/block.rb', line 146 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
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/blocks/block.rb', line 155 def callSteps(method) @result = true 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 |
#clean ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/blocks/block.rb', line 201 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
68 69 70 71 72 73 74 75 76 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 |
# File 'lib/blocks/block.rb', line 68 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
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/blocks/block.rb', line 175 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
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/blocks/block.rb', line 125 def executeStep(step, method) @result = false begin @result = step.send(method) rescue Bake::SystemCommandFailed => scf rescue SystemExit => exSys ProcessHelper.killProcess(true) rescue Exception => ex1 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
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/blocks/block.rb', line 246 def exits return true if (@visited) @visited = true depResult = callDeps(:exits) return false if not depResult and Bake..stopOnFirstError if Bake..verbose >= 1 and not exitSteps.empty? Bake.formatter.printAdditionalInfo "**** Exiting #{@projectName} (#{@configName}) ****" end @result = true exitSteps.each do |step| @result = executeStep(step, :exitStep) if @result return false if not @result and Bake..stopOnFirstError 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 |
#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
45 46 47 |
# File 'lib/blocks/block.rb', line 45 def set_library(library) @library = library end |
#startup ⇒ Object
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/blocks/block.rb', line 226 def startup return true if (@visited) @visited = true depResult = callDeps(:startup) return false if not depResult and Bake..stopOnFirstError if Bake..verbose >= 1 and not startupSteps.empty? Bake.formatter.printAdditionalInfo "**** Starting up #{@projectName} (#{@configName}) ****" end @result = true startupSteps.each do |step| @result = executeStep(step, :startupStep) if @result return false if not @result and Bake..stopOnFirstError end return (depResult && @result) end |
#startupSteps ⇒ Object
21 22 23 |
# File 'lib/blocks/block.rb', line 21 def startupSteps @startupSteps ||= [] end |