Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a command in SCons without dependencies

Tags:

scons

I want to run a command in SCons which doesn't have any input/output files (actually the input and output are the same file). At the moment I am just manually running it with subprocess.Popen but is there a more SConsy way of doing it?

like image 722
Luke McCarthy Avatar asked Aug 17 '11 13:08

Luke McCarthy


1 Answers

You can use the Command function to run whatever external command you run via Popen, and you can use the AlwaysBuild function to ensure your command is always run even if the target file exists. Scons doesn't like dependency cycles, so leave the source list empty.

myfile = env.Command('myfile.out', [], 'echo Hello world > $TARGETS')
env.AlwaysBuild(myfile)

The scons wiki also has a recipe for PhonyTargets which makes it easy to set up a lot of simple commands.

like image 153
Dave Bacher Avatar answered Oct 24 '22 03:10

Dave Bacher