[Scons-users] Merging Environments, Revisited!

Brian Cody brian.j.cody at gmail.com
Mon Mar 30 12:11:19 EDT 2015


This is a timely response to this message, and I'm asking for help:


Gary Oberbrunner-: Aug 05, 2011; 1:39pm Re: Merge two environments?
How would you like them combined?  Replace?  Append?  Merge?  Think
about something like LIBS or CPPDEFINES which are themselves lists or
dicts, or other vars which are python functions.  Anyway, whatever
scheme you like could be implemented because you can treat an env just
like a dict: iterate over its members and do whatever you like to each
one.

On Fri, Aug 5, 2011 at 7:16 AM, Julius Ziegler <[hidden email]> wrote:

> Hello,
>
> I wonder if there is a systematic way to merge all the flags contained
> in two Environments?
>
> I would like to do somehting like this (random example):
>
> env_Qt  = ... # setup an environment for building Qt stuff
> env_png = ... # setup an environment for building something that uses
libpng
>
> env_Qt_png = env_Qt.Clone()
> env_Qt_png.MergeFlags(env_png) # have an environment which combines both
>
> The last call of course does not work, since it expects either a gcc-ish
> string ("-lpng"), or a dictionary.
>
> Is there a canonic way to achieve this?
>
> Thanks!
> Julius



In this case I have a helper function to set up an environment for Xilinx.
I have a helper function to set up an environment for Modelsim. These are
used separately (Xilinx for building projects, Modelsim for running tests
on code) and there are input variables into each. To properly test with
Xilinx built-ins, there is a step where you invoke Xilinx to invoke
Modelsim to compile Xilinx's built-ins for simulation. I want to have a
helper that takes a Xilinx environment and a Modelsim environment and spits
out an environment suitable for that particular combination of the tools
and settings. I'd like the helper to know the bare minimum of the internals
of those environments so when something needs to change, there's the least
amount of work possible.

In the post above, Gary mentioned that you can treat the environments like
a dictionary. The way to combine two dictionaries is usually (depending on
what you want to do with the collisions):
new_dict = dict1.copy()
new_dict.update(dict2)

This doesn't actually work though. The environments are not dictionary-like
enough to have a copy() method. Could someone suggest an alternative? If I
had this behavior, I think the only other step I'd need to do would be to
manually modify the path variable.

Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20150330/78f560f5/attachment.html>


More information about the Scons-users mailing list