Reputation: 13806
I'm trying out Scons by setting up a basic C++ sample project that has two sub-projects:
You can see the directory structure and the contents of my SConstruct and SConscript files here
The problem I'm running into is that in order to build these targets from the command line I have to specify both the relative path to their build directory and their platform specific file extensions.
For example, to build Prj1 I have to do:
build> scons ../bin/project1.exe
Likewise, to build Prj2 I have to do:
build> scons ../bin/project2.dll
How can I make SCons build these projects without specifying the relative path and platform specific file extension?
Desired:
build> scons project1
build> scons project2
prj1_env.Alias( 'project1', PROG)
prj1_env.Alias( 'project1', os.path.join( BIN_DIR, PROG) )
Upvotes: 3
Views: 2106
Reputation: 13518
Moving this to an answer instead of a comment. :)
References
Alias needs an actual target as its second argument. I think the issue is that "project1" (the value of PROG) is not an actual target. An easy way to correct this is the following. Make PrefixProgram return a value:
def PrefixProgram(env, outdir, trgt, srcs):
return env.Program(target = os.path.join(outdir, trgt), source = srcs)
Then:
target = PrefixProgram( prj1_env, BIN_DIR, PROG, SOURCES )
prj1_env.Alias("project1", target)
You can of course just do this:
prj1_env.Alias("project1", PrefixProgram( prj1_env, BIN_DIR, PROG, SOURCES ))
But I think the first way is easier to understand.
I hope this helps.
Upvotes: 3