[Scons-users] turning off directory creation?

Robert Zeigler robert.zeigler at gmail.com
Tue Apr 30 09:03:18 EDT 2013


I'm in the process of converting a make-based build to an scons one. One of the programs called during the build generates a set of targets in a particular directory structure. It creates this directory structure itself and, as currently written, won't work correctly if that directory structure already exists. However, it appears that scons automatically creates directories when a target is a directory path (see example at end of e-mail). I've worked around the problem for now by forcing the build to remove the destination directory, but that's an ugly hack. Long-term, the solution is to rework the underlying code to be more intelligent about handling existing directory structures, but there simply isn't time to do that right now. Is there a way to turn off scons's default "create non-existent target directory structure" behavior? I've googled this for the past day to no avail.

Thanks!

Robert

SConstruct:
Command(["foo/bar/baz.txt"],[],"echo noop")

terminal:

rm -rf foo/
ls foo
ls: cannot access foo: No such file or directory
scons
scons: Reading SConscript files …
scons: done reading SConscript files.
scons: Building targets …
echo noop
noop
scons: done building targets.

ls foo
bar


This is different from make's behavior, which requires users to explicitly create any auto-generated target folders:
makefile:

foo/bar/baz.txt:
echo noop
all: foo/bar/baz.txt

terminal:
rm -rf foo/
ls foo
ls: cannot access foo: No such file or directory
make all
echo noop
noop
ls foo
ls: cannot access foo: No such file or directory




More information about the Scons-users mailing list