Creating toolkit artifacts for use on multiple platforms
Teracloud® Streams supports a varied set of hardware architectures and Linux™ distributions such as Red Hat Enterprise Linux™ (RHEL). If you plan to deploy a toolkit on multiple platforms, you can create toolkit artifacts that simplify the management of the various C++ libraries. These examples show how to maintain a common infrastructure that works across multiple Linux™ distributions and hardware platforms.
Procedure
- Create platform-specific subdirectories in the impl/lib toolkit
directory.For example: impl/lib/architecture.os-levelAn example of the toolkit structure is as follows:
/+ exampleToolkit /+ toolkit.xml /+ info.xml /+ com.ibm.streams.example /+ myoperator /+ myoperator.xml /+ myoperator_cpp.cgt /+ myoperator_cpp.pm /+ myoperator_h.cgt /+ myoperator_h.pm /+ impl /+ bin /+ archLevel /+ include /+ myheader.h /+ lib /+ ppc64.RHEL7 /+ libmylib.so /+ x86_64.RHEL6 /+ libmylib.so /+ x86_64.RHEL7 /+ libmylib.so
- Create a script that computes the library path.
For example, the following archLevel shell script can be used to return the architecture.os-level portion of the path:
#!/bin/sh # Output appropriate libPath information for toolkits # that support multiple platforms. if [ "$1" == "libPath" ]; then OS=`uname -s` MACH=`uname -i` if [ "${MACH}" = "i386" ] ; then echo "unsupported architecture" exit 1 fi if [ "${OS}" = "Linux" ] ; then if [ -f /etc/redhat-release ] ; then OSVER=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//` OSLVL=RHEL${OSVER} else OSLVL="unsupported Linux distribution" fi OSSTR="../../impl/lib/${MACH}.${OSLVL%%.*}" else OSSTR="${MACH}.unsupported OS" fi echo ${OSSTR} elif [ "$1" == "includePath" ]; then # echo any computed include paths here, if needed : elif [ "$1" == "lib" ]; then # echo any computed library names here, if needed : else echo "unsupported option" fi # end of archLevel script
The archLevel script provides output in the following format:$ impl/bin/archLevel libPath ../impl/lib/ppc64.RHEL7
- Use the script to reference the appropriate library in
the operator model artifacts (operatorName.xml)
and function artifacts (native.function/function.xml).
For example, you can specify the archLevel script in the library element of the operator model for a primitive operator:
<library> <cmn:description>My operator library</cmn:description> <cmn:managedLibrary> <cmn:lib>mylib</cmn-lib> <cmn:includePath>../../impl/include</cmn:includePath> <cmn:command>../../impl/bin/archLevel</cmn:command> </cmn:managedLibrary> </library>