Manual Clone of Public Code

来源:互联网 发布:海湾200主机编程 编辑:程序博客网 时间:2024/06/06 02:40

If sysgen_capture doesn't work for some reason you can always manually clone the component you want to modify. By following the instructions on the blog post "Cloning Public Code: An Example" you should be able to get this working, but to help you a bit more here are some step by step instructions for manually cloning public code.

In this blogpost we'll be cloning TELNETD because for some reason sysgen_capture doesn't work for this component. TELNETD is located under the WINCE project tree "servers". I know the exact name of the WINCEPROJ by opening up the makefile in /PUBLIC/SERVERS/CESYSGEN and searching for WINCEPROJ. The correct sysgen_capture command for TELNETD would be:

sysgen_capture -p servers telnetd

The -p parameter indicates the WINCEPROJ, so in this case it's of course not "common", but "servers". Unfortunately for some reason this command doesn't output a sources.telnetd file (in fact it doesn't output any file!). No stress, let's just clone manually:

  1. Copy the TELNETD folder to your OS Design (/WINCE500/PBWorkspaces/<MyOSDesign>/TELNETD or /WINCE600/OSDesigns/<MyOSDesign>/<MyOSDesign>/TELNETD)
  2. Open the sources. file in the folder you just copied
  3. Set TARGETTYPE to DYNLINK
  4. Set RELEASETYPE to LOCAL
  5. Delete WINCETARGETFILE0=$(_RELEASELIBDIR)/$(TARGETDEFNAME).def
  6. Open the makefile. in <WINCEROOT>/PUBLIC/SERVERS/CESYSGEN and search for telnetd
  7. Copy the line @set TARGETLIBS... and @set DLLENTRY...
  8. Paste into your sources. file
  9. Change @set TARGETLIBS... in your sources. file to:
    TARGETLIBS=$(_PROJECTROOT)/cesysgen/sdk/lib/$(_CPUINDPATH)/ws2.lib /
               $(_PROJECTROOT)/cesysgen/sdk/lib/$(_CPUINDPATH)/coredll.lib /
               $(_PROJECTROOT)/cesysgen/sdk/lib/$(_CPUINDPATH)/ceosutil.lib  /
               $(_PROJECTROOT)/cesysgen/sdk/lib/$(_CPUINDPATH)/authhlp.lib
  10. Change @set DLLENTRY... in your sources. file to:
    DLLENTRY=DllEntry
  11. Add the include paths:
    _OEMINCPATH=$(_WINCEROOT)/public/common/oak/inc; $(_WINCEROOT)/public/common/sdk/inc; $(_WINCEROOT)/public/common/ddk/inc
    NOTE: DO NOT PUT SPACES BETWEEN THE PATHS! I know it is confusing because I do it above, but I have to to support line breaking (otherwise this page will look ugly...).
  12. And build...

Easy as that! Now that you have the TELNETD component successfully cloned you can continue following the instructions from step 7 in the blog post "Cloning Public Code: An Example" (of course replacing "netui" with "telnetd" in the text).

Here's the complete sources. file for reference (don't forget to delete the spaces in the _ISVINCPATH, _OEMINCPATH and INCLUDES macros! I need those spaces here to format the HTML nicely, but you will get compiler error "/I" requires an argument if you leave those spaces):

 

WINCEOEM=1
_OEMINCPATH=$(_WINCEROOT)/public/common/oak/inc; $(_WINCEROOT)/public/common/sdk/inc; $(_WINCEROOT)/public/common/ddk/inc

TARGETNAME=telnetd
TARGETTYPE=DYNLINK
RELEASETYPE=LOCAL

TARGETDEFNAME=$(TARGETNAME)
DEFFILE=$(TARGETNAME).def
CDEFINES=$(CDEFINES) -DwinCE
DLLENTRY=DllEntry

SOURCES=telnetd.cpp telndev.cpp consemu.cpp

TARGETLIBS=$(_PROJECTROOT)/cesysgen/sdk/lib/$(_CPUINDPATH)/ws2.lib /
           $(_PROJECTROOT)/cesysgen/sdk/lib/$(_CPUINDPATH)/coredll.lib /
           $(_PROJECTROOT)/cesysgen/sdk/lib/$(_CPUINDPATH)/ceosutil.lib  /
           $(_PROJECTROOT)/cesysgen/sdk/lib/$(_CPUINDPATH)/authhlp.lib

 

Cloning public code: An example

For some strange reason, people are still changing public code and doing build and sysgen's on their Windows CE tree (read this to learn why this is a bad thing). Changing code in the PUBLIC and PRIVATE trees might seem like a shortcut but actually it is everything but a shortcut. When you clone the code before changing it in place you will save yourself hours and hours of build time. A targeted build of a cloned driver takes seconds, a clean build and sysgen takes hours.

Cloning is not difficult at all, so there is really no reason to change PUBLIC or PRIVATE code. To prove that it is not difficult (once you know what you are doing) I will show you how to clone PUBLIC code in this blog post. Note that there is an article by Steve Maillet and Mike Hall in MSDN about cloning public code too. They split the clone into a "LIB" part and a "DLL" part. I don't really like that method; I just merge the sources file into one that creates the DLL in one go. Have a look at the "split" method here.

I chose to clone NETUI, since this component is responsible for a lot of dialog boxes that you may want to change to match your systems specifications.

I am cloning NETUI on a Windows CE 6.0 tree, but it works exactly the same on a Windows CE 5.0 tree (apart from the OSDesign folder which is called PBWorkspaces in CE 5.0).

Prerequisites: A sysgenned OSDesign with the "Network UI" component included.

Let's start!

  1. Copy the entire /WINCE600/PUBLIC/COMMON/OAK/DRIVERS/NETUI folder to your OSDesign, for instance /WINCE600/OSDesigns/MyOS/MyOS
  2. Open a build window (in Platform Builder / VS2005 click "Open Release Directory in Build Window" from the menu "Build"
  3. In the build window, type:
    cd..
    cd..
    cd netui
  4. Now type:
    sysgen_capture -p common netui
    This command will output a set of files in the current directory.
  5. Since we only want to build netui, you can delete:
    sources.btdrt
    sources.ceddk
    sources.iphlpapi
    sources.k.iphlpapi
    sources.ws2
    sources.ws2k
  6. Now intelligently merge sources. with sources.netui (we make the changes in the sources. file):
    • Make a backup of the sources. file (copy to sources.org) so you can always go back if needed
    • We are trying to build a DLL, so change TARGETTYPE=LIBRARY to TARGETTYPE=DYNLINK
    • We are building NETUI as a project in our workspace, so set the RELEASETYPE to LOCAL (RELEASETYPE=LOCAL)
    • We are not building a LIB anymore, so there's no need to preprocess the def file. Remove the following lines:
      WINCETARGETFILE0=$(_RELEASELIBDIR)/$(TARGETDEFNAME).def
      PREPROCESSDEFFILE=1

      And add this line to tell the build system to use the local def file for the exports:

      DEFFILE=$(TARGETDEFNAME).def

       

    • We don't need the resource file later (because we are not creating a lib that has to be transformed into a dll later), so remove the COPYRES=1 line and the WINCETARGETFILES line pointing to the res.
    • OSDesign SubProjects get build last, so we don't need to copy SYNCHRONIZE_DRAIN=1 from sources.netui to our sources. file
    • Since we are now building a DLL, copy the DLLENTRY line from sources.netui to sources.
    • Now move the entire SOURCELIBS and TARGETLIBS from sources.netui to sources.
    • and delete any references to netui (netui.lib/netui.res) itself (because we are building that now)
    • Change the paths to the target libraries from using the PUBLIC sysgened libraries to the libraries sysgened to your workspace, so change $(_SYSGENSDKROOT)/ to $(_PROJECTROOT)/cesysgen/sdk/ and $(_SYSGENOAKROOT)/ to $(_PROJECTROOT)/cesysgen/oak/
    • You can also delete the #xref lines, they are remains of older days (CE 2.11 era).
    • Now try to build (by typing "build" in the build window you still have open)
    • oops! Doesn't build. It can't find the standard include files... Add the following to the top of the sources file:
      _ISVINCPATH=$(_WINCEROOT)/public/common/sdk/inc;
      _OEMINCPATH=$(_WINCEROOT)/public/common/ddk/inc; $(_WINCEROOT)/public/common/oak/inc; $(_WINCEROOT)/public/common/sdk/inc;
      NOTE: DO NOT PUT SPACES BETWEEN THE PATHS! I know it is confusing because I do it above, but I have to to support line breaking (otherwise this page will look ugly...).
    • And since this project is building OEM code (a kernel component) set WINCEOEM=1 to indicate we want to use the _OEMINCPATH (so if you really want to you can delete the _ISVINCPATH since we don't use that one).
    • Try to build again:
      BUILD: [01:0000000048:ERRORE] /WINCE600/OSDesigns/MyOS/MyOS/NETUI/./btmgmtui.cpp(39) : fatal error C1083: Cannot open include file: '../bluetooth/sample/btenum/btenum.hxx': No such file or directory

      So, one of the sources files is trying to include a header on a relative path. Since NETUI came from /WINCE600/PUBLIC/COMMON/OAK/DRIVERS/NETUI this path must be /WINCE600/PUBLIC/COMMON/OAK/DRIVERS/BLUETOOTH

      Now there are 3 ways to solving this: Either add the /WINCE600/PUBLIC/COMMON/OAK/DRIVERS/NETUI folder to the include path (add INCLUDES=$(INCLUDES);/WINCE600/PUBLIC/COMMON/OAK/DRIVERS/NETUI) so that the header file can be found off the relative path, or change the source file including the header to use a full path to the header file, or copy the btenum.hxx file into the NETUI folder and change the source file including the header to use the local header file. I think the last option is the cleanest, so let's copy /WINCE600/PUBLIC/COMMON/OAK/DRIVERS/BLUETOOTH/SAMPLE/BTENUM/btenum.hxx to /WINCE600/OSDesigns/MyOS/MyOS/NETUI/btenum.hxx and change btmgmtui.cpp to #include "btenum.hxx"

    • Build again: 0 Warnings,  0 Errors. Whuuhooo!
    • Now there is one final thing we have to add to the NETUI sources. file. We have to tell the build system we want to copy the final binary to the _FLATRELEASEDIR so our netui.dll will overwrite the default one from the PUBLIC/COMMON folder. Add WINCEREL=1 to the top of the sources. file.
  7. Now add the NETUI project to your workspace. In the Platform Builder VS IDE click "Add Existing Subproject..." from the "Project" menu. Browse to the /WINCE600/OSDesigns/MyOS/MyOS/NETUI folder, select "Sources/Dirs Files" from the "Files of type" dropdown list, select the sources. file, and click "Open"
  8. In the Solution Explorer window you can now find your NETUI component under the "SubProjects" node. Right click NETUI and click "Rebuild" to see if you can build the project from the IDE. It should all build fine.
  9. If all builds fine, you can delete the sources.netui and the sources.org files since you no longer need them now.
  10. The "Insert existing project" action created a couple of files for you. One of those files is a bib file. BIB files are used to indicate which files need to be included in the image. Since we cloned NETUI, but did not remove it from the OSDesign features, we now have 2 references to NETUI in the combined BIB files (one is in COMMON.BIB and the other in our newly generated NETUI.BIB). We don't need an extra reference in the BIB files, all we want is overwrite the default NETUI.DLL in the _FLATRELEASEDIR, so you can remove this reference from the newly generated NETUI.bib.

Now you can change whatever you need to change in NETUI without worrying about messing up the PUBLIC portion of the WINCE tree or having to do a "Clean Build and Sysgen".

If you have followed all the steps above your final NETUI sources. file should look like this (except the spaces in the _ISVINCPATH, _OEMINCPATH and INCLUDES macros!):

 

_ISVINCPATH=$(_WINCEROOT)/public/common/sdk/inc;
_OEMINCPATH=$(_WINCEROOT)/public/common/ddk/inc; $(_WINCEROOT)/public/common/oak/inc; $(_WINCEROOT)/public/common/sdk/inc;

WINCEOEM=1
WINCEREL=1

TARGETNAME=netui
TARGETTYPE=DYNLINK
RELEASETYPE=LOCAL

TARGETDEFNAME=$(TARGETNAME)
DEFFILE=$(TARGETDEFNAME).def

DLLENTRY=_DllEntryCRTStartup

CONDITIONAL_INCLUDES=prshtp.h

SOURCELIBS=

TARGETLIBS=/
    $(_PUBLICROOT)/common/oak/lib/$(_CPUINDPATH)/btenum.lib /
    $(_PROJECTROOT)/cesysgen/sdk/lib/$(_CPUINDPATH)/iphlpapi.lib /
    $(_PROJECTROOT)/cesysgen/oak/lib/$(_CPUINDPATH)/btdrt.lib /
    $(_PROJECTROOT)/cesysgen/sdk/lib/$(_CPUINDPATH)/ws2.lib /
    $(_PROJECTROOT)/cesysgen/oak/lib/$(_CPUINDPATH)/ceddk.lib /
    $(_PROJECTROOT)/cesysgen/sdk/lib/$(_CPUINDPATH)/coredll.lib

SOURCES= /
    netui.c /
    getip.c /
    ipaddr.c /
    getuser.c /
    linecnfg.c /
    wnet.c /
    netcard.c /
    certui.cpp  /
    showcert.cpp /
    eaptlscfg.cpp /
    network.c /
    transdlg.c /
    reg.c /
    util.c /
    wzcui.c /
    wzcprops.c /
    btmgmtui.cpp /
    WzcQuickCfgUi.c /
    IpQuickCfgUi.c /
    QuickConfigUi.c /
    WzcLogging.c /
    WzcPopup.c /
    netui.rc  /
    wnet_wrapper.cpp /
    netui_wrapper.cpp /
    getuser_wrapper.cpp /
    gwes_wrapper.cpp /
    getip_wrapper.cpp /
    linecnfg_wrapper.cpp /
    transdlg_wrapper.cpp /
    network_wrapper.cpp /
    netcard_wrapper.cpp

FILE_VIEW_PARAMETER_FOLDER= /
    NETUI.bib /
    NETUI.reg /
    NETUI.dat /
    NETUI.db /
    ProjSysgen.bat /

FILE_VIEW_ROOT_FOLDER= /
    prelink.bat /
    postlink.bat /

PRELINK_PASS_CMD=prelink.bat
POSTLINK_PASS_CMD=postlink.bat
原创粉丝点击