lib/blocks/block.rb in bake-toolkit-2.62.0 vs lib/blocks/block.rb in bake-toolkit-2.63.0
- old
+ new
@@ -20,11 +20,11 @@
@@block_counter = 0
@@delayed_result = true
@@threads = []
- attr_reader :lib_elements, :projectDir, :library, :config, :projectName, :configName, :prebuild, :output_dir, :tcs
+ attr_reader :lib_elements, :projectDir, :library, :executable, :config, :projectName, :configName, :prebuild, :output_dir, :tcs
attr_accessor :visited, :inDeps, :result, :bes, :besDirect
def startupSteps
@startupSteps ||= []
end
@@ -62,20 +62,25 @@
end
def set_library(library)
@library = library
end
-
+
+ def set_executable(executable)
+ @executable = executable
+ end
+
def qname()
@projectName + "," + @configName
end
def initialize(config, referencedConfigs, prebuild, tcs)
@inDeps = false
@prebuild = prebuild
@visited = false
@library = nil
+ @executable = nil
@config = config
@referencedConfigs = referencedConfigs
@projectName = config.parent.name
@configName = config.name
@projectDir = config.get_project_dir
@@ -117,28 +122,37 @@
if (inc[0] == @projectName) # prio 1: the real path magic
resPathMagic = inc[1..-1].join("/") # within self
resPathMagic = "." if resPathMagic == ""
res << resPathMagic
+ if warnIfLocal
+ if resPathMagic == "."
+ Bake.formatter.printInfo("\"#{d}\" uses path magic in IncludeDir, please use \".\" instead", elem)
+ else
+ Bake.formatter.printInfo("\"#{d}\" uses path magic in IncludeDir, please omit \"#{inc[0]}/\" or use \"./#{resPathMagic}\"", elem) if warnIfLocal
+ end
+ end
elsif @referencedConfigs.include?(inc[0])
dirOther = @referencedConfigs[inc[0]].first.parent.get_project_dir
resPathMagic = File.rel_from_to_project(@projectDir, dirOther, false)
postfix = inc[1..-1].join("/")
resPathMagic = resPathMagic + "/" + postfix if postfix != ""
resPathMagic = "." if resPathMagic == ""
res << resPathMagic
+ Bake.formatter.printInfo("\"#{d}\" uses path magic in IncludeDir, please use a Dependency to \"#{inc[0]}\" instead", elem) if warnIfLocal
end
if File.exists?(@projectDir + "/" + d) # prio 2: local, e.g. "include"
res << d
end
- # prioo 3: check if dir exists without Project.meta entry
+ # prio 3: check if dir exists without Project.meta entry
Bake.options.roots.each do |r|
absIncDir = r.dir+"/"+d
if File.exists?(absIncDir)
res << File.rel_from_to_project(@projectDir,absIncDir,false)
+ Bake.formatter.printInfo("\"#{d}\" uses path magic in IncludeDir, please create a Project.meta in \"#{absIncDir}\" or upwards and use a Dependency instead", elem) if warnIfLocal && res.length == 1
end
end
return d if res.empty? # prio 4: fallback, no path found
@@ -353,18 +367,18 @@
end
def callSteps(method)
@config.writeEnvVars()
Thread.current[:lastCommand] = nil
- allSteps = (preSteps + mainSteps + postSteps)
+ @allSteps = (preSteps + mainSteps + postSteps)
# check if we have to delay the output (if the last step of this block is not in a thread)
@outputStep = nil
- allSteps.each { |step| @outputStep = independent?(method, step) ? step : nil }
- while !allSteps.empty?
+ @allSteps.each { |step| @outputStep = independent?(method, step) ? step : nil }
+ while !@allSteps.empty?
parallel = []
- while allSteps.first && independent?(method, allSteps.first)
- parallel << allSteps.shift
+ while @allSteps.first && independent?(method, @allSteps.first)
+ parallel << @allSteps.shift
end
if parallel.length > 0
execute_in_thread(parallel) {
lastStep = Thread.current[:steps].last
begin
@@ -381,11 +395,11 @@
ensure
SyncOut.stopStream() if lastStep == @outputStep if Bake.options.syncedOutput
end
}
else
- step = allSteps.shift
+ step = @allSteps.shift
Blocks::Block::waitForAllThreads()
@result = executeStep(step, method) if @result
@outputStep = nil if !@result && blockAbort?(@result)
end
return @result if blockAbort?(@result)
@@ -402,17 +416,33 @@
end
end
return true
end
- return true if (@visited)
- @visited = true
+ SyncOut.mutex.synchronize do
+ if @visited
+ while !defined?(@allSteps) || !@allSteps.empty?
+ sleep(0.1)
+ end
+ return true # maybe to improve later (return false if step has a failed non-independent step)
+ end
+ @visited = true
+ end
@inDeps = true
- depResult = callDeps(:execute)
+ begin
+ depResult = callDeps(:execute)
+ rescue Exception => e
+ @allSteps = []
+ raise
+ end
+
@inDeps = false
- return @result && depResult if blockAbort?(depResult)
+ if blockAbort?(depResult)
+ @allSteps = []
+ return @result && depResult
+ end
Bake::IDEInterface.instance.set_build_info(@projectName, @configName)
begin
SyncOut.mutex.synchronize do
@outputStep = nil
@@ -443,11 +473,12 @@
SyncOut.stopStream()
else
SyncOut.discardStreams()
end
end
+ @allSteps = []
end
-
+
return (depResult && @result)
end
def clean
return true if (@visited)
\ No newline at end of file