Compartir a través de


Custom Build (Windows Embedded CE 6.0)

1/5/2010

This topic describes how to create a custom build of a run-time image by using environment variables.

Custom Build Actions

With the Custom Build Actions page in the <OS Design> Property Pages dialog box, you can assign custom actions and environment variables to projects and files. To access this page, on the Project menu, choose Properties, expand ConfigurationProperties, and select Custom Build Actions.

To accomplish this, you can enter commands that use syntax similar to that of batch (.bat) files, and that use common environment variables for increased readability and portability. For more information, see Environment Variables.

If you build an OS design copied from another development workstation with a different %_WINCEROOT% environment variable than your development workstation, you must rename <OS Design Name>\%_WINCEROOT%.

For example, suppose that on the original development workstation, %_WINCEROOT% is set to WINCE600, and on your development workstation %_WINCEROOT% is set to <Installation Directory>.

If you copy <OS Design Name>\WINCE600 from the original development workstation to <Installation Directory>\Public on your development workstation, you must rename the OS design directory from %_WINCEROOT%\OSDesigns\<OS Design Name>\WINCE600 to %_WINCEROOT%\OSDesigns\<OS Design Name>\<Installation Directory>.

Custom Build that is Targeted to an OS Version

You can create a custom build of a run-time image that conditionally selects code which is targeted to a specific OS version. To do this, you must add conditional statements to the source code files and the run-time image configuration files.

Ee479161.collapse(en-US,WinEmbedded.60).gif_WINCEOSVER

In .reg, .bat, .dat, and .db files, the environment variable _WINCEOSVER can be used to create a custom build that is targeted to a specific OS version. _WINCEOSVER describes the version of the Windows Embedded CE operating system. The value of _WINCEOSVER is defined in wince.bat.

The following example code shows you how to use _WINCEOSVER in a conditional statement on a block of code to target a specific version in a .reg, .bat, .dat, or .db file:

#if (_WINCEOSVER >= 600)

         //OS version specific code goes here

#endif

Ee479161.collapse(en-US,WinEmbedded.60).gifCE_MAJOR_VERSION and CE_MINOR_VERSION

In .c, .cpp, .h, or .h* files, the declared constants CE_MAJOR_VERSION and CE_MINOR_VERSION can be used to create a custom build that is targeted to a specific OS version. The header file bldver.h defines these files, and it is located in %_WINCEROOT%\COMMON\SDK\INC. In a rolled SDK, bldver.h is located in the sdk\inc directory.

The CE_MINOR_VERSION value is expressed in hundredths; for example, the values CE_MAJOR_VERSION=0x0005 and CE_MINOR_VERSION=0x0001 would correspond to version 5.01. If the combined value of these variables is displayed to the user as a string, it should be formatted by using the C code %d.%02d. Be aware that many applications incorrectly format this string. The bldver.h header file and the declared constants can be used in .c, .cpp, .h, or .h* files.

Ee479161.collapse(en-US,WinEmbedded.60).gif_WIN32_WCE

By default, Makefile.def, which is located in %_WINCEROOT%\PUBLIC\COMMON\OAK\MISC, adds the following code:

!ELSEIF "$(_TGTOS)" == "CE"
  -DUNDER_CE=### and -D_WIN#@_WCE=###
!ENDIF

In the previous command, ### is the version number. For example, ### would be in the form of 501 for major version=5 and minor version=1. This file is typically included in the makefile in your directory. If it is included, _WIN32_WCE (or UNDER_CE) can be used to create a custom build for an OS version in .c, .cpp, .h, and .h* files, without requiring that you include bldver.h.

The following example code shows you how to use _WIN32_WCE in a conditional statement:

#ifndef _WIN32_WCE
        // codes goes here for compilation of code that is 
        // not for Windows CE
#else
  #if (_WIN32_WCE < 600)
       // Code for versions earlier than CE 6.0 goes here
  #else
      // Code for versions of CE 6.0 and later versions goes here
  #endif
                
#endif

See Also

Concepts

Run-Time Image Build Process

Other Resources

OS Design Property Pages Dialog Box