[Scons-users] Building SDL 2 with SCons on Linux
    Davide Coppola 
    vivaladav at gmail.com
       
    Fri Mar 14 11:17:44 EDT 2014
    
    
  
Hey Dirk,
I'm glad you appreciated the post, thanks.
I have indeed a few comments, especially regarding your usage of the
> variant_dir feature.
>
> 1.) If your projects get bigger and you would perhaps like to create
> several (all?) variants with *one* call of SCons, here's what you could
> change: Create another SConscript, right beside your top-level SConstruct.
> It only contains the includes to the lower directories, so:
>
>   Import('env')
>   SConscript('src/libs/SDL2/SConscript', exports = 'env', variant_dir =
> 'build/' + env['mode'], src_dir = 'src', duplicate = 0)
>   SConscript('src/game/SConscript', exports = 'env', variant_dir =
> 'build/' + env['mode'], src_dir = 'src', duplicate = 0)
>
> Then, set up single environments for the variants you'd like to create in
> your SConstruct:
>
>   env = Environment(variables = vars)
>   debugEnv = env.Clone()
>   debugEnv.Append(CCFLAGS = ['-Wall', '-g', '-O0', '-DDEBUG'])
>   debugEnv['mode'] = 'debug'
>
>   ...
>   profileEnv = env.Clone()
>   profileEnv.Append(CCFLAGS = ['-Wall', '-pg', '-O0', '-DNDEBUG'])
>   profileEnv['mode'] = 'profile'
>
> Now, you can do things like
>
>   mode_env = {'debug' : debugEnv,
>                          'release' : releaseEnv,
>                          'profile' : profileEnv}
>   for m in mode_env:
>     SConscript('SConscript', exports={'env' : mode_env[m]})
>
> and get all variants at once.
>
I was aware of that (I probably saw something similar on the wiki), but I
prefer to be able to control which build is created at any time.
I'll keep your solution in mind though, as I could change my mind at some
point!
> 2.) As another minor point, in the SConscripts you create localEnvs via
> Clone(). This is okay, but when you then call localEnv.Program() (or any
> other builder that is defined within the localEnv environment) and
> additionally give parameters like LIBPATH to this call, this means that
> internally another Environment (a so called OverrideEnvironment) gets
> created.
> Doesn't really hurt, but it's actually unnecessary. You don't use the
> localEnv for anything else, so just set it up completely like for the other
> variables:
>
>   localEnv.Append(CPPPATH=['#/src/libs/SDL2/include'])
>   localEnv.Append(CCFLAGS = ['-D_REENTRANT'])
>   localEnv.Append(LINKFLAGS=['-Wl,--no-undefined'])
>   localEnv.Append(LIBS=['SDL2', 'pthread', 'm', 'dl', 'ts', 'pthread',
> 'rt'])
>   localEnv.Append(LIBPATH=['../libs/SDL2'])
>
Wow, I wasn't aware of that!
I changed my scripts and updated the blog post with your suggestion, thanks
> Finally, feel free to add your project as snippet to our Wiki, under the
> "Recipes" section ( http://www.scons.org/wiki/SconsRecipes ) . We can
> always use more good examples like this one.
>
I'd like to, but the WIKI doesn't allow me to create an account... I get
the following error message when I try: "Unknown action newaccount."
Could you or someone else fix that?
Thanks again
-- 
Davide Coppola
*email:* vivaladav at gmail.com
*website:* http://www.davidecoppola.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20140314/e4ddf740/attachment.htm 
    
    
More information about the Scons-users
mailing list