wince自动生成XIP映像文件的一种方法

前端之家收集整理的这篇文章主要介绍了wince自动生成XIP映像文件的一种方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在WINCE做MULTIBIN+XIP方式的启动映像文件时,往往需要分两步走:第一步、生成映像文件;第二步、修改ce.bib然后再romimage一次,以前的做法是手动修改极不方便,后来在网上找到了一些办法并整合到一起就能够做到一步到位。

1、做一个批处理放在BSP的Files/premake目录下供PB调用文件内容如下:

  1. echo.
  2. echo%_TGTPLAT%-preriprocessing...
  3. echo.
  4. @H_502_34@ if"%IMGMULTIXIP%"=="1"cd%_TARGETPLATROOT%/Files/premake
  5. if"%IMGMULTIXIP%"=="1"copy%_FLATRELEASEDIR%/ce.bib%_TARGETPLATROOT%/Files/premake
  6. @H_502_34@ if"%IMGMULTIXIP%"=="1"copyce.bibce_orig.bib
  7. if"%IMGMULTIXIP%"=="1"oembibhelpermultibin.txtce_orig.bibce.bib
  8. @H_502_34@ if"%IMGMULTIXIP%"=="1"copyce.bib%_FLATRELEASEDIR%
  9. if"%IMGMULTIXIP%"=="1"cd%_FLATRELEASEDIR%
  10. @H_502_34@ if"%IMGMULTIXIP%"=="1"romimagece.bib

2、oembibhelper.vbs脚本的内容如下:
[vb] copy
    ' @H_502_34@ 'Copyright(c)MicrosoftCorporation.Allrightsreserved.
  1. '
  2. 'USEOfthissamplesourcecodeissubjecttothetermsoftheMicrosoft
  3. @H_502_34@ 'licenseagreementunderwhichyoulicensedthissamplesourcecode.If
  4. 'youdidnotacceptthetermsofthelicenseagreement,youarenot
  5. @H_502_34@ 'authorizedtousethissamplesourcecode.Forthetermsofthelicense,
  6. 'pleaseseethelicenseagreementbetweenyouandMicrosoftor,ifapplicable,
  7. @H_502_34@ 'seetheLICENSE.RTFonyourinstallmediaortherootofyourtoolsinstallation.
  8. 'THESAMPLESOURCECODEISPROVIDED"ASIS",WITHNOWARRANTIES.
  9. @H_502_34@ 'Modifiedthisbibhelper.vbstomodifythebibtoimplementtheMulti-Bin
  10. 'Forexample:"nk.exe@XIPKERN"ofconfigfilewillmakenk.exepackedintoXIPKERN.bin
  11. PublicFunctionSplitEx(InputText,Delimiter)
  12. @H_502_34@
  13. 'ThisfunctionsplitsthesentenceinInputTextinto
  14. @H_502_34@ 'wordsandreturnsastringarrayofthewords.Each
  15. 'elementofthearraycontainsoneword.
  16. 'Thisconstantcontainspunctuationandcharacters
  17. @H_502_34@ 'thatshouldbefilteredfromtheinputstring.
  18. DimstrReplacedText
  19. @H_502_34@ DimintIndex
  20. 'Replacetabcharacterswithspacecharacters.
  21. 'Replacetabcharacterswithspacecharacters.
  22. @H_502_34@ strReplacedText=Trim(Replace(InputText,vbTab,""))
  23. 'Loopuntilallconsecutivespacecharactersare
  24. @H_502_34@ 'replacedbyasinglespacecharacter.
  25. DoWhileInStr(strReplacedText,"")
  26. @H_502_34@ strReplacedText=Replace(strReplacedText,"","")
  27. Loop
  28. 'Splitthesentenceintoanarrayofwordsandreturn
  29. @H_502_34@ 'thearray.Ifadelimiterisspecified,useit.
  30. 'MsgBox"String:"&strReplacedText
  31. @H_502_34@ IfLen(Delimiter)=0Then
  32. SplitEx=Split(strReplacedText)
  33. @H_502_34@ Else
  34. SplitEx=Split(strReplacedText,Delimiter)
  35. @H_502_34@ EndIf
  36. EndFunction
  37. PrivateFunctionLoadConfigFile(Filename)
  38. @H_502_34@ ConstForReading=1,ForWriting=2,ForAppending=8
  39. DimLCArray()
  40. @H_502_34@ LoopVal=0
  41. Setfs=CreateObject("Scripting.FileSystemObject")
  42. @H_502_34@ Seta=fs.OpenTextFile(Filename,ForReading,False)
  43. DoWhileNota.AtEndOfStream
  44. @H_502_34@ FileLine=a.ReadLine()
  45. ifLeft(FileLine,1)=";"Then
  46. @H_502_34@ 'Wscript.Echo"Skip;forcomments"'
  47. Else
  48. @H_502_34@ SubStrings=SplitEx(FileLine,"")
  49. IfUBound(SubStrings)=1Then
  50. @H_502_34@ ReDimPreserveLCArray(LoopVal)
  51. LCArray(LoopVal)=SubStrings
  52. @H_502_34@ LoopVal=LoopVal+1
  53. 'Wscript.Echo"Skipblanklines"'
  54. EndIf
  55. @H_502_34@ a.Close
  56. LoadConfigFile=LCArray
  57. @H_502_34@ EndFunction
  58. PrivateFunctionCalcRegionString(InString,ConfigArrayElement)
  59. CalcRegionString=InString
  60. @H_502_34@ ForLoopVal=1ToUBound(ConfigArrayElement)
  61. IfLeft(ConfigArrayElement(LoopVal),1)="@"Then
  62. @H_502_34@ CalcRegionString=Right(ConfigArrayElement(LoopVal),Len(ConfigArrayElement(LoopVal))-1)
  63. Next
  64. PrivateFunctionFindReplaceStrings(SubStrings,ConfigArray,StringToReplace,ReplaceString)
  65. @H_502_34@ FindReplaceStrings=False
  66. LoopVal=0
  67. @H_502_34@ ForLoopVal=0ToUBound(ConfigArray)
  68. IfSubStrings(0)=ConfigArray(LoopVal)(0)Then
  69. IfUBound(SubStrings)=2Then
  70. @H_502_34@ TypeString=CalcRegionString("",ConfigArray(LoopVal))
  71. StringToReplace=SubStrings(1)
  72. @H_502_34@ ReplaceString=SubStrings(2)+""+TypeString
  73. FindReplaceStrings=True
  74. @H_502_34@ IfUBound(SubStrings)=3Then
  75. TypeString=CalcRegionString(SubStrings(3),ConfigArray(LoopVal))
  76. @H_502_34@ StringToReplace=SubStrings(2)
  77. ReplaceString=TypeString
  78. @H_502_34@ FindReplaceStrings=True
  79. 'MainFunction
  80. 'ReadProgramArguments
  81. @H_502_34@ SetArgs=Wscript.Arguments
  82. ifArgs.count<>3then
  83. Wscript.Echo"Error:InvalidNumberofarguments"
  84. @H_502_34@ Wscript.Echo""
  85. Wscript.Echo"Usage:cscriptbibhelper.vbsconfigfileinbibfileoutbibfile"
  86. @H_502_34@ Wscript.Quit
  87. Endif

猜你在找的VB相关文章