Dealing with Different Platforms

In the section on Linker Options we saw that GCC and Clang required slightly different linker flags to generate the map file.

Using the environment variable we can interrogate the current environment to find which platform we are compiling on, e.g.

vars = Variables()
env = Environment(variables = vars)

platform = env.Dictionary('PLATFORM')

This returns a string indictating the current build platform. This variable can then be used to manage any pltaform specific build requirements, e.g.

generate_map_file = '-Wl,'
if(platform == 'posix'): # Linux
map='-Map,'
if (platform == 'darwin'): # OS X
map='-map,'
generate_map_file += map+exe+'.map'

env.Append(LINKFLAGS = [generate_map_file,])

results matching ""

    No results matching ""