Method: Bake::Blocks::BlockBase#calcFileCmd

Defined in:
lib/blocks/blockBase.rb

#calcFileCmd(cmd, onlyCmd, orgOut, tcs, postfix = "") ⇒ Object



203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/blocks/blockBase.rb', line 203

def calcFileCmd(cmd, onlyCmd, orgOut, tcs, postfix = "")
  if tcs[:FILE_COMMAND] == ""
    Bake.formatter.printWarning("Warning: file command option not yet supported for this toolchain")
    return cmd
  end
  args = cmd.drop(onlyCmd.length)
  argsFlat = args.join(' ')

  splittedArgs = argsFlat.split("\"")
  argsFlat = ""
  splittedArgs.each_with_index do |s,i|
    argsFlat << s
    argsFlat << (i%2 == 0 ? "\"\\\"" : "\\\"\"") if i != splittedArgs.length - 1 
  end

  cmdFile = orgOut + ".file" + postfix
  cmdFileLong = File.expand_path(cmdFile, @projectDir)
  Utils.gitIgnore(File.dirname(cmdFileLong))
  File.open(cmdFileLong, "w") { |f| f.puts argsFlat }
  return onlyCmd + ["#{tcs[:FILE_COMMAND]}#{cmdFile}"]
end