Partager via


Clone the Public Tree Code to Modify It (Compact 7)

3/12/2014

Modifying code in the public tree is problematic because rolling back changes to public binaries requires the reinstallation of Platform Builder.

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.

To avoid modification of the public shared code, you can create a clone of the directory you want to modify in the platform tree.

Advantages of Cloning

Building the code in the platform tree offers you several advantages. First, it preserves the public tree. This avoids a reinstallation of Platform Builder to restore the original version. Second, it makes targeted builds simpler because the code is built later in the build process and avoids the Sysgen OS phase. Finally, if the cloned code breaks, you may be able to complete the build using the original version as a temporary solution.

How to Clone

Start cloning by copying the code that you want to modify into a new directory in Platform\$(_TGTPLAT), together with its sources file. Next, determine the dependencies using the targeted build preparation algorithm presented in Create Targeted Builds. Each dependency before the Platform\$(_TGTPLAT) step must be copied also.

After copying the files, begin modifying the sources files. Typically, references in the sources files to $(_COMMONOAKROOT), $(_COMMONSDKROOT), and $(_COMMONDDKROOT) must be changed to $(_SYSGENOAKROOT), $(_SYSGENSDKROOT), and $(_SYSGENDDKROOT), respectively. This will include and link files against the Sysgen output directory $(SG_OUTPUT_ROOT) instead of the Build OS phase directories. The RELEASETYPE must be changed from OAK to PLATFORM to reflect the new build location. You will also have to examine the Cesysgen\makefile in the corresponding public code to make sure that any special rules are represented.

A Cloning Example

This example demonstrates cloning the code in Public\common\oak\drivers\nleddrvr\mdd into the TI_3530_EVM platform.

Research the Code

It is important that you do some research to determine how this code is built and which sources files and Cesysgen\makefiles use the output. By reviewing the sources files in the directory that you want to clone, you see that Nleddrvr_mdd.lib is linked. You must update anything that uses this library to use instead the cloned version. Using the command findstr /sip nleddrvr sources makefile in Public\ and Platform\TI_3530_EVM\, you can determine what must be examined:

  • Public\common\oak\drivers\nleddrvr\lib\sources
  • Public\common\oak\drivers\nleddrvr\dll\sources
  • Public\common\cesysgen\makefile

In the first occurrence, Nleddrvr_mdd.lib is linked into Nleddrvr_lib.lib. Because Nleddrvr_lib.lib is a library, it can potentially be linked into other downstream binaries. Therefore, you must use Findstr to perform the same enumeration on Nleddrvr_lib.lib:

  • Public\common\cesysgen\makefile
  • Public\common\oak\drivers\nleddrvr\dll\sources
  • Platform\TI_3530_EVM\src\drivers\nled\sources

Next examine the full listing of files that use Nleddrvr_mdd.lib and Nleddrvr_lib.lib. Looking at Public\common\oak\drivers\nleddrvr\dll\sources, you can see that this creates Nleddrvr.dll, linking both libraries together with a stub pdd library. Because Platform\TI_3530_EVM\src\drivers\nled\sources also links Nleddrvr.dll in a later build step, it replaces the one created from the public tree. Therefore, Public\common\oak\drivers\nleddrvr\dll is now accounted for, and you can focus on the other libraries in the build.

In Public\common\cesysgen\makefile, there are several references to nleddrvr_mdd and nleddrvr_lib. First is an inclusion of makefile rules for both libraries as a dependency of the driverlibs rule. Driverlibs, as seen in the makefile, is a rule that is always run during the preprocessing phase of Sysgen. You can also see that each library has a rule to copy itself to $(SG_OUTPUT_OAKLIB). You must make sure that any sources files that consume Nleddrvr_lib from $(SG_OUTPUT_OAKLIB) instead consume the cloned library. Fortunately, there is only one real consumer:

  • Platform\TI_3530_EVM\src\drivers\nled\sources

Clone the Code

Now that you have done the research, you can perform the actual implementation. Start by copying the code found in Public\common\oak\drivers\nleddrvr\mdd to a new directory in the platform. Create the Platform\TI_EVM_3530\src\drivers\nledlib directory and copy all of the files in Public\common\oak\drivers\nleddrvr\mdd into it. Then modify Platform\TI_EVM_3530\src\drivers\dirs, adding an entry for nledlib just before the nled entry. By adding it here, you pick up the appropriate conditioning on CE_MODULES_NLEDDRVR (for more information, see Filter BSP dirs, .bib, and .reg Files). This conditioning ensures that NLED dependencies such as ceddk are included, but it also includes Nleddrvr_stubpdd.lib, which you may require later.

Next, modify Platform\TI_EVM3530\src\drivers\nledlib\sources to match the fact that it is building in the Platform directory. You pick up RELEASETYPE=PLATFORM from Platform\TI_EVM3530\sources.cmn. Therefore, you do not have to add it here. What you will have to change is the DEFFILE and WINCETARGETFILE0 macros, which currently refer to a .def file in the Public\ tree. If the .def file has CESYSGEN filtering in it, it is best to repoint it to the .def file in the $(SG_OUTPUT_ROOT), so that you can pick up that filtering. Looking at Platform\TI_3530_EVM\src\drivers\nled\sources, it does not have filtering and has already been cloned. So you can remove the TARGETDEFNAME, DEFFILE, and WINCETARGETFILE0 macros, leaving a simple sources file.

The last step is to point Platform\TI_3530_EVM\src\drivers\nled\sources at the new Nleddrvr_mdd.lib. This sources file links against Nleddrvr_lib.lib, which includes Nleddrvr_mdd.lib (which you have cloned) and Nleddrvr_stubpdd.lib (which you have not cloned). So the new SOURCELIBS must resemble the following.

$(_PLATLIB)\$(_CPUINDPATH)\nleddrvr_mdd.lib \
$(_SYSGENOAKROOT)\lib\$(_CPUINDPATH)\nleddrvr_stubpdd.lib \

This picks up the cloned code from the $(_PLATLIB) directory, which is what the output directory Build.exe uses for RELEASETYPE=PLATFORM and TARGETTYPE=LIBRARY. It also picks up the Nleddrvr_stubpdd.lib file from the SYSGEN output directory.

See Also

Concepts

Improve The Build Process