您的位置:首页 > 其它

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

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

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

[cpp] view
plaincopy

echo.

echo %_TGTPLAT%-preri processing...

echo.

if "%IMGMULTIXIP%"=="1" cd %_TARGETPLATROOT%/Files/premake

if "%IMGMULTIXIP%"=="1" copy %_FLATRELEASEDIR%/ce.bib %_TARGETPLATROOT%/Files/premake

if "%IMGMULTIXIP%"=="1" copy ce.bib ce_orig.bib

if "%IMGMULTIXIP%"=="1" oembibhelper multibin.txt ce_orig.bib ce.bib

if "%IMGMULTIXIP%"=="1" copy ce.bib %_FLATRELEASEDIR%

if "%IMGMULTIXIP%"=="1" cd %_FLATRELEASEDIR%

if "%IMGMULTIXIP%"=="1" romimage ce.bib

2、oembibhelper.vbs脚本的内容如下:

[vb] view
plaincopy

'

' Copyright (c) Microsoft Corporation. All rights reserved.

'

'

' Use of this sample source code is subject to the terms of the Microsoft

' license agreement under which you licensed this sample source code. If

' you did not accept the terms of the license agreement, you are not

' authorized to use this sample source code. For the terms of the license,

' please see the license agreement between you and Microsoft or, if applicable,

' see the LICENSE.RTF on your install media or the root of your tools installation.

' THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.

'



' Modified this bibhelper.vbs to modify the bib to implement the Multi-Bin

' For example: "nk.exe @XIPKERN" of config file will make nk.exe packed into XIPKERN.bin

'

Public Function SplitEx(InputText,Delimiter)



' This function splits the sentence in InputText into

' words and returns a string array of the words. Each

' element of the array contains one word.



' This constant contains punctuation and characters

' that should be filtered from the input string.

Dim strReplacedText

Dim intIndex



' Replace tab characters with space characters.

' Replace tab characters with space characters.

strReplacedText = Trim(Replace(InputText, vbTab, " "))





' Loop until all consecutive space characters are

' replaced by a single space character.

Do While InStr(strReplacedText, " ")

strReplacedText = Replace(strReplacedText, " ", " ")

Loop



' Split the sentence into an array of words and return

' the array. If a delimiter is specified, use it.

'MsgBox "String:" & strReplacedText

If Len(Delimiter) = 0 Then

SplitEx = Split(strReplacedText)

Else

SplitEx = Split(strReplacedText, Delimiter)

End If

End Function



Private Function LoadConfigFile(Filename)

Const ForReading = 1, ForWriting = 2, ForAppending = 8

Dim LCArray()

LoopVal = 0

Set fs = CreateObject("Scripting.FileSystemObject")

Set a = fs.OpenTextFile(Filename,ForReading,False)

Do While Not a.AtEndOfStream

FileLine = a.ReadLine()

if Left(FileLine,1) = ";" Then

'Wscript.Echo "Skip ; for comments"'

Else

SubStrings = SplitEx(FileLine," ")

If UBound(SubStrings) = 1 Then

ReDim Preserve LCArray(LoopVal)

LCArray(LoopVal) = SubStrings

LoopVal = LoopVal + 1

Else

'Wscript.Echo "Skip blank lines"'

End If

End If

Loop

a.Close

LoadConfigFile = LCArray

End Function



Private Function CalcRegionString(InString, ConfigArrayElement)

CalcRegionString = InString

For LoopVal = 1 To UBound(ConfigArrayElement)

If Left(ConfigArrayElement(LoopVal), 1) = "@" Then

CalcRegionString = Right(ConfigArrayElement(LoopVal), Len(ConfigArrayElement(LoopVal))-1)

End If

Next

End Function



Private Function FindReplaceStrings(SubStrings, ConfigArray, StringToReplace, ReplaceString)

FindReplaceStrings = False

LoopVal = 0

For LoopVal = 0 To UBound(ConfigArray)

If SubStrings(0) = ConfigArray(LoopVal)(0) Then



If UBound(SubStrings) = 2 Then

TypeString = CalcRegionString("", ConfigArray(LoopVal))

StringToReplace = SubStrings(1)

ReplaceString = SubStrings(2) + " " + TypeString

FindReplaceStrings = True

End If



If UBound(SubStrings) = 3 Then

TypeString = CalcRegionString(SubStrings(3), ConfigArray(LoopVal))

StringToReplace = SubStrings(2)

ReplaceString = TypeString

FindReplaceStrings = True

End If



End If

Next

End Function





' Main Function

'

'

' Read Program Arguments

Set Args = Wscript.Arguments



if Args.count <> 3 then

Wscript.Echo "Error: Invalid Number of arguments"

Wscript.Echo ""

Wscript.Echo "Usage: cscript bibhelper.vbs configfile inbibfile outbibfile"

Wscript.Quit

End if
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: