[Scons-users] Issues Generating Java Classes from a Swig Interface (.i) under Scons

William Blevins wblevins001 at gmail.com
Sun Oct 11 19:34:49 EDT 2015


On Sun, Oct 11, 2015 at 10:10 PM, Bailey Stephen via Scons-users <
scons-users at scons.org> wrote:

> When I attempt to run scons (2.3.0) to build a class from a SWIG interface
> file, scons fails to pick up all the generated files, either as being in
> the sourcepath, or to be included in the build (even with classpath set).
> Instead only two java files are attempted to be compiled, both of which
> fail because they are derived from other classes.
>
> loc_env = env.Clone()
> loc_env['JAVACLASSPATH']= ['build/$TARGET_ARCH/$TARGET_OS/.../java']
> swig_j = loc_env.Java(target='.', source=['source_java.i']) #1#swig_j = loc_env.Jar(target='.', source=['source_java.i']) #2
>
> Both #1, and #2 fail to produce a result. #2 shows an error message that
> the source has not been accepted, and is a blank string, which I can
> accept, even with example code suggesting it should work.
> For #1 The root cause seems to be in Scons/Tool/swig.py def
> _find_modules(src):, which has a regex to match all modules generated,
> but fails to account for any raw enums or other artefacts from wrapping up
> C code. When I had a hand-rolled makefile the classpath
> For reference, The javac build instruction for #1 is:
>
> javac -classpath build/x86_64/linux/.../java -d build/x86_64/linux/.../java/ -sourcepath build/x86_64/linux/.../java build/x86_64/linux/release/.../source.java build/x86_64/linux/release/.../sourceJNI.java
>
> (This does not contain the additional files for the accessors, enums,
> structs, etc. that are generated by SWIG, and so javac fails.)
>
Do you mean Java files or class files?  What step is failing specifically?


> Is this a known bug (As part of SCONS' handling of 1->N mappings)? Is it a
> flaw in the Scons Parsing of .i files? or is it a more fundamental issue?
>
In order for SCons to know what class files come from a Java file, SCons
Java scanner must open the Java file and parse out the contents.  When the
Java file doesn't exist, the Java scanner (naively) places a single class
file as the output. On a second compile pass (after the Java files exist),
the dependency graph will be expanded to something better (though I know
there are issues with anonymous classes).  I do not know how SCons goes
from SWIG to Java though.  Is it 1:1 or 1:N?


> Best Regards,
> Steve
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
This could also be related to CrossLanguageScanning not working.  Please
see the following pull request slated for SCons 2.5.0:
https://bitbucket.org/scons/scons/pull-requests/244/issue-2264-cross-language-scanner-support/diff

V/R,
Wiliam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20151012/d1eb9919/attachment.html>


More information about the Scons-users mailing list