I want to run the built program directly after compilation, so that i can build and start my program with scons
.
I thought that this SConstruct-File, would start the program, whenever it is rebuilt.
main = Program( "main", [ "main.cc" ] )
test = Command( None, None, "./main >testoutput" )
Depends( test, main )
And this would start it, every time I run scons
main = Program( "main", [ "main.cc" ] )
test = Command( None, None, "./main >testoutput" )
Requires( test, main )
But both don't work, my program is never executed. What am I doing wrong?
This should work better to run the program only when its built.
main = Program( "main", [ "main.cc" ] )
test = Command( target = "testoutput",
source = "./main",
action = "./main > $TARGET" )
Depends( test, main )
And use the AlwaysBuild() to run it every time, as mentioned by @doublep like this:
main = Program( "main", [ "main.cc" ] )
test = Command( target = "testoutput",
source = "./main",
action = "./main > $TARGET" )
AlwaysBuild( test )
And if you want to see the contents of the testoutput, you could do this:
(Assuming Linux. It would be more portable to print the file with some Python code instead)
main = Program( "main", [ "main.cc" ] )
test = Command( target = "testoutput",
source = "./main",
action = ["./main > $TARGET",
"cat $TARGET"] )
AlwaysBuild( test )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With