<commit_before>#

def freplace( fname, pattern, str )
  f = File.open( fname )
  strings = f.read
  f.close

  strings.gsub!( pattern, str )

  f = File.new( fname, "w" )
  f.print strings
  f.close
end

def startmds
  mdshome =  $config["env"]["paths"][$config["env"]["bbver"]]["mds"]
  args = []
  args << "/c"
  args << "run.bat"

  Jake.run("cmd.exe",args, mdshome,true)
end 

def stopmds
  mdshome =  $config["env"]["paths"][$config["env"]["bbver"]]["mds"]
  args = []
  args << "/c"
  args << "shutdown.bat"

  Jake.run("cmd.exe",args, mdshome, true, true)
end 

def startsim
  bbver = $config["env"]["bbver"]
  sim = $config["env"]["paths"][bbver]["sim"]
  jde = $config["env"]["paths"][bbver]["jde"]
    
  command =  '"' + jde + "/simulator/fledge.exe\""
  args = []
  args << "/app=Jvm.dll"
  args << "/handheld=" + sim
  args << "/session=" + sim
  args << "/app-param=DisableRegistration"
  args << "/app-param=JvmAlxConfigFile:"+sim+".xml"
  args << "/data-port=0x4d44"
  args << "/data-port=0x4d4e"
  args << "/pin=0x2100000A"
  args << "/no-compact-filesystem"
    
  if bbver !~ /^4\.[012](\..*)?$/
    args << "/fs-sdcard=true"
  end
        
  args << "\"/app-param=JvmDebugFile:"+Jake.get_absolute($config["env"]["applog"]) +'"'

  Thread.new { Jake.run(command,args,jde + "/simulator",true) }
  $stdout.flush
end

def stopsim
  sim = $config["env"]["paths"][$config["env"]["bbver"]]["sim"]
  jde = $config["env"]["paths"][$config["env"]["bbver"]]["jde"]
    
  command =  '"' + jde + "/simulator/fledgecontroller.exe\""
  args = []
  args << "/session="+sim
  args << "/execute=Exit(true)"
  Jake.run(command,args, jde + "/simulator")
end

def manualsign
  java = $config["env"]["paths"]["java"] + "/java.exe"
  jde = $config["env"]["paths"][$config["env"]["bbver"]]["jde"]

  args = []
  args << "-jar"
  args << '"' + jde + "/bin/SignatureTool.jar\""
  args << "-r"
  args << $targetdir

  puts Jake.run(java,args)
  $stdout.flush

end

def autosign
  java = $config["env"]["paths"]["java"] + "/java.exe"
  jde = $config["env"]["paths"][$config["env"]["bbver"]]["jde"]

  args = []<commit_msg>Improve rake run:bb speed<commit_after>#

def freplace( fname, pattern, str )
  f = File.open( fname )
  strings = f.read
  f.close

  strings.gsub!( pattern, str )

  f = File.new( fname, "w" )
  f.print strings
  f.close
end

def startmds
  mdshome =  $config["env"]["paths"][$config["env"]["bbver"]]["mds"]
  args = []
  args << "/c"
  args << "run.bat"

  Jake.run("cmd.exe",args, mdshome,true)
end 

def stopmds
  mdshome =  $config["env"]["paths"][$config["env"]["bbver"]]["mds"]
  args = []
  args << "/c"
  args << "shutdown.bat"

  Jake.run("cmd.exe",args, mdshome, true, true)
end 

def startsim
  bbver = $config["env"]["bbver"]
  sim = $config["env"]["paths"][bbver]["sim"]
  jde = $config["env"]["paths"][bbver]["jde"]
    
  command =  '"' + jde + "/simulator/fledge.exe\""
  args = []
  args << "/app=Jvm.dll"
  args << "/handheld=" + sim
  args << "/session=" + sim
  args << "/app-param=DisableRegistration"
  args << "/app-param=JvmAlxConfigFile:"+sim+".xml"
  args << "/data-port=0x4d44"
  args << "/data-port=0x4d4e"
  args << "/pin=0x2100000A"
  args << "/no-compact-filesystem"
    
  if bbver !~ /^4\.[012](\..*)?$/
    args << "/fs-sdcard=true"
  end
        
  args << "\"/app-param=JvmDebugFile:"+Jake.get_absolute($config["env"]["applog"]) +'"'

  Thread.new { Jake.run(command,args,jde + "/simulator",true) }
  $stdout.flush
end

def stopsim
  sim = $config["env"]["paths"][$config["env"]["bbver"]]["sim"]
  jde = $config["env"]["paths"][$config["env"]["bbver"]]["jde"]
    
  command =  '"' + jde + "/simulator/fledgecontroller.exe\""
  args = []
  args << "/session="+sim
  args << "/execute=Exit(true)"
  #Jake.run(command,args, jde + "/simulator")
  Thread.new { Jake.run(command,args, nil, true,true) }  
end

def manualsign
  java = $config["env"]["paths"]["java"] + "/java.exe"
  jde = $config["env"]["paths"][$config["env"]["bbver"]]["jde"]

  args = []
  args << "-jar"
  args << '"' + jde + "/bin/SignatureTool.jar\""
  args << "-r"
  args << $targetdir

  puts Jake.run(java,args)
  $stdout.flush

end

def autosign
  java = $config["env"]["paths"]["java"] + "/java.exe"
  jde = $config["env"]["paths"][$config["env"]["bbver"]]["jde"]

  args = []
{'fraction_non_alphanumeric': 0.2506393861892583, 'fraction_numerical': 0.008835154615205766, 'mean_word_length': 3.748344370860927, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5292695', 'n_tokens_mistral': 1759, 'n_tokens_neox': 1794, 'n_words': 289}