[Scons-users] custom builder for use with wine

Patrick.Wambacq at esat.kuleuven.be Patrick.Wambacq at esat.kuleuven.be
Fri Aug 16 05:01:50 EDT 2013

Dear all,

I want to cross-compile unix code for windows using the mingw toolchains. In my setup, several small C programs are run by scons (using TryRun) to check compiler and system behaviour, and this requires running these Windows test executables on the host system. I use wine for this purpose on Linux, and this works well. On Linux the kernel can be made to recognize windows executables (using binfmt_misc) such that they can be run without having to specify "wine" on the command line.

This functionality however does not exist on Mac OSX, where a windows executable needs to be run with "wine path-to-executable".
So I tried to make a custom builder, similar to TryRun that does this. But I cannot get it to work. Here is what I tried: I copied the TryRun source and slightly modified it so that it looks like

def TryWine(self, text, extension):
ok = self.TryLink(text, extension);
if( ok ):
prog = self.lastTarget;
pname = "/path_to_wine/wine " + prog.path;
output = self.confdir.File(os.path.basename(pname)+'.out');
node = self.env.Command(output, prog, [ [ pname, ">", "${TARGET}"] ]);
ok = self.BuildNodes(node);
if ok:
outputStr = output.get_contents();
return( 1, outputStr);
return (0, "");

I also attach it to my environment with

env['BUILDERS']['TryWine'] = Builder(action=TryWine);

and I use it with

result = conf.env.TryWine(some_test_program,".c");
result = result[1].split();

where conf is an environment that has all the custom checks in a dictionary:

conf = env.Configure(custom_tests=custom_tests);
for check in sorted(custom_tests):
# see if we have a working compiler
env = conf.Finish();

All the above works if TryRun is used instead of my own TryWine. The C code for the test programs is not in SConstruct but is stored and loaded in a separate file (sysdep.py), as you can see in the dump below.

I get the following error:

IndexError: list index out of range:
File "/Users/patrickw/my_project/SConstruct", line 331:
File "../scons_base/lib/scons-2.2.0/SCons/SConf.py", line 640:
ret = self.test(context, *args, **kw)
File "/Users/patrickw/my_project/sysdep.py", line 55:
result = result[1].split();
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/UserList.py", line 31:
def __getitem__(self, i): return self.data[i]

Obviously the result from TryWine is stored differently than the one from TryRun, but I don't see why. This is probably caused by my somewhat limited knowledge of scons and python and because I inherited all this code that I did not wrtite myself. I tried to debug it with --debug=pdb but that does not show me what I am doing wrong.

Do you have some advice?



More information about the Scons-users mailing list