subport syntax clarification
Ryan Schmidt
ryandesign at macports.org
Sat Jan 14 15:07:01 PST 2012
On Jan 14, 2012, at 16:58, Joshua Root wrote:
> On 2012-1-15 09:03 , Ryan Schmidt wrote:
>> I get the impression that the following two blocks are equivalent. Is this true?
>>
>>
>> if {${name} == ${subport}} {
>> ...
>> }
>>
>>
>> subport ${name} {
>> ...
>> }
>>
>>
>> I've been using the former sometimes, but I think the latter is more succinct and I might try that instead, unless there's a reason not to.
>
> Not entirely; the latter also adds to the set of known subports. (I also
> wonder why you specifically use ${name} in your question?)
I specifically used ${name} in my question because ${name} is already indexed as a port, so there's no difference if I also make it a subport.
I understand that the above would be different if I didn't use ${name}. For example if I write:
name foo
subport bar {}
I understand that both foo and bar get indexed as ports whereas if I write:
name foo
if {${subport} == "bar"} {}
then only foo is indexed as a port.
Other than that difference, however, that they seem to be equivalent. subports aren't like variants that are processed after the main body of the port. They're like platform statements now, they're processed inline right where they are, just like an "if" statement.
More information about the macports-dev
mailing list