Swig fails with a SWIGOUTDIR (not created) if language is not Python/Java
This issue was originally created at: 2009-02-25 04:46:22.
This issue was reported by: teajay.
teajay said at 2009-02-25 04:46:22
When using SWIG we like to specify a SWIGOUTDIR in order for the generated code to fall into a seperate directory. This works great as long as the output directory already exists. If the directy happens to be missing the call to swig fails as it can't write it's output files.
I worked around the problem in my SConstruct files but it would definitly be nicer if Swig builder created the SWIGOUTDIR if it doesn't exist.
Thanks for the great work.
Thomas Bernard.
gregnoel said at 2009-03-05 15:22:44
Bug party triage. Greg to find out who previous SWIG expert was and report back.
gregnoel said at 2009-03-13 13:27:35
Ben, we believe that SWIGOUTDIR should cause the directory to be created. Can you look into this and let us know what's wrong? Add a comment to the issue and change the milestone back to -unspecified- so we'll pick it up for retriage. Tks
benmwebb said at 2009-03-14 09:00:34
Sure, I'll take a look. What I can say for sure is that SWIG's -outdir option does not create the directory, so scons will have to do it. I'll make up some test cases to see what's going on here.
benmwebb said at 2009-03-15 11:54:05
Created an attachment (id=594) scons-python-outdir.patch
benmwebb said at 2009-03-15 11:57:30
Thomas, are you using SWIG to generate Python wrappers? Looking at the SWIG tool, it looks like SWIGOUTDIR should work correctly if you are generating Java wrappers - there's even a test for this in the test suite. But SWIGOUTDIR appears to be ignored when generating Python wrappers.
The attached patch (to scons SVN trunk, r4074) adds support for SWIGOUTDIR with Python wrappers, and adds a test case for this. Please let me know if this fixes the issue for you (if not, please provide a minimal test case to demonstrate your problem).
teajay said at 2009-03-15 23:18:25
Acutally i'm using swig to generate com and C# wrappers for now. I also intend to generate lua wrappers but I know they don't produce any script side files so it shouldn't be a problem.
I'll have a look at the patch you made and i'll provide a test case for the issue i'm facing. If I get that far, I might as well try to provide a patch.
benmwebb said at 2009-03-16 08:34:22
Well, there's your problem - the SWIG builder currently only knows about language-dependent files for Python and Java. It has no support for C# or any other language for that matter. So it'll work, but it won't track the dependencies of the language-dependent files at all, so won't rebuild them if you delete them, won't clean them with -c, and (when using SWIGOUTDIR) won't create the directory they're supposed to end up in.
It wouldn't be that hard to teach the builder about language dependent files for other languages (although it would be tedious to add support for every language). But it would add a lot of dependencies to the build system if the current tests for Python and Java, which build all the way from .i to .so, were extended to test every SWIG-supported language (since you'd need to install the C API headers and libraries for each language to compile and link the wrappers). As a compromise the tests could just go from .i to *_wrap.c for now.
teajay said at 2009-03-16 08:40:19
I tried earlier today to get the tests concerning swig running on my machine so I could try and have a go at the patch you provided. The problem was I didn't get the tests to work in the first place ... I didn't have time to work any longer on the problem so I left that aside.
Anyway that would really be great to get support for all the generated interface types supported by swig ...
If I get those tests running I might have a go at it (at least for C#, COM and lua)
gregnoel said at 2009-03-16 16:31:43
Setting this back to -unspecified- so it will be retriaged.
gregnoel said at 2009-03-19 02:11:40
Bug party triage. Ben, we are most impressed. We only asked for an analysis of the problem, but you provide a patch with tests, plus determined that the OP is looking for something we don't currently support.
Would you be willing to be a developer? Unless you volunteer for something, it basically means that we'd nag you with issues like this one from time to time. (For example, if you want to volunteer to tackle adding support for the missing SWIG languages, you'd be a hero to us.)
If you do want to be a developer, let me know and I'll enable you so you can go ahead and apply this patch. And also apply that documentation patch you posted for review a few days ago.
benmwebb said at 2009-03-21 19:33:20
Certainly, I would be happy to be a developer. I am unfortunately rather busy with other things right now, however, so can't promise to be able to do much more than fix the occasional SWIG problem here and there.
I don't think it would be hard to add support for at least the major languages currently supported by SWIG, so I'll take a look at that in the near future. (Some other languages such as R might be hard to test, because I think that would require a very recent version of SWIG.)
garyo said at 2012-09-01 10:01:49
Bumping all old issues targeted for past releases to 2.x.
benmwebb attached scons-python-outdir.patch at 2009-03-15 11:54:05.
Just a note on history: the patch referenced here was applied in 2009. Knowing this, I'm removing the "Has Patch" label (which I added recently), because it doesn't have a pending patch. I presume since the the original topic, which was about a different language, remains unresolved we should just leave the bug as it?
Looks like the issue description is inaccurate. It should be SWIGOUTDIR not created if language output from swig isn't one of java, python, c ?