[Scons-users] Conditional process

William Blevins wblevins001 at gmail.com
Sun Jan 25 10:54:29 EST 2015


Tobbe,

I'm not sure why you would want/need to do this, so there may be a better
way to achieve your "end goal" if we knew the "why" question.

Consider creating aliases for target creation sets, and simply call "scons
<target_alias>" on the command line.  Keep in mind that SCons will also
build all the necessary dependencies, so SCons may build other targets if
necessary.

Alias information: http://www.scons.org/doc/HTML/scons-user/ch25.html

V/R,
William

On Sun, Jan 25, 2015 at 9:48 AM, Sven Lars Tobias Stål <smp428 at alumni.ku.dk>
wrote:

> Dear all,
>
> I’m using SCons to build work flows of Madagascar programs (
> http://www.ahay.org). I’m new to SCons, so sorry for asking basic
> questions. I’m grateful for any advice.
>
> I’d like to build files differently based on a variable.
>
> I could easily make a Python script, using os or subprocess to achieve the
> wanted result, but I’d like to use SCons and implement this process in a
> larger flow. The loop goes through all file names, check a variable from a
> list, SN, if it’s 2 it adds the following file and skips i+1. If the
> variable is 4, it adds the there following files and jump to the file after.
>
> i = 0
> while i < len(fL):
>         shutil.copy2('t'+ fL[i]+'.rsf', iN + fL[i]+'.rsf') #Select trace
> header files
>         shutil.copy2('t'+ fL[i]+'.rsf@', iN + fL[i]+'.rsf@')
>         sL.append(iN + fL[i] + '.rsf')
>         if SN[i] == 2:
>                 os.popen('sfadd < '+ fL[i] + '.rsf ' + fL[i+1] + \
>                 '.rsf scale=1,1 > ' + iN + fL[i] + '.rsf').read()
>                 i += 2 #Jump to next file
>         elif SN[i] == 4:
>                 os.popen('sfadd < '+ fL[i] + '.rsf ' + fL[i+1] + '.rsf ' +
> fL[i+2] + \
>                 '.rsf ' + fL[i+3] + '.rsf scale=1,1,1,1 > ' + iN + fL[i] +
> '.rsf').read()
>                 i += 4 #Jump to next file
>         else:
>                 print('Unspecified stack %s' % fL[i]) #Or error
>
> Alternatively, how can I call a python script from SCons so that the input
> is defined (all files in fL list) but the output depends on the conditional
> result from the script.
>
> Regards
> Tobbe
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20150125/b7e1977f/attachment.html>


More information about the Scons-users mailing list