Handling source code differences

Learn how to handle differences in the source code.

Use the same files (that is, the same versions of file elements) in all builds, for all platforms. You can usually achieve this goal by using the standard UNIX system and Linux approach: conditional compilation using the C preprocessor, cpp(1). For example, if a header file string.h is to be used for the architecture whose cpp symbol is ARCH_A, and header file strings.h is to be used for architecture ARCH_B, use this code:

#ifdef ARCH_A
#include <string.h>
#else
#ifdef ARCH_B
#include <strings.h>
#endif /* ARCH_B */
#endif /* ARCH_A */

If a file element cannot be compiled conditionally (for example, a bitmap image), the traditional solution is to put architecture-specific code in different elements (for example, panel.image.x86_64 versus panel.image.ppc64le). This approach requires that build scripts be architecture specific, too.

With HCL VersionVault, you have the option of splitting the element into branches. The ARCH_A variant can be developed on the element's /main/arch_a branch; edits and builds for that variant are developed in a view configured with this rule:

element * /main/arch_a/LATEST

Other variants are developed on similar branches, each using a different view, configured with a rule as mentioned in the preceding command. In such a situation, the element's main branch might not be used at all.

Use this branching strategy only when necessary, because of its disadvantages:

  • Each time platform-independent code is changed on one of the branches, you must merge the change to the other branches.
  • Developers must create a view for each architecture. In each view, only one variant of the application can be built.

If you can do so, organize your code into architecture-specific subdirectories or architecture-specific VOBs.