class CompileCommand
Public Instance Methods
getCompileCommand(xcactivitylog, compile_file, output_file)
click to toggle source
# File lib/xcactivitylog/compile_command.rb, line 9 def getCompileCommand(xcactivitylog, compile_file, output_file) ret = false if File.directory?(xcactivitylog) path = "#{xcactivitylog}/*.xcactivitylog" files_sorted_by_time = Dir[path].sort!{ |x,y| File.mtime(y) <=> File.mtime(x) } files_sorted_by_time.each do |file| ret = getCompileCommandFromLog(file, compile_file, output_file) if ret break end end else ret = getCompileCommandFromLog(xcactivitylog, compile_file, output_file) end end
getCompileCommandFromLog(xcactivitylog, compile_file, output_file)
click to toggle source
# File lib/xcactivitylog/compile_command.rb, line 25 def getCompileCommandFromLog(xcactivitylog, compile_file, output_file) ext = File.extname(compile_file) file = File.basename(compile_file, ext) file = "#{file}.o" output_file = "#{output_file}.sh" # filter compile command reg = ".*clang+.*Applications(.*o)" # prase slf0 and filter the command flag = false text = XcodeResultBundleProcessor::Logdeserializer.deserialize_action_logs(xcactivitylog) text.each do |item| # puts item # if item =~ reg && item =~ /#{file}/ if item =~ /#{file}/ content = item.match(reg) if content puts content writeFile(output_file, content) flag = true break end end end flag end
writeFile(file, content)
click to toggle source
# File lib/xcactivitylog/compile_command.rb, line 56 def writeFile(file, content) aFile = File.new(file, "w+") if aFile aFile.syswrite(content) end end