Sources File

Sources File

Windows CE .NET

A sources file is a text file that sets the macro definitions for the source code in a subdirectory. Build.exe uses these macro definitions to determine how to compile and link the source code.

Note   The directory and file names used in the code examples in this section are samples that demonstrate the way to set up a sources file. You would choose different names for any sources files and directories that you create.

The following code example shows the placement of the common sources file, Sources.cmn, and other sources files in a sample directory.

\Public
  \MyProj
    Sources.cmn
    Dirs
    \Proj2
      Dirs
      Makefile
      Sources
      Proj2.cpp
      Proj2.h
    . . .

The following table shows the macro variables for the sources file in the MyProj\Proj2 directory.

Macro Description
TARGETNAME=Proj2 Defines the base name of the file to be built. Build.exe creates a file named Proj2.extension, where extension can be .lib, .dll, or .exe.
TARGETTYPE=PROGRAM Defines the type of file, and hence the extension in that file's name. PROGRAM generates an .exe file.
TARGETLIBS=$(_COMMONSDKROOT)\lib\$(_CPUINDPATH)\Coredll.lib Defines the libraries to be linked.
SOURCES=Proj2.cpp \ Defines the source code files to compile. Header files do not need to be on the SOURCES line if they are included inside other files.
EXEENTRY=WinMain Defines the entry point for the .exe file. WinMain sets the entry point for a Windows application.

Your source code tree can optionally include Sources.cmn. Any macro variables in a common sources file apply to all sources files in that directory and its associated subdirectories.

The Platform Builder sample code includes a common sources file in each of the following directories:

  • %_WINCEROOT%\Public\Common
  • %_WINCEROOT%\Platform\Cepc

The following code example shows the contents of Public\Common\Sources.cmn. These macro definitions apply to every sources file in the Public\Common directory.

Sample SOURCES.CMN from \Common
WINCEOEM=1
WINCEPROJ=COMMON
WINCETREE=winceos
WARNISERROR=1

After Build.exe parses the sources file, Nmake.exe incorporates the sources file into the common makefile file, Makefile.def. Build.exe follows only the macro assignments and ignores any other lines, such as conditional Nmake.exe statements. Conditional statements in sources files are not supported.

The following code example shows that Build.exe ignores the first, second, fourth, and sixth lines, and appends the SOURCES macro twice.

# Bad example
!IF  "$(LOCALE)" ==  "0409"
  SOURCES= $(SOURCES) us-src.c
!ELSE
  SOURCES= $(SOURCES) inter-src.c
!ENDIF

See Also

Platform Configuration Files | Build Tool | Windows CE Build Environment Tool | Nmake Tool


 Last updated on Friday, October 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.

Show:
© 2016 Microsoft