[Omake] Testing whether a target has been defined
Jason Hickey
jyh at cs.caltech.edu
Sun Jun 18 20:27:06 PDT 2006
malc wrote:
...
>>> <OMakeroot>
>>> .SUBDIRS: .
>>> old-rule = $(rule)
>>> rule(p1, p2, p3, p4, p5, p6) =
>>> old-rule($(p1), $(p2), $(p3), $(p4), $(p5), $(p6))
>>> export
>>> a: :value: $`(println $@)
>>> touch $@
>>> .DEFAULT: a
>>> </OMakeroot>
...
> Btw. is it possible to extend p6(body) somehow, my naive attempts have
> been unsuccessful.
Wow, that makes a lot of sense. Here is a trick that will work--but I
think we should consider adding something simpler to OMake.
get-body(x) =
value $x
rule(multiple, target, pattern, sources, options, body) =
XTARGETS[] += $(target)
x =
get-body()
apply($(fun $(body)))
echo XXX
old-rule($(multiple), $(target), $(pattern), $(sources),
$(options), $x)
export
The idea: when an an application has a body, the body is passed to the
function as its first argument. For example, consider the expression.
get-body()
echo Hi
echo Bye
This evaluates to the body "echo Hi; echo Bye".
Similarly, the fun function takes a body as its first argument. So
$(fun $(body)) is a function of 0 arguments with body $(body), and the
apply(...) applies the function.
I've attached a complete OMakefile. I admit it is a bit crazy:b
Jason
--
Jason Hickey http://www.cs.caltech.edu/~jyh
Caltech Computer Science Tel: 626-395-6568 FAX: 626-792-4257
-------------- next part --------------
old-rule = $(rule)
XTARGETS[] =
append-body(x) =
value $x
rule(multiple, target, pattern, sources, options, body) =
XTARGETS[] += $(target)
new-body =
append-body()
apply($(fun $(body)))
echo Second line >> $@
old-rule($(multiple), $(target), $(pattern), $(sources), $(options), $(new-body))
export
a:
echo Building the program $@
echo First line > $@
println($"Targets: $(XTARGETS)")
More information about the Omake
mailing list