Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This section describes additional details of the SCons build script used to compile the AP Bridge software. You may need to further modify the SConstruct file if you install the toolchain or other dependencies in a different location than described in the build instructions. 

TODO: update SCons snippets and provide where paths should be set (instead of where it is used)

Certain parts of the build scripts may need to be adjusted to specify the location of files on the host build platform. The SConstruct file defines a build environment that contains the path to the compiler(s) and the search paths for headers and libraries. 

...

The getHOSTEnv function configures common parameters for a particular build host. This function should be used to set common tools, compile flags and directory paths, such as the path to the directory where the required libraries are installed. Most of the directories and paths can be controlled by command line options. The SCons documentation lists the built-in variables that are used to construct the compilation commands. This function is the place to add common compile and link flags that are not specific to a particular target

Code Block
def getLinuxEnv(baseEnv):
    'Construct the Linux build environment'
    boost_incdir, boost_libdir = findBoostDirs(baseEnv)
    env = baseEnv.Clone(
        HOST_ARCH = platform.machine() + '-linux',
        TOOLS_DIR = baseEnv['tools_prefix'],  # tools_prefix can be passed as a command option
        BOOST_BASE= baseEnv['boost_prefix'],  # boost_prefix can be passed as a command option
        ...
        CPPPATH=[
            '#',
            '$TOOLS_DIR/include',
            boost_incdir,
        ],
        # Linker flags
        LIBPATH=[
            '$TOOLS_DIR/lib',
            boost_libdir,
        ],
    )
    # Compile actions for various intermediate languages
    env['PROTOC'] = '/usr/local/bin/env['protoc']
    ...
    return env


The get_TARGET_platform function specializes the configuration for a particular target platform. This may involve changing the compiler path and updating the compiler flags used for a particular target platform. The RPi 2 platform function contains several target-specific names that may need to be updated if you use a different cross-compiler. 

Code Block
def get_raspi2_platform(env):
    'Set architecture-specific flags for raspberry pi 2'
    # compiler location
    env['CXX']  = '$toolchain_dir/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++'
    env['LINK'] = '$toolchain_dir/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++'
    ...
    # other variables are defined in this function to customize the build process for this target
    env['PLATFORM'] = 'armpi-linux'
    return env


Manually overriding SConstruct variables

Certain variables, such as target and the directories used for the toolchain and libraries, can be specified on the scons command line. For example, to use a toolchain installed in in a central directory /tools/armpi-linux/arm-bcm2708:

No Format
$ scons toolchain_dir=/tools/armpi-linux/arm-bcm2708 target=armpi apbridge


By default, scons prints a help message containing a list of all the variables and their default values. Some variables are used internally as part of the Dust build and release process. 

...