[Scons-users] Copying and merging directories

William Deegan bill at baddogconsulting.com
Tue Sep 11 14:38:25 EDT 2012


Peter,

Try:
scons --tree=prune

This will show you the dependencies that SCons "knows" about.
Specifically look at the install tree your construction.

You could put the following in to debug what your glob is returning you.

nodes=Glob(C_FROM_DIR+'/fw')
for n in nodes:
print "NODE:%s"%str(n)
You might want to use env.Glob() instead of plain Glob.

Is it safe to assume that TOT doesn't point to a subdirectory of the directory where you run SCons and/or SConstruct resides?

-Bill
On Sep 10, 2012, at 6:33 AM, "Peter Steele" <pwsteele at gmail.com> wrote:


> Okay, I've got a basic test copy/install working, but after putting it all

> together with my full SConstruct file, I'm getting behaving I don't quite

> understand. Here's my full script, which I've modeled after my original ant

> script:

>

> import os

>

> TOT = os.environ["TOT"]

> CLASSPATH =

> "bin:{0}/tools/jars/tools.jar:{0}/tools/jars/velocity-1.7-dep.jar".format(TO

> T)

> SM_BASE = "{0}/Peaxy/sm".format(TOT)

> FROYO_BASE = SM_BASE + "/froyo"

> C_FROM_DIR = FROYO_BASE + "/output/c"

> C_TO_DIR = SM_BASE + "/libipc/src"

> JAVA_FROM_DIR = FROYO_BASE + "/output/java/com/peaxy/ipc/fw"

> JAVA_TO_DIR = SM_BASE + "/common/src/com/peaxy/ipc"

>

> env = Environment(JAVACLASSPATH=CLASSPATH, JAVAVERSION="1.7")

>

> env.Clean("all", Glob("bin") + Glob("output") + Glob(C_TO_DIR + "/fw") +

> Glob(JAVA_TO_DIR + "/fw"))

>

> build = env.Alias("build", [env.Java("bin", "src"), env.Java("bin",

> "idl")])

>

> codegen = env.Alias("codegen", env.Command(

> "codegen", [],

> "java -cp {0} -Dsdir={1}/idl -Dodir={1}/output -Dtdir={1}/template

> -Ddpath={1}/bin com.peaxy.ipc.codegen.IDLCompiler"

> .format(CLASSPATH, FROYO_BASE)),

> )

>

> copy = env.Alias("copy", env.Install(C_TO_DIR, Glob(C_FROM_DIR +

> "/fw")))

>

> Default(build, codegen, copy)

>

> My application is basically a code generator and there are three distinct

> phases: build, codegen, and copy. My ant script also has an "all" target so

> that when I do an "ant all", it runs the targets build, codegen, and copy in

> sequence. I'm using the scons Default function to mimic the ant "all"

> target, at least that's my intent. When I run "scons -c clean", all of the

> generated files are cleaned up as expected. When I run "scons" without any

> arguments, the build and codegen phases work as intended. However, the

> 'copy' target reports "Nothing to be done for 'copy'." If I then immediately

> turn around and run "scons copy", the files are copied successfully on this

> attempt. So, I'm missing something key how this all operates. Why does the

> copy alias not work when run through Default() but does run when specified

> explicitly as a target?

>

> In fact, my script above isn't quite complete. What I really want for the

> copy step is something like this:

>

> copy = env.Alias("copy", [env.Install(C_TO_DIR, Glob(C_FROM_DIR +

> "/fw")),

>

> env.Install(JAVA_TO_DIR, Glob(JAVA_FROM_DIR + "/fw"))])

>

> However, this doesn't work at all and I'm clearly not constructing the logic

> correctly. Basically, I want to copy the generated source files to two

> separate locations, one in a C source directory and another in a Java source

> directory. These projects are then built in separate steps with their own

> scons/ant scripts.

>

>

> -----Original Message-----

> From: scons-users-bounces at scons.org [mailto:scons-users-bounces at scons.org]

> On Behalf Of Francis Bolduc

> Sent: Monday, September 10, 2012 5:14 AM

> To: SCons users mailing list

> Subject: Re: [Scons-users] Copying and merging directories

>

>> env.Alias('copy', env.Command('copy', [], env.Install(TO_DIR,

>> env.Glob(FROM_DIR))))

>

> I think there are two problems with this.

>

> 1- env.Command is redundant, simply remove it.

>

> env.Alias('copy', env.Install(TO_DIR, env.Glob(FROM_DIR)))

>

> 2- Glob(pattern) returns files matching the pattern in the SConscript

> directory. So if you print the result from Glob(), you'll see which files

> will be copied. Also, beware, Glob(pattern) is not recursive.

>

> for node in env.Glob('*.h'):

> print node.abspath

>

> Finally, be sure to keep the Alias because if TO_DIR is not in the

> SConscript's directory or one of it's sub-directories, SCons will not copy

> the install the files unless you specify the install directory as part of

> the target. The phony 'copy' target you created prevents this.

> _______________________________________________

> Scons-users mailing list

> Scons-users at scons.org

> http://four.pairlist.net/mailman/listinfo/scons-users

>

> _______________________________________________

> Scons-users mailing list

> Scons-users at scons.org

> http://four.pairlist.net/mailman/listinfo/scons-users




More information about the Scons-users mailing list