Significado de? = e ?? = em bitbake / yocto

1

O que os diferentes tipos de atribuição significam em scripts de receita bitbake, como:

 BB_NUMBER_THREADS  ?=  "${@oe.utils.cpu_count()}"
 PARALLEL_MAKE  ?=  "-j ${@oe.utils.cpu_count()}"
 MACHINE    ??= "qemux86"

O que está acima é análogo ao bb_number_threads ||= 'something' ? do Ruby?

    
por Frankie_Fomalhaut 10.07.2015 / 10:53

1 resposta

5

De acordo com este

? = é:

You can use the "?=" operator to achieve a "softer" assignment for a variable. This type of assignment allows you to define a variable if it is undefined when the statement is parsed, but to leave the value alone if the variable has a value. Here is an example:

A ?= "aval"

If A is set at the time this statement is parsed, the variable retains its value. However, if A is not set, the variable is set to "aval".

?? = é:

It is possible to use a "weaker" assignment than in the previous section by using the "??=" operator. This assignment behaves identical to "?=" except that the assignment is made at the end of the parsing process rather than immediately. Consequently, when multiple "??=" assignments exist, the last one is used. Also, any "=" or "?=" assignment will override the value set with "??=". Here is an example:

 A ??= "somevalue"
 A ??= "someothervalue"

If A is set before the above statements are parsed, the variable retains its value. If A is not set, the variable is set to "someothervalue".

Again, this assignment is a "lazy" or "weak" assignment because it does not occur until the end of the parsing process.

    
por 10.07.2015 / 13:35