Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

TODO: describe that this is only necessary if you have custom paths

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 libaries. 

SCons defines it's own default PATH for finding executables. If any of the build tools are located outside of the default locations, either the absolute path must be provided in the build environment defined in the SConstruct file or the user_path=1 option must be used when running scons commands.

The SConstruct is organized to allow for targets to be built for different platforms based on the target option to the scons command. SCons uses the Environment data structure to set build parameters such as the compiler path, header search directories, libraries to link against, etc.  

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. The SCons documentation lists the built-in variables that are used to construct the compilation commands. 

def getLinuxEnv(baseEnv):
    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/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. 

def get_raspi2_platform(env):  
    # compiler location
    env['TOOLCHAIN_DIR'] = "/tools/armpi-linux/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian" 
    env['CXX']  = '$TOOLCHAIN_DIR/bin/arm-linux-gnueabihf-g++'
    env['LINK'] = '$TOOLCHAIN_DIR/bin/arm-linux-gnueabihf-g++'
    ...
    env['PLATFORM'] = 'armpi-linux'

While the paths to the compiler or directories containing headers and libraries may need to be changed, there are other variable definitions that are required by the build steps. 

  • No labels