Scons - run the program after compilation

I want to run an embedded program immediately after compilation so that I can create and run my program with scons.

I thought this SConstruct-File would run the program when it was restored.

main = Program( "main", [ "main.cc" ] )

test = Command( None, None, "./main >testoutput" )
Depends( test, main )

And it will start every time I run scons

main = Program( "main", [ "main.cc" ] )

test = Command( None, None, "./main >testoutput" )
Requires( test, main )

But both do not work, my program is never executed. What am I doing wrong?

+5
source share
2 answers

This should work better to run the program only when it is created.

main = Program( "main", [ "main.cc" ] )

test = Command( target = "testoutput",
                source = "./main",
                action = "./main > $TARGET" )
Depends( test, main )

And use AlwaysBuild () to run it every time, as @doublep pointed out as follows:

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 test output, you can do this:

(, Linux Python)

main = Program( "main", [ "main.cc" ] )

test = Command( target = "testoutput",
                source = "./main",
                action = ["./main > $TARGET",
                          "cat $TARGET"] )
AlwaysBuild( test )
+7

ls SCons:

ls = Command ('ls', None, 'ls')
AlwaysBuild ('ls')
Default ('ls')

SCons, . , , - .

, , , , , Python .

+4

All Articles