Partager via


Targeted Build Example: Public Tree (Compact 7)

3/12/2014

In Clone the Public Tree Code to Modify It we recommend that you clone code in the public tree instead of modifying it in the public tree itself. This topic considers how you create targeted builds for public tree code whether or not you have cloned it.

Important

We do not recommend the modification of public code, nor do we provide support for this practice. Public code modification examples are intended for an expert audience only.

Code in the public tree builds during the Build OS or Sysgen OS step. Therefore, we recommend that you do not try to create a targeted build unless you thoroughly understand these steps.

When doing a targeted build of public code, you must modify the targeted build preparation algorithm presented in Create Targeted Builds. First, search other sources files in the public and private trees. Then search the Cesysgen\makefiles in those trees. Finally, search sources files in Platform\ and subprojects.

You can walk through the targeted build preparation algorithm by following the next detailed example. For this example, consider that the changed file is Public\common\oak\drivers\pm\mdd\pmsysstate.cpp, and that the $(_TGTPLAT) is the TI_EVM_3530 platform.

Looking at Public\common\oak\drivers\pm\mdd\sources, you see that it produces Pm_mdd_lib.lib. This becomes the root node of the tree. If you scan other sources files in the public and private trees, you see that there are no additional dependencies on this .lib.

The next step is to examine Public\common\cesysgen\makefile. There you will find the following rules (we omit some lines for simplicity).

pm:: pm_mdd_lib pm_default_pdd_lib pmstubs_lib pm_pdd_common_lib
pm_mdd pm_default_pdd pmstubs pm_pdd_common:
    @set SOURCELIBS=%%SOURCELIBS%% $(SG_INPUT_LIB)\$@_lib.lib
pm:: $(PM_COMPONENTS)
    @set TARGETTYPE=DYNLINK
    @set TARGETNAME=$@
    $(MAKECMD) /NOLOGO $(SG_OUTPUT_OAKTGT)\$@.dll

Looking at Public\CEBase\oak\misc\winceos.bat, you see that pm_mdd is a member of PM_COMPONENTS. So Pm.dll depends on the pm_mdd rule, which adds Pm_mdd_lib.lib to its SOURCELIBS. Therefore, Pm.dll depends on pm_mdd_lib. The tree now has two nodes: pm_mdd_lib (the parent) and Pm.dll (the child).

After Sysgen OS, the next build steps are Platform\common and Platform\TI_EVM_3530. If you scan the sources files there, you see one reference to pm_mdd_lib: Platform\TI_EVM_3530\src\drivers\pm\pdd\sources. This sources file actually creates Pm.dll as well, which will override the Pm.dll that was produced during the Sysgen OS step. Therefore, at the end of this exercise, the targeted build tree resembles the following.

The targeted build tree for the modified .cpp

Now that the tree is complete, performing the build is simple. First, run Build.exe in Public\common\oak\drivers\pm\mdd.

Next, run the makefile rule in Public\common\cesysgen\makefile. To do this, use the Sysgen.bat utility located in Public\common\oak\misc. The basic syntax is sysgen.bat -p <_DEPTREE> <makefile rule>. _DEPTREE is the value from $(_DEPTREES) that corresponds to the directory of the makefile under Public\. Therefore, in this case, the _DEPTREE is common and the whole command is sysgen -p common pm. This runs the pm makefile rule in the common _DEPTREE.

It is important to remember that you must run the Cesysgen\makefile rule even though the Pm.dll from the Sysgen OS build step is not used by the TI platform. This is because the TI platform does use pm_mdd_lib. When you ran Build.exe in Public\common\oak\drivers\pm\mdd, Pm_mdd_lib.lib was output to Public\common\oak\lib\$(_TGTCPU)\$(WINCEDEBUG). However, platforms must only link with files in the $(SG_OUTPUT_ROOT). So you must make sure that pm_mdd_lib is copied to the $(SG_OUTPUT_ROOT). Because the pm makefile rule depends on pm_mdd_lib, sysgen -p common pm will still accomplish the copy.

The next step is to run Build.exe in the Platform\TI_EVM_3530\src\drivers\pm\pdd directory. Then you can run Makeimg, and the results of the original change to Pmsysstate.cpp will be represented in the OS run-time image.

Here is a review of the build steps taken:

  1. Run Build.exe in Public\common\oak\drivers\pm\mdd.
  2. Run sysgen -p common pm.
  3. Run Build.exe in Platform\TI_EVM_3530\src\drivers\pm\pdd.
  4. Run Makeimg.exe.

See Also

Concepts

Create Targeted Builds