[Omake] help not exporting the loop variable?
Aleksey Nogin
nogin at metaprl.org
Sun Jan 7 10:06:13 PST 2007
On 05.01.2007 10:30, Erick Tryzelaar wrote:
> I'm running into an issue using some non-standard omake-style coding.
> I'm investigating porting our custom package based build system over to
> omake, and I'm running into an odd problem. Here's my code:
Erik, there seem to be several minor problems in your code - each is
pretty harmless, but they add up together.
> OMakefile:
> packages. =
> extends $(Map)
>
> register-package(package) =
> echo register $(package.name)
> packages = $(packages.add $(package.name), $(package))
> export
Note that the above "export" call will export the full environment - and
that includes not only the "packages" variable that was explicitly
modified, but the "package" variable that was passed in as an argument!
You might want to change it into an explicit "export packages" (this
would be sufficient to correct the problem).
> foreach(x, a.om b.om)
> echo loading $x
> include $x
> echo
> export
Depending on what you expectations are, you might want to be careful
with the export here as well. Note that "include" will propagate all the
environment changes from the included file. Do you want the package "b"
to be affected by all the variable definitions and implicit rule from
package "a"? If not, then you need to either:
- put the include line into a section
- change the "export" into something like "export packages"
>
> a.om:
> private.package. =
> name = a
> register-package($(package))
>
>
> b.om:
> private.package. =
> name = b
> register-package($(package))
Note that the last line above is equivalent to
register-package($(public.package))
which means that the $(private.package) that you've just defined will
only get used if the $(public.package) does not exist. (BTW, this is
supposed to change in 0.9.9 to be a bit saner).
> Also, any tips on a better way of doing what I'm doing?
First, minor comment: the .om suffix is assumed and you do not have to
use it explicitly in "include" statements.
Will every package file always add a single package? If so, then I'd
suggest moving the register-package call into the foreach loop:
OMakefile:
...
foreach(x, a b)
echo loading $x
name = $"Default package name" # Optional
include $x
package. =
name = $(name)
register-package($(package))
echo
export packages
a.om:
name = a
b.om:
name = b
P.S. In a somewhat similar situation in MetaPRL, we use "MetaprlInfo"
files (that define MetaPRL "theories" - somewhat similar to your
packages) that each only define a bunch of variables and the "central"
code that reads all of those info file will use the variable values to
do the actual work. See the big section block at the end of
http://svn.metaprl.org/viewvc/*checkout*/mojave/metaprl/OMakefile_theories
if interested.
Aleksey
More information about the Omake
mailing list