XDC packaging an add-on library

From Texas Instruments Embedded Processors Wiki

Jump to: navigation, search
Translate this page to   

This topic demonstrates a use-case of how to 'wrap' a Target Content library in an XDC package so that the system-integrator doesn't need to do any add-on work (such as adding linker command files to explicitly link in that library)


Contents

Use-case Introduction : DM6467 HDVICP library

The video codecs in the 1.40 DVSDK for the DM6467 all use an accelerator library called hdvicp_ti_api_c64Plus.lib. The APIs in this library enable the codec to offload intensive video specific processing to this dedicated accelerator.

In a DVSDK context we're used to seeing codec packages with the appropriate hooks/methods to work in Codec Engine. There's even a wizard to generate these. However the HDVICP library is not a codec so we just need the basic RTSC packaging so that the XDC tools can pull in what we need (the library itself). We'll show why this adds value in the remainder of this topic.

The 'normal' way

If RTSC did not exist what would you do? You'd probably ship a README saying something like "Set an environment variable HDVICP_LIB to point to your install location. Then add -i"%HDVICP_LIB%/lib" to your build options. Then add -l hdvicp_ti_api_c64Plus.lib to your linker command file"

That's fine for 1 add-on library but if you have 10 or 20 it gets very tedious! In addition you need separate instructions for Windows .v. Linux (and separate instructions for different shells on Linux!)

We need a better way...

Wrapping HDVICP library in an XDC package - why bother?

Here are some of the reasons why we wrap the library in an XDC package: -

Now that we've established the basis for putting HDVICP in a package here's how it's done: -

It makes sense to create our hdvicp package right beside the codecs since the (video) codecs depend on it.

These are the fundamentals of a RTSC package.

package.xdc is mandatory since it declares what the package is (and its compatibility key)

package ti.sdo.codecs.hdvicp [1, 0, 0] {
}

package.xs implements the XDC getLibs() method to return the library name (lib/hdvicp_ti_api_c64Plus.lib) to be linked in to the server/combo or executable.

function getLibs(prog)
{
    var libList = null;
 
    if (prog.build.target.isa == '64P') {
        libList = "lib/hdvicp_ti_api_c64Plus.lib";
        print("    will link with " + this.$name + ":" + libList);
    }
 
    return (libList);
}

package.bld doesnt do much in this context since we're not building any target code - we're just bundling pre-existing content into a package. All it contains is a statement to tell the XDC tools to include all the files in the package when doing an xdc release.

Pkg.attrs.exportAll = true;

The convention is to create a directory named lib in the package. In there we put our hdvicp_ti_api_c64Plus.lib

We can now build the package with the XDC tools - we're not building any C code - just running the XDC tools to build the package.

[>] <path_to_xdc_tools>/xdc

Done!

How to use the HDVICP package?

There are actually several ways to use the package. We explore the pros & cons of each.

Using 'requires' to let codecs 'see' our new package

In e.g. mpeg2dec/package.xdc (and all other video codecs package.xdc files) we could add: -

requires ti.sdo.codecs.hdvicp;

This says "mpeg2dec has a hard dependency on the hdvicp package"

Advantages: -

Disadvantages: -

Leveraging loadPackage in the server/combo

In our server config file we could simply add a line to load the HDVICP package via loadPackage: -

var HDVICP = xdc.loadPackage('ti.sdo.codecs.hdvicp');

Advantages: -

Disadvantages: -

Leveraging useModule in the codec

This requires an extra file and a few more modifications. xdc.useModule() would be necessary if we had to set configuration parameters for the module - in this case there aren't any for HDVICP but the details are included for completeness. xdc.useModule() exists to conditionally include other modules on an as needed basis.

In the HDVICP package we tweak package.xdc to declare the HDVICP module name: -

package ti.sdo.codecs.hdvicp [1, 0, 0] {
      module HDVICP;
}

Then we add a file HDVICP.xdc to declare that this is a metaonly (no code) module.

metaonly module HDVICP
{
 
}

Then (after we build the hdvicp package) we modify the codecs package.xs to add: -

function close()
{
    xdc.useModule('ti.sdo.codecs.hdvicp.HDVICP');
}

Advantages: -

Disadvantages: -

Conclusions

Hopefully this topic shows the rationale for wrapping content in an XDC package as well as the technique to do so.

The recommended method for using the package is via requires, however the xdc.useModule() and (to a lesser extent) the xdc.loadPackage() options can also be used.

Leave a Comment

Comments

Comments on XDC packaging an add-on library


ChrisRing said ...

We probably need to add some details/warnings about 1) the importance of selecting a unique name, and 2) redistributing this new package (e.g. "xdc release" to generate the .tar file, etc).

--ChrisRing 23:37, 2 June 2009 (CDT)

Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox