Cloning CalibrUi in Windows CE 6.0
If you have a need to clone the calibration application in Windows CE 6.0 you'll run into several problems when following the instructions in MSDN. The instructions on that page seem to be working fine for Windows CE 5.0 but are causing major headaches on Windows CE 6.0...
Time for an update on the documentation to match the correct procedure for Windows CE 6.0:
Cloning the CalibrUi Module
To clone the CalibrUi module
- Select the Catalog Items View tab in the workspace window.
- Expand the [OS Design Name]\Core OS node, and navigate to CEBASE\Shell and User Interface\Graphics, Windowing and Events.
- Right-click Minimal GDI Configuration. In the pop-up menu that appears, select Clone Catalog Item.
- The Clone Catalog Item - gwe2 window appears, with a list of component libraries that can be cloned. If the Calibrui module is not already selected, select it and choose OK. In the Cloning Complete window, choose OK.
- To make sure that the CalibrUi module has been cloned, select the Solution Explorer tab in the workspace. Expand the Subprojects node. If the cloning operation was successful, you will see CalibrUi (gwe2 clone) in the list of subprojects.
- Note: You must never change the project name CalibrUi (gwe2 clone). Making changes to the project name will affect the build system and cause your run-time image to be built incorrectly or to fail.
- Expand the CalibrUi (gwe2 clone) node. All of the source files that relate to the Calibrui module are now available for editing. Any changes to the source files will take effect in any run-time image or executable that you create from this point forward.
You can now try to build the CalibrUi subproject by right clicking it and choosing "Build" from the context menu. If you have sysgenned your OS Design before it should build without any problems.
The problems start when you now (re)sysgen your entire OS Design (needed to include the cloned CalibrUi into your kernel).
When the build system executes
sysgen -p dcom preproc a build tool called "SysgenMake.exe" will throw an unhandled exception:
Unhandled Exception: System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path)
at System.IO.Path.GetFileName(String path)
at System.IO.Path.GetFileNameWithoutExtension(String path)
at Microsoft.PlatformBuilder.MainClass.ComputeClonedLibs(String targetLibs, StringDictionary& moduleVars, StringDictionary& environmentVariables, Boolean res2res)
at Microsoft.PlatformBuilder.MainClass.Main(String args)
NMAKE : fatal error U1077: 'SysgenMake' : return code '0xe0434f4d'
This error is caused by TAB characters in the makefile in
\WINCE600\PUBLIC\DCOM\CESYSGEN. Remember that you should NEVER EVER change anything in the PUBLIC or PRIVATE folders? Well, this is an exception. There's simply no way around this bug without changing the TAB characters to spaces, so:
\WINCE600\PUBLIC\DCOM\CESYSGEN\makefile.in Visual Studio 2008
- Press CTRL-R, CTRL-W (this will turn on "View White Space")
- Replace all TAB characters in the file (recognizable by the right arrow character) with spaces
- Save the file
If you would now sysgen your OS Design again you will see that it successfully executes the
sysgen -p dcom preproc command but unfortunately it will fail a bit later in the build process with the following error:
Building combined gwes res file for 0419
SysgenMake -RES2RES %GWES_RESOURCES% -fo C:\WINCE600\OSDesigns\MyOSDesign\MyOSDesign\Wince600\MyBSP_ARMV4I\cesysgen\oak\target\ARMV4I\retail\0419\gwes.res
Res2Res for Windows CE (Release) (Built on Jun 30 2006 16:52:50)
Copyright (C) Microsoft Corp. 1991-2004. All rights reserved.
Res2Res: Ignoring "dummy"
Res2Res: Using C:\WINCE600\public\common\oak\Bin\i386\R2RDUMMY.DLL for temp exe
Res2Res: Using resources from C:\WINCE600\OSDesigns\MyOSDesign\MyOSDesign\calibrui\obj\ARMV4I\retail\0419\calibrui_clone.res.
Res2Res: Adding resources from C:\WINCE600\OSDesigns\MyOSDesign\MyOSDesign\calibrui\obj\ARMV4I\retail\0419\calibrui_clone.res to C:\DOCUME~1\Michel\LOCALS~1\Temp\R2R1A00.tmp.
ERROR: Res2Res: Could not open C:\WINCE600\OSDesigns\MyOSDesign\MyOSDesign\calibrui\obj\ARMV4I\retail\0419\calibrui_clone.res.
Res2Res: Error adding resources (-1)
NMAKE : fatal error U1077: 'SysgenMake' : return code '0x2'
It is complaining it can't find the file
C:\WINCE600\OSDesigns\MyOSDesign\MyOSDesign\calibrui\obj\ARMV4I\retail\0419\calibrui_clone.res. Let's check if that file exists or not...
This is the tree of the CalibrUi subproject after building it:
As you can see all locale subfolders are created *except* 0419 (Russian)... Even though you may not even need Russian this is still causing a problem!
Inside the obj dir of CalibrUi a file named
clone_locales.txt is generated. It looks like this file may have something to do with our problem... But who/where/when is this file created?
The magic is in prelink.bat (thank you for the tip MVP Pavel Belevsky!):
@REM This is called before build to create all the RES files needed for all locales
@REM WARNING: Do not change the names of any files because SYSGENMAKE.EXE assumes their location for cloning
(IF NOT EXIST obj mkdir obj || goto EXIT_ERROR
(IF NOT EXIST obj\%_TGTCPU% mkdir obj\%_TGTCPU%) || goto EXIT_ERROR
(IF NOT EXIST obj\%_TGTCPU%\%WINCEDEBUG% mkdir obj\%_TGTCPU%\%WINCEDEBUG%) || goto EXIT_ERROR
dir /AD /B %_PROJECTOAKROOT%\files\INTLTRNS > obj\%_TGTCPU%\%WINCEDEBUG%\clone_locales.txt
for /f %%L in (obj\%_TGTCPU%\%WINCEDEBUG%\clone_locales.txt) do call :COMPILE_RC %%L
(set LOCALE=%1 && nmake CalibrUi_clone.res) || goto EXIT_ERROR
(IF NOT EXIST obj\%_TGTCPU%\%WINCEDEBUG%\%1 mkdir obj\%_TGTCPU%\%WINCEDEBUG%\%1) || goto EXIT_ERROR
move /Y CalibrUi_clone.res obj\%_TGTCPU%\%WINCEDEBUG%\%1\CalibrUi_clone.res || goto EXIT_ERROR
exit /b -1
@REM Place any additional steps after END_CLONING but before EOF
As you can see in the above batch file the folder list in
clone_locales.txt is created by the line:
%_PROJECTOAKROOT%\files\INTLTRNS (in our case
C:\WINCE600\OSDesigns\MyOSDesign\MyOSDesign\Wince600\MyBSP_ARMV4I\OAK\files\INTLTRNS) apparently does not contain the full list of locales we need for a successful sysgen of the OS Design. We already saw that our
%_FLATRELEASEDIR% does seem to contain more locale IDs but at the time of a clean sysgen those folders do not exist in the
%_FLATRELEASEDIR% yet, so we need to get them from another location. A bit of searching leads us to
\WINCE600\PUBLIC\COMMON\OAK\LIB so lets change the line creating
clone_locales.txt to take that location as a source:
Now if you build the CalibrUi subproject you will end up with this tree:
With all the above changes implemented you can finally successfully sysgen your platform with your cloned and modified CalibrUi component!