[Scons-users] Custom Builder Problems

Dirk Bächle tshortik at gmx.de
Thu Dec 19 20:40:39 EST 2013

Hi Sean,

On 20.12.2013 01:16, Sean McCauliff wrote:

> Hi I'm new to Scons. Sorry if this has been asked before.


and welcome. :)

> I'm trying to create a custom builder for mex files. These are shared

> libraries that are then linked into Matlab at run time. I've run into

> one or two custom builders for mex files but I'm not able to get them

> to work so I decided I would just write my own.


> I want to be able to check if the user wanted to build in optimized or

> debug mode and then set the correct flags for the 'mex' executable

> (the thing that is going to build the mex file). It's a little unclear

> how build variables are propagated to the builders.

Usually you'd setup the command string of your Action for the Builder as
something like

mex_build = SCons.Builder.Builder(action='$MEX $MEXFLAGS -o $TARGET

. Note, I'm just guessing here...I have absolutely no idea how to call
"mex" properly. The basic idea with this is, to then
assign the env['MEXFLAGS'] to what you want it to be. Either fixed for a
specific folder in your project, or depending on a command-line option.

When trying to write a Builder, you might want to check out


, if you haven't already done so.

Please show us the full source code of your current Builder, or give an
URL to its public repo (github/bitbucket). Like this, we can help you
much better.

> If I do env['LIBS'] I get a list of additional libraries to link with,

> but I don't see my 'compileMode' variable there. My other problem is

> that env['CPPPATH'] contains a list of additional include paths, but

> one of them is specified with a '#' that I thought would automatically

> resolve to the path of the SConstruct file. This turns out not to be

> the case and the '#' character is then included as part of the action.


Again, I'd like to see the source for this.

Best regards,


More information about the Scons-users mailing list