I can use the Install()
builder to install a directory, provided I don't use a variant.
Example without a variant (works fine):
$ mkdir -p test/src/doc
$ cd test
$ echo "SConscript('src/SConscript', exports={'dst': '/tmp'})" > SConstruct
$ echo xyz > src/doc/file
$ echo "Import('dst')" > src/SConscript
$ echo "Install(dst, 'doc')" >> src/SConscript
$ scons /tmp
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
Install directory: "src/doc" as "/tmp/doc"
scons: done building targets.
$ scons --version
SCons by Steven Knight et al.:
script: v2.1.0.r5357[MODIFIED], 2011/09/09 21:31:03, by bdeegan on ubuntu
engine: v2.1.0.r5357[MODIFIED], 2011/09/09 21:31:03, by bdeegan on ubuntu
engine path: ['/usr/lib/scons/SCons']
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 The SCons Foundation
Example with a variant (does not work):
$ echo "SConscript('src/SConscript', variant_dir='build', duplicate=0, exports={'dst': 'install'})" > SConstruct
$ scons build
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
Install file: "build/doc" as "build/install/doc"
scons: *** [build/install/doc] build/doc: No such file or directory
scons: building terminated because of errors.
This appears to be a very odd behaviour... For my current project, I want to be able to install a directory tree (typically documentation), but using variants.
Could anyone help me? Many thanks in advance!
After investigation, it seems scons tries to install directories using the given path relative from the variant directory, which obviously points to a non-existent folder.
I solved the problem by using absolute paths. Using my toy example:
$ mkdir -p test/src/doc
$ cd test
$ echo "import os" > SConstruct
$ echo "SConscript('src/SConscript', variant_dir='build', duplicate=0, exports={'cwd': os.getcwd() + '/src', 'dst': '/tmp'})" >> SConstruct
$ echo xyz > src/doc/file
$ echo "Import('cwd dst')" > SConscript
$ echo "Install(dst, cwd + '/doc')" >> SConscript
$ scons /tmp
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
Install directory: "src/doc" as "/tmp/doc"
scons: done building targets.
Problem solved! Hope this helps.