[Scons-users] custom builder for use with wine

Dirk Bächle tshortik at gmx.de
Fri Aug 16 12:39:46 EDT 2013


Hi Patrick,

On 16.08.2013 11:01, Patrick.Wambacq at esat.kuleuven.be wrote:

> 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.

>

> [...]

> I get the following error:

>

> IndexError: list index out of range:

> File "/Users/patrickw/my_project/SConstruct", line 331:

> setattr(my_project,check,getattr(conf,check)());

> 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]

>

> [...]

> Do you have some advice?


can you please try to add your TryWine() method to the configure context
instead of the environment? Note how you have the "env" as build
environment, which has all the builders and stuff...and your configure
context "conf" for this environment.

Both support different sets of functions, and have different return
values. While a builder in SCons usually returns the targets it creates
(as Nodes), the configure methods return either a "0|1" (TryLink) or a
tuple like (0, '') for TryRun.

You should be able to get it running by using something along the lines of:

conf = env.Configure(custom_tests={'TryWine' : TryWine})
result = conf.TryWine(some_test_program,".c")
if(not(result[0])):
return(compiler_failure(conf))
result = result[1].split()

Please, also have a look at the MAN page of SCons. In the section
"Configure Contexts" it contains a simple example for how to add your
own configure checks.

Best regards,

Dirk



More information about the Scons-users mailing list