[Scons-users] java builder not working with variant directory

Dirk Bächle tshortik at gmx.de
Wed Jun 25 15:22:24 EDT 2014


Hi William,

On 25.06.2014 18:09, William Roberts wrote:
> [...]
>
> When running "broken" we see the following output from the java builder:
> scons: Reading SConscript files ...
> CWD: /home/wroberts/simple/broken/out
> Entry: .
> Is directory
> Source files: []
> Classes: []
>
> It switched to the variant dir, but never made the hardlink back to
> the java sources, and never switch into that hardlink. Based on what I
> see for my C code projects that do this we should see out/broken/<src>
> and we do not.

all your problems go back to your SConscript file, where you set

   cls = Java(target = 'classes', source = '.')

. This may work at first, but gives errors when used with VariantDirs, 
as you experienced. SCons internally tries to resolve the "." string to 
either a File or Dir Node, and correctly decides that "." is a 
folder...while being in the output directory (abspath = 
".../simple/broken/out"). In the javac.py Tool, method 
emit_java_classes(target, source, env), the "." is resolved to its 
variant dir via the FS.Dir.rdir() method.
But the folder ".../simple/broken/out" (= ".") already exists, because 
your SConscript was linked to it (check with the --debug=duplicate 
option). So, resolving stops and the original folder is returned from 
rdir()...where the Java sources don't exist yet.

The solution is to create an additional subfolder "simple/broken/src" 
with the SConscript, and a Java source folder "simple/broken/src/main" 
with all the *.java files, and then have in your SConscript:

   cls = Java(target = 'classes', source = 'main')

and in your SConstruct:

   SConscript("src/SConscript", variant_dir="out", duplicate=1)

This approach works fine on my side.


Best regards,

Dirk



More information about the Scons-users mailing list