tags:

views:

360

answers:

1

Hi, I try to setup a build system to build a shared lib MySharedLib and a binary MyBinary that rely on MySharedLib. The build system should be able to install MySharedLib and MyBinary when asked for it, and only when asked for it.

import os.path

env = Environment()
env.Append(CCFLAGS='-g -Wall -ansi -O2')

prefix = '/usr/local'
lib_dir = os.path.join(prefix, 'lib')
bin_dir = os.path.join(prefix, 'bin')
Export('env prefix lib_dir bin_dir')

libMySharedLib = SConscript('libMySharedLib/SConscript')
MyBinary   = SConscript('MyBinary/SConscript')

env.Alias('install', env.Install(lib_dir, libMySharedLib))
env.Alias('install', env.Install(bin_dir, MyBinary))

When I run SCons with no command line arguments, MySharedLib and MyBinary are built, but it also it try to install them. I want them installed only just when I ask for the install target. I tried many times, read the docs, but I can't figure it out.

+3  A: 

By default, and when no target are set into the scons script, scons builds every target in '.'. You can control which targets to build by default with the Default function:

lib = SConscript('libMySharedLib/SConscript')
bin = SConscript('MyBinary/SConscript')

env.Alias('install', env.Install(lib_dir, lib))
env.Alias('install', env.Install(bin_dir, bin))

# By default (scons called with no explicit target), only build bin
Default(bin)

AFAIK, there is no way to tell scons to build nothing, although you could create a dummy target I suppose.

David Cournapeau