* ****************************** Loongembedded ******* *************************
Author: loongembedded (Kandi)
Time: 2011.9.9
Category: wince System Development
* ****************************** Loongembedded ******* *************************
The compilation tool build.exe of winceuses The following information provided by the source code configuration file of Wince to compile the source code of the specified directory and subdirectory ):
1) directory to run through.
2) The C and Microsoft Visual C ++ files to be compiled.
3) create a binary file.
Source code configuration file of Wince refers to the following types of files
1) dirs File
Refers to the dirs file, which is used to identify subdirectories containing source code, that is, the directory where the source code to be compiled is located.
2) Make File
The MAKEFILE file under the folder, which contains the variables required to compile and link the source code.
3) module-definition file
For example, the powerbutton. Def file under the power key driver file contains the declaration of shared symbols, functions, and variables defined in an executable or DLL file.
4) Sources File
Contains the macro variables required for compiling source code.
The compilation tool runs through a directory tree, first looking for the dirs file, and then the sources file. The dirs file specifies the source code to be included or a subdirectory containing the sources file. When the compilation tool locates a sources file in the current directory, it calls nmake tool(nmake.exe) to compile the specified C or C ++ source code file, and link the target module according to the link rules contained in the MAKEFILE file.
Figure 1
The following describes the source code configuration files:
1. dirs File
The dirs file is a text file that specifies the directory containing the source code to be compiled, such as the dirs content under smdk6410 \ SRC:
Dirs = \
Common \
OAL \
Kitl \
Drivers \
Bootloader
This indicates that the dirs files under the smdk6410 \ src directory should compile the source code files under the common, oal, kitl, drivers, and bootloader directories or subdirectories in these directories.
The dirs, dirs_ce, and optional_dirs keywords are used in the dirs file to compile the specified directory.
1) dirs
As shown above, dirs is used to specify the directory to be compiled. dirs = * indicates all directories to be compiled in person. In addition, the preceding example can be used to specify the directory to be compiled in the following way:
Dirs = Common oal kitl dirvers bootloader
That is to say, the Space key is used to separate the directories to be compiled, but this is not intuitive and this method is not recommended.
2) dirs_ce
The source code of the directory is compiled only when the source code in the directory specified by dirs_ce is written into the image of the running Windows XP system. For example, the content of the dirs file under the camera driver is as follows:
Dirs = \
Camera_pdd \
Ov9650_module \
Initi6410_camera \
DLL
3) optional_dirs
Specify the directory that can be compiled, such as optional_dirs = projecta. To compile the projecta directory, set build_options = projecta and run the build command.
2. makefile
Each subdirectory (subdirectory) in the source code tree contains a sources file and a MAKEFILE file, for example:
Figure 2
In an application development environment (for example, vs2005), a MAKEFILE file contains all commands, macro definitions, and optional options for specifying how to compile. However, in contrast, makefile files in Pb (platforom builder) only contain references to a shared makefile, as follows:
Figure 3
The Environment Variable _ makeenvroot mentioned in the figure is defined in wince. BAT in \ public \ common \ oak \ Misc. See:
Figure 4
In Figure 4, the Environment Variable _ winceroot is combined with Figure 1. We can see that _ winceroot = F: \ wince600, so that we can determine the complete path, at the same time, we can infer that the compiled file shared by all parts of Wince is under F: \ wince600 \ public \ common \ oak \ MISC, and the file name is makefile. def.
After the dirsand sourcesfiles are located in build.exe, nmake.exe sets an internal environment variable. Then nmake.exe uses this environment variable to append the sources. CEN file to the sources file in the appropriate subdirectory. Next, nmake.exe uses makefiel. def file to convert the current series of environment variables into calls by the compiler, linker, or other tools, in this way, you can compile the source code specified in the sources file or link the target module (Object modules) to be specified ).
3. XXX. Def File
Xxx. the def file is a module definition file that contains a declaration of common symbols, functions, and variables defined in an executable or DLL file. These declarations are executable files (generally DLL files) the exported interface, such as the powerbutton driver powerbutton. def file with the following content:
Library PWR
Exports
Pwr_init
Pwr_deinit
Pwr_open
Pwr_close
Pwr_read
Pwr_write
Pwr_seek
Pwr_iocontrol
Pwr_powerup
Pwr_powerdown
Although all executable files can use xx. def file, but it is mainly used by the linker to define the DLL export function, XX. the def file contains the following content, which briefly describes common parts:
1) Name
2) Library
This Declaration tells the linker to create a DLL and that the declaration part must be earlier than the other declaration parts. At the same time, the linker creates an import library ), unless the export file (. export). I don't know where to decide whether to generate it. export File, I tried, even if I put my powerbutton. def file content is cleared. During powerbutton driver compilation, the smdk6410_pwrbtn.exp and smdk6410_pwtn.lib files are generated in the platform \ smdk6410 \ Lib \ armv4i \ retail directory, I didn't seem to specify where to generate these two files ????????????????
3) stacksize
4) Sections
5) Export
This statement allows one or more definitions to be effectively exported to other applications. It is mainly used to export function interfaces in DLL files, in this way, the system or application can use these exported interface functions by loading the DLL to its own memory space.
6) version
4. Sources File
The sourcesfile sets the macro definition of the source code in the directory. In this example, build.exe can use these macro definitions to determine how to compile and link the source code. Deny only follows macro assignment and ignores other instructions. Next, let's take a look at the knowledge points in the sources file.
1) synchronize_drain
The instructions in the help document are as follows:
When you perform a build on a development workstation that has multiple processors, this creates the possibility that different build tool (build.exe) threads might be running on different processors.
In this case, you must ensure that your build process is ordered so that build.exe does not attempt to build a product without first building its dependencies.
If this macro definition is set to 1 in a directory's sources file, build.exe builds that directory last.
A directory containing a sources file that uses this macro is not built until all other directories are built. for example, this macro definition allows you to ensure that all preceding Library (. lib) files are built before building the current directory,
Which depends on the previous libraries.
Use this macro, and the related synchronize_block macro, very sparingly. When encountered, these macros completely stall the build process until synchronization is complete.
If a directory uses this macro, list the directory last in its parent dirs File
Pipeline will not try to build a file that none of its dependent files have yet to be built, otherwise it will generate an error that cannot find the library. Note that if synchronize_drain = 1 is set for the sources file in the directory file, we should also put the directory file at the end of the dirs file to indicate the row, this also shows that only the files in dirs are ordered.
2) targetname
The name of the target file generated by compilation, excluding the extension, for example:
Targetname = maid
Indicates that the target file name generated by the touch screen driver is.
3) targettype
Type of the generated target file, which can be the following three types:
Library: the target file is a static link library file (. Lib ).
Dynlink: the target file is a dynamic link library file (. dll ).
Program: the target file is an executable file (.exe ).
4) releasetype
This macro definition is set to another identifier (FLAG): releasedir and releaselibdir, used to specify the binary files generated during compilation and the directory where the library files are stored. It is a value description of releasetype.
Figure 5
5) dllentry
If targetype = dynlink, the macro dllentry is defined as an entry function used to specify this DLL file. If the value of dllentry is not assigned, the DLL entry function is _ dllmaincrtstartup by default, the following describes the possible values of dllentry:
(1) _ dllmaincrtstartup
This function is the first entry point of a DLL in the C runtime, which is defined in the C runtime. When the DLL file is mapped to the address space of the process, the operating system calls this function to initialize the C runtime and call the global variable initialization. Next, the dllmain function is called; when the DLL is uninstalled, the operating system calls the _ dllmaincrtstartup function to deinitialize the memory usage during the C runtime and release the initialization.
Because _ dllmaincrtstartup will call the dllmain function, we need to define the dllmain function for the DLL, but do not need to export the dllmain function. The function prototype is as follows:
Bool dllmain (handle hinstdll, DWORD dwreason, lpvoid lpvreserved );
(2) dllmain
DLL direct entry function. If your application uses C Runtime when our DLL is being attach by the process, this function is responsible for executing any initialization during C runtime, when the DLL is detach by the process, it is responsible for deinitialize C runtime and memory usage during initialization.
If dllentry = dllmain, we must define this function in the DLL, just like the prototype above. Of course, you do not need to export this function, the operating system can call this function by itself.
(3) _ dllentrycrtstartup
DLL basic (basic) C Runtime entry function, which is also defined in C runtime. Its function is similar to the _ dllmaincrtstartup function, but it will call the dllentry function, instead of the dllmain function, if dllentry = _ dllentrycrtstartup, you must define but do not necessarily need to export the dllentry function. The prototype of this function is as follows:
Bool dllentry (handle hinstdll, DWORD dwreason, lpvoid lpvreserved );
The C Runtime Library (CRT) in the wince system provides many useful functions to make programming easier. The CRT exists in coredll (reside in. DLL and corelibc. in Lib, we can link coredll. lib to link to coredll. part of the CRT in the DLL. Corelibc. LIB contains the CRT startup function. Apart from the initial stage, we must link other CRT functions included in it to first ensure the most appropriate performance.
6) deffile
Specify the. Def file of this module. We know that the module exports the interface of this module through the. Def file.
7) precompiled_include
Specifies the name of the pre-compiled header file. If this item is set, the header file specified by enable will be used for compilation during compilation.
8) targetlibs
It refers to other (additional) library files and object files (. OBJ) in the target Executable File (.exe or. dll ). This macro is typically only used when our module needs to link the output library, such as coredll. lib, ceddk. lib, etc. These library files are the output library. They export some shared functions to applications or modules so that these shared functions can be used.
9) sourcelibs
Specifies the library files to be linked to in our modules. Typically, they are only used to link static libraries. static libraries are files that contain objects, functions, and data. According to my observations, the libraries to be linked in sourcelibs are generally used for a driver rather than the libraries that can be shared by the entire system, while the libraries specified by targetlibs to be linked are some shared libraries.
10) Sources
Specifies the source code file to be compiled.
11) skipbuild
If skipbuild = 1, skip this directory instead of compiling.
12) preprocessdeffile
If it is set to 1, the. Def file containing path indication must be pre-processed, PDD in the touch screen driver
This item is set in the sources file of the layer.
13) des
This macro is used only when the header file to be included is private because the standard shared header file is automatically included.
14) winceoem
Set this value to use some common import library and header files in the system. This macro is usually set in the system level, for example, some drivers in the BSP package.
15) wincemap
It is used to generate the corresponding. map file during the compilation process. By default, this macro is set to 1. This. Map File is very helpful for debugging.
There are some other macro variables in the sources file. For details, refer to the help documentation in msdn.