Discussion:
variable not defined on my own define-rule
(too old to reply)
Jeremy Cowgar
2009-09-12 15:12:07 UTC
Permalink
I am having problems setting up my own define rule. The problem I have is that
bakefile says: "error: failed to set variable '__s' to value '$(__source)':
name '__source' is not defined"

The rule I have created is:

<define-rule name="euphoria" extends="action">
<template>
<is-phony />
<set var="__build_dir">$(id)_dir</set>
<set var="__output">..$(DIRSEP)$(id)$(EXE_EXT)</set>
<set var="__lib">..$(DIRSEP)eu$(LIB_EXT)</set>
<set var="__include">..$(DIRSEP)include</set>
<command>eui ec.ex -con $(EUC_FLAGS) -i $(__include) -builddir
$(__build_dir) -keep -o $(__output) -lib $(__lib) $(__source)</command>
<dependency-of>all</dependency-of>
</template>
<define-tag name="source">
<set var="__source">$(value)</set>
</define-tag>
</define-rule>

An example use of the rule is:

<euphoria id="eui">
<source>int.ex</source>
</euphoria>

Can anyone shed some light on what I am doing wrong?

Thanks,

Jeremy
Vaclav Slavik
2009-09-13 13:09:25 UTC
Permalink
Post by Jeremy Cowgar
Can anyone shed some light on what I am doing wrong?
Using (in a template) a variable before defining it (in target's body,
after the template was processed). Hence "...is not defined" error.

Vaclav
Jeremy Cowgar
2009-09-13 22:45:09 UTC
Permalink
Post by Vaclav Slavik
Post by Jeremy Cowgar
Can anyone shed some light on what I am doing wrong?
Using (in a template) a variable before defining it (in target's body,
after the template was processed). Hence "...is not defined" error.
Um I gathered that. I was assuming I would get a response on how to fix it, but
I guess that's not exactly what I asked, although it could very well be
assumed. So, I'll ask...

How do I fix it?

Jeremy
Vaclav Slavik
2009-09-14 07:48:51 UTC
Permalink
Post by Jeremy Cowgar
Post by Vaclav Slavik
Using (in a template) a variable before defining it (in target's body,
after the template was processed). Hence "...is not defined" error.
Um I gathered that.
Wasn't quite clear from what you wrote...
Post by Jeremy Cowgar
I was assuming I would get a response on how to fix it, but
I guess that's not exactly what I asked, although it could very well be
assumed.
I kind of assumed that the way to fix it is obvious: don't use variables
before you define them (IOW, don't create the command line until you
collected the sources information). Or, to put it the other way, define
them before you use them (i.e. define __source at the top of the
template).

Your best bet probably is to define __source as empty first, then put
the command into a variable set with <set var="my_cmd"
eval="0">...$(__source)...</set> and then use
<command>$(my_cmd)</command>. That should do what you want.

Vaclav
Jeremy Cowgar
2009-09-14 13:30:46 UTC
Permalink
Post by Vaclav Slavik
Your best bet probably is to define __source as empty first, then put
the command into a variable set with <set var="my_cmd"
eval="0">...$(__source)...</set> and then use
<command>$(my_cmd)</command>. That should do what you want.
Ah! Ok, that did the trick. Defining it empty and also putting eval="0".
Previously, I did try adding it as empty but I didn't have eval="0". The
__source was always empty then, regardless of the fact that the target having
<source>...</source>.

Thanks!

Jeremy

Loading...