Skip to content

AlwaysBuild() does not work if the target is a directory #1426

Closed

Description

@bdbaddog

This issue was originally created at: 2006-06-27 21:33:33.
This issue was reported by: petergummer.
petergummer said at 2006-06-27 21:33:33

I have a SCons script that has a directory as a target. Whenever this target is
specified, I want it to run an associated Command(), regardless of whether the
target directory already exists. The idea is that this command will
automatically do a test run after I have built and installed some applications.

I've got all of this working except for the requirement that it should always
run. I tried to do this with AlwaysBuild(). The SCons manpage says, "Marks each
given target so that it is always assumed to be out of date, and will always be
rebuilt if needed."

Well, I'm afraid it doesn't, if the target is a directory. Here's a 2-line
SConstruct that demonstrates the problem, with a sequence of commands where I
run the script, with and without the target as a directory, and then with and
without the target as a file. Apart from showing that AlwaysBuild() does work if
the target is a file, this also shows that running the script automatically
deletes the target if it is a file, but not if it is a directory. I wonder if
this is the cause of the problem.

$ type SConstruct
env = Environment()
AlwaysBuild(env.Command('/xxx', None, 'echo $SOURCE $TARGET'))

$ scons -Q /xxx
echo C:\xxx
"C:\xxx"
$ md \xxx

$ scons -Q /xxx
scons: `C:\xxx' is up to date.
$ rd \xxx

$ scons -Q /xxx
echo C:\xxx
"C:\xxx"
$ echo hello > xxx

$ type xxx
hello

$ scons -Q /xxx
echo C:\xxx
"C:\xxx"
$ type xxx
The system cannot find the file specified.

$ scons -Q /xxx
echo C:\xxx
"C:\xxx"
$

There is a workaround, which works as expected:

env = Environment()
AlwaysBuild(env.Command('/xxx/*', None, 'echo $SOURCE $TARGET.dir'))

stevenknight said at 2007-05-24 13:43:49

Fixed for next release. Thanks for the report. --SK

stevenknight said this issue blocks #1664 at 2007-05-24 13:43:49.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions