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

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

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

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

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

相关文章

Format[$] ( expr [ , fmt ] ) format 返回变体型 format$ 强...
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办...
在项目中添加如下代码:新建窗口来显示异常信息。 Namespace...
转了这一篇文章,原来一直想用C#做k3的插件开发,vb没有C#用...
Sub 分列() ‘以空格为分隔符,连续空格只算1个。对所选...
  窗体代码 1 Private Sub Text1_OLEDragDrop(Data As Dat...