[PATCH] eng: Add build system chapter

Chris Johns chrisj at rtems.org
Tue Nov 12 21:43:25 UTC 2019


On 12/11/19 5:05 pm, Sebastian Huber wrote:
> On 11/11/2019 23:29, Chris Johns wrote:
>> On 11/11/19 8:45 pm, Sebastian Huber wrote:
>>> On 08/11/2019 23:48, Chris Johns wrote:[...]
>>>> 3. Is the ${} expansion something you have implemented? It is a nice feature.
>>> [...]
>>>
>>> With standard Python the substitution itself is a one liner:
>>>
>>>      def substitute(self, ctx, value):
>>>          if isinstance(value, str):
>>>              try:
>>>                  return Template(value).substitute(ctx.env)
>>>              except Exception as e:
>>>                  ctx.fatal(
>>>                      "In item '{}' substitution in '{}' failed: {}".format(
>>>                          self.uid, value, e
>>>                      )
>>>                  )
>>>          return value
>>>
>>
>> Does this support nested defines?
> 
> You mean something like this:
> 
> Python 2.7.14 (default, Oct 12 2017, 15:50:02) [GCC] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import string
>>>> d={"a":"x","b":"y","c":"${a}${b}"}
>>>> t=string.Template("${c}")
>>>> t.substitute(d)
> '${a}${b}'
>>>>
> 
> ?
> 
> Apparently, the Template.substitute() doesn't work recursively.

Yes.

> The variables used for the substitution are the configuration set environment
> variables. I intentionally didn't add a recursive substitution since you should
> specify the variable definitions in a proper order.

And if there are competing orders? It all depends on how the declared variables
are used, where they are used and how many times.

>> The RSB and rtemstoolkit macros recursively expand as it was a something I found
>> needed and useful ...
>>
>> https://git.rtems.org/rtems-tools/tree/rtemstoolkit/macros.py#n471
> 
> I think we should keep it simple in the build system right now. If there is a
> real need, then we can have a look at this.

Sure as long and this is an option and we do not unrolling items to avoid it. It
can be viewed as an abstraction tool, eg x is defined by m and n, m is defined
by a and b, n is defined by c and d and then y is defined by n and o where o is
something else.

Personally I would add the feature rather than needing to revisit this part of
the code later. A new build system is not just a replacement task for what is
there fitted to be a close match. It should be considered a framework that needs
to grow and adapt as we find new ways to use it and RTEMS. Ten plus years of the
RSB has taught me people will work with what you provide rather than step inside
the tool and make a change even if what they have to do is bad.

Chris


More information about the devel mailing list