[Scons-users] custom builder for use with wine

Dirk Bächle tshortik at gmx.de
Mon Aug 19 14:36:42 EDT 2013


Patrick,

thanks a lot for your example. Hacking around a little, I found a
solution that works (see attached file)...but doesn't look very pretty.
The problem is that all custom defined tests get called as a
CheckContext, which sort of wraps the actual SConfBase class.

This is the reason why simply adding "TryWine" to "SConfBase" is not
enough, you have to provide the delegate method for "CheckContext" too.

Regards,

Dirk


-------------- next part --------------
import SCons.SConf
import os

def my_test(conf):
conf.Message("Checking hello world: ");
result=conf.TryWine(my_test.prog,".c")
#result=conf.TryRun(my_test.prog,".c")
if(not(result[0])):
return(False);
print result[1];
conf.Result("yes, it works!");
return(True);

my_test.prog = r"""
#include <stdio.h>
int main(void)
{
printf("Hello World\n");
return 0;
}
"""

def TryWine(self, text, extension):
ok = self.TryLink(text, extension);
if( ok ):
prog = self.lastTarget;
pname = prog.path;
#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, "");


SCons.SConf.SConfBase.TryWine = TryWine


def CheckContextTryWine(self, *args, **kw):
return self.sconf.TryWine(*args, **kw)

SCons.SConf.CheckContext.TryWine = CheckContextTryWine


env = Environment();
conf = Configure(env, custom_tests = {'my_test' : my_test});
#conf.TryWine = ConfTryWine
print conf.my_test();
env = conf.Finish();



More information about the Scons-users mailing list