Saturday, January 27, 2007

Overriding .BIB files - removing shortcuts from CE screen More options

A previous thread explained how to modify common .BIB files to remove desktop shortcuts. I'm more interested a modification that doesn't affect every single platform. Is there a way to remove an entry from a platform-level .BIB file in a using a project-level .BIB file or through some other means? Secifically, I need to remove

..\cesysgen\oak\files\directx.bib(159):   ceplayer.lnk $(_FLATRELEASEDIR)\ceplayer.lnk             NK SH
..\cesysgen\oak\files\ie.bib(110):   iesample.lnk $(_FLATRELEASEDIR)\iesample.lnk             NK SH

from there respective files, and also remove the associated .DAT file entries
..\cesysgen\oak\files\directx.dat(16):Directory("\Windows\LOC_DESKTOP_DIR")­:-File("Media Player.lnk", "\Windows\ceplayer.lnk")
..\cesysgen\oak\files\directx.dat(17):Directory("\Windows\LOC_PROGRAMS_DIR"­):-File("Media Player.lnk", "\Windows\ceplayer.lnk")

In the spirit of Dan having had his coffee this morning, here is the PREMAKEIMG.BAT that solved my problem: (See http://msdn2.microsoft.com/en-us/library/ms900321.aspx for more info.)

@ECHO OFF
REM Does not support spaces in any path or file names

SET REMOVEFILES="iesample.lnk" "ceplayer.lnk"

IF EXIST "%1" GOTO CHECK
CD %_FLATRELEASEDIR%
FOR %%I IN (*.BIB *.DAT) DO CALL %0 %%I
GOTO END

:CHECK
FOR %%I IN (%REMOVEFILES%) DO FIND /C "%%~I" %1 && IF NOT ERRORLEVEL 1
GOTO REMOVE
GOTO END

:REMOVE
COPY /Y %1 %1.premakeimg
MOVE /Y %1 %1.premakeimgtmp
FOR %%I IN (%REMOVEFILES%) DO FIND /V "%%~I" < %1.premakeimgtmp > %1 &&
COPY /Y %1 %1.premakeimgtmp
DEL %1.premakeimgtmp

:END

Just before romimage is called in CE5.0, the build system has combined all of the .bib information into a single file ce.bib in the flat release directory. You can pre-process this file prior to running romimage if you add a PreRomImage.bat file into your FILES directory. We use this method to move some DLLs into the files section at the end of the bib file:

@echo off
echo PreRomImage.bat entry.
pushd %_FLATRELEASEDIR%
echo Moving net components to the file regions
findstr /I "mbridge.dll ipnat.dll fw6.dll tcpstk.dll cxport.dll ndis.dll ar5210.dll aumac.dll vmini.dll" ce.bib > ce_net.bib
findstr /I /v "mbridge.dll ipnat.dll fw6.dll tcpstk.dll cxport.dll ndis.dll ar5210.dll aumac.dll vmini.dll" ce.bib > ce_nonet.bib
copy /A ce_nonet.bib+ce_net.bib ce.bib
popd
echo PreRomImage.bat exit.
@echo on

No comments: