[Omake] scoping rules/export for subdirs

Christopher L Conway cconway at cs.nyu.edu
Fri May 25 14:06:36 PDT 2007


Is it possible to export a variable from a subdir to the parent? E.g.,
I'd like to be able to pass "accumulator" variables into subdirs, as
in the following:

OMakefile:
GLOBALVAR[] = foo
println("In foo: GLOBALVAR=$(string $(GLOBALVAR))")

section
    GLOBALVAR += section
    println("In section: GLOBALVAR=$(string $(GLOBALVAR))")
    export GLOBALVAR

println("In foo, after section: GLOBALVAR=$(string $(GLOBALVAR))")

.SUBDIRS: bar
println("In foo, after bar: GLOBALVAR=$(string $(GLOBALVAR))")
---

bar/OMakefile:
GLOBALVAR += bar
println("In bar: GLOBALVAR=$(string $(GLOBALVAR))")
export GLOBALVAR

My expectation was that subdir scope would behave like any other
scope. But the result I get is:

$ omake
*** omake: reading OMakefiles
In foo: GLOBALVAR=foo
In section: GLOBALVAR=foo section
In foo, after section: GLOBALVAR=foo section
In bar: GLOBALVAR=foo section bar
In foo, after bar: GLOBALVAR=foo section
*** omake: finished reading OMakefiles (0.0 sec)
*** omake: done (0.0 sec, 0/0 scans, 0/0 rules, 1/37 digests)

What i'd like is:
In foo, after bar: GLOBALVAR=foo section bar

I thought I might get around this with a function in the top-level
scope, as follows:

OMakefile:
GLOBALVAR[] = foo
println("In foo: GLOBALVAR=$(string $(GLOBALVAR))")

add_to_globalvar(x) =
    GLOBALVAR += $(x)
    export GLOBALVAR

.SUBDIRS: bar
println("In foo, after bar: GLOBALVAR=$(string $(GLOBALVAR))")
---

bar/OMakefile:
add_to_globalvar(bar)
println("In bar: GLOBALVAR=$(string $(GLOBALVAR))")
export GLOBALVAR

But it does the same thing.

$ omake
*** omake: reading OMakefiles
In foo: GLOBALVAR=foo
In bar: GLOBALVAR=foo bar
In foo, after bar: GLOBALVAR=foo
*** omake: finished reading OMakefiles (0.0 sec)
*** omake: done (0.0 sec, 0/0 scans, 0/0 rules, 9/37 digests)

Is there a way to accomplish this?

Thanks,
Chris


More information about the Omake mailing list