lib/blocks/compile.rb in bake-toolkit-2.43.2 vs lib/blocks/compile.rb in bake-toolkit-2.44.0
- old
+ new
@@ -5,10 +5,45 @@
require 'common/ext/dir'
require 'common/utils'
require 'bake/toolchain/colorizing_formatter'
require 'bake/config/loader'
+
+begin
+require 'Win32API'
+
+def longname short_name
+ max_path = 1024
+ long_name = " " * max_path
+ lfn_size = Win32API.new("kernel32", "GetLongPathName", ['P','P','L'],'L').call(short_name, long_name, max_path)
+ return long_name[0..lfn_size-1]
+end
+
+def shortname long_name
+ max_path = 1024
+ short_name = " " * max_path
+ lfn_size = Win32API.new("kernel32", "GetShortPathName", ['P','P','L'],'L').call(long_name, short_name, max_path)
+ return short_name[0..lfn_size-1]
+end
+
+def realname file
+ longname(shortname(file))
+end
+
+rescue LoadError
+
+def realname file
+ file
+end
+
+end
+
+
+
+
+
+
module Bake
module Blocks
class Compile < BlockBase
@@ -218,11 +253,11 @@
incList = process_result(cmd, consoleOutput, compiler[:ERROR_PARSER], nil, reason, success)
if type != :ASM and not Bake.options.analyze and not Bake.options.prepro
Dir.mutex.synchronize do
Dir.chdir(@projectDir) do
incList = Compile.read_depfile(dep_filename, @projectDir, @block.tcs[:COMPILER][:DEP_FILE_SINGLE_LINE]) if incList.nil?
- Compile.write_depfile(incList, dep_filename_conv, @projectDir)
+ Compile.write_depfile(source, incList, dep_filename_conv, @projectDir)
end
end
incList.each do |h|
Thread.current[:filelist].add(File.expand_path(h, @projectDir))
@@ -272,22 +307,38 @@
end
deps
end
# todo: move to toolchain util file
- def self.write_depfile(deps, dep_filename_conv, projDir)
+ def self.write_depfile(source, deps, dep_filename_conv, projDir)
if deps && !Bake.options.dry
+ wrongCase = false
begin
File.open(dep_filename_conv, 'wb') do |f|
deps.each do |dep|
f.puts(dep)
+
+ if (Bake.options.caseSensitivityCheck)
+ if dep.length<2 || dep[1] != ":"
+ real = realname(dep)
+ if dep != real && dep.upcase == real.upcase
+ Bake.formatter.printError("Case sensitivity error in #{source}:\n included: #{dep}\n realname: #{real}")
+ wrongCase = true
+ end
+ end
+ end
+
end
end
rescue Exception
Bake.formatter.printWarning("Could not write '#{dep_filename_conv}'", projDir)
return nil
end
+ if wrongCase
+ FileUtils.rm_f(dep_filename_conv)
+ raise SystemCommandFailed.new
+ end
end
end
def execute
#Dir.chdir(@projectDir) do
@@ -299,16 +350,15 @@
fileListBlock = Set.new if Bake.options.filelist
compileJobs = Multithread::Jobs.new(@source_files) do |jobs|
while source = jobs.get_next_or_nil do
- if ((jobs.failed || !Blocks::Block.delayed_result) and Bake.options.stopOnFirstError) or Bake::IDEInterface.instance.get_abort
+ if (jobs.failed && Bake.options.stopOnFirstError) or Bake::IDEInterface.instance.get_abort
break
end
SyncOut.startStream()
- SyncOut.reset_errors()
begin
Thread.current[:filelist] = Set.new if Bake.options.filelist
Thread.current[:lastCommand] = nil
result = false
@@ -324,12 +374,11 @@
end
end
jobs.set_failed if not result
ensure
- SyncOut.stopStream(result)
- SyncOut.flush_errors()
+ SyncOut.stopStream()
end
self.mutex.synchronize do
fileListBlock.merge(Thread.current[:filelist]) if Bake.options.filelist
end
@@ -415,25 +464,25 @@
def calcSources(cleaning = false, keep = false)
return @source_files if @source_files and not @source_files.empty?
@source_files = []
exclude_files = Set.new
- @config.excludeFiles.each do |p|
- Dir.glob_dir(p.name, @projectDir).each {|f| exclude_files << f}
+ @config.excludeFiles.each do |pr|
+ Dir.glob_dir(pr.name, @projectDir).each {|f| exclude_files << f}
end
source_files = Set.new
@config.files.each do |sources|
- p = sources.name
- p = p[2..-1] if p.start_with?"./"
+ pr = sources.name
+ pr = pr[2..-1] if pr.start_with?"./"
- res = Dir.glob_dir(p, @projectDir).sort
+ res = Dir.glob_dir(pr, @projectDir).sort
if res.length == 0 and cleaning == false
- if not p.include?"*" and not p.include?"?"
- Bake.formatter.printError("Source file '#{p}' not found", sources)
+ if not pr.include?"*" and not pr.include?"?"
+ Bake.formatter.printError("Source file '#{pr}' not found", sources)
raise SystemCommandFailed.new
elsif Bake.options.verbose >= 1
- Bake.formatter.printInfo("Source file pattern '#{p}' does not match to any file", sources)
+ Bake.formatter.printInfo("Source file pattern '#{pr}' does not match to any file", sources)
end
end
res.each do |f|
next if exclude_files.include?(f)
next if source_files.include?(f)
\ No newline at end of file