[Omake] help not exporting the loop variable?

Aleksey Nogin nogin at metaprl.org
Tue Jan 9 09:49:07 PST 2007


On 08.01.2007 21:24, Erick Tryzelaar wrote:

> I'm now running into a scoping issue with .PHONY targets. I'd like to do 
> something like this:
> 
> foreach(x, a b)
>   echo loading  $x
>   package. =
>       include $x
>   register-package($(package))
>   .PHONY: $(package.name)
>   echo
>   export packages
> 
> But I'm not sure how to export the $(package.name). I tried "export 
> packages $(package.name)" but that didn't work. Doing a full "export" 
> works though. Is there a way to do this?

Note that it's not the $(package.name) that you want exported here, but 
the "phony state". There is an undocumented (bug 625) form "export 
rules" that exports all the implicit rules and phony targets, but, 
unfortunately, it can not be combined with the "export vars" form (bug 626).

I would suggest something like:

phonies[] =
foreach(x, a b)
    echo loading  $x
    package. =
       include $x
    register-package($(package))
    phonies[] += $(package.name)
    echo
    export packages phonies
.PHONY: $(phonies)

or even

foreach(x, a b)
    echo loading  $x
    package. =
       include $x
    register-package($(package))
    echo
    export packages

foreach(package, $(packages))
    .PHONY: $(package.name)
    export rules

Aleksey


More information about the Omake mailing list