Discussion:
fileList does not seem to expand variables
(too old to reply)
Sebastian Schuberth
2008-08-06 14:47:28 UTC
Permalink
Raw Message
Hi,

I'm new to Bakefile (and to Python) and want to start off by porting a small CMake project. I'm having some problems with the following file:

<?xml version="1.0"?>

<makefile>

<set var="PROJECT_NAME">gale</set>

<set var="BUILD_ROOT">..</set>
<set var="HEADER_ROOT">$(BUILD_ROOT)/include</set>
<set var="SOURCE_ROOT">$(BUILD_ROOT)/source</set>
<set var="GLEX_ROOT">$(BUILD_ROOT)/glex</set>

<lib id="$(PROJECT_NAME)">
<headers>$(fileList(["$(HEADER_ROOT)/gale/math/*.h",'$(HEADER_ROOT)/*.inl']))</headers>
<sources>$(SOURCE_ROOT)/*.cpp</sources>
<include>$(HEADER_ROOT) $(GLEX_ROOT)</include>
<sys-lib></sys-lib>
<libname>$(BUILD_ROOT)/lib/$(PROJECT_NAME)</libname>
</lib>

</makefile>

It seems fileList() does not expand $(HEADER_ROOT):

[dbg] condition 'BUILDDIR=='.'' for variable '_builddir' is always met
fileList('$(HEADER_ROOT)/gale/math/*.h'): matches for ...

If I replace $(HEADER_ROOT) with the actual directory, it works. What am I doing wrong?

Thanks.
--
Sebastian Schuberth
Vaclav Slavik
2008-08-06 15:03:38 UTC
Permalink
Raw Message
Hi,
Post by Sebastian Schuberth
<headers>
$(fileList(["$(HEADER_ROOT)/gale/math/*.h",'$(HEADER_ROOT)/*.inl']))
</headers>
...
Because you're trying to double-expand it. $(expr) substitutes the value
of expr, which is a Python expression (or a variable reference, which is
just a special case of Python expression). You wouldn't try to reference
a variable as $($(FOO)) either. Furthermore, the $(HEADER_ROOT) uses are
inside quotes, so it's a string _literal_.

What you want to do is this:

$(fileList([HEADER_ROOT"+/gale/math/*.h",HEADER_ROOT+"/*.inl"]))

Regards,
Vaclav
Sebastian Schuberth
2008-08-06 15:28:52 UTC
Permalink
Raw Message
Post by Vaclav Slavik
Post by Sebastian Schuberth
<headers>
$(fileList(["$(HEADER_ROOT)/gale/math/*.h",'$(HEADER_ROOT)/*.inl']))
</headers>
...
Because you're trying to double-expand it. $(expr) substitutes the value
of expr, which is a Python expression (or a variable reference, which is
just a special case of Python expression). You wouldn't try to reference
a variable as $($(FOO)) either. Furthermore, the $(HEADER_ROOT) uses are
inside quotes, so it's a string _literal_.
$(fileList([HEADER_ROOT"+/gale/math/*.h",HEADER_ROOT+"/*.inl"]))
Thanks a lot, that works.

For my better understanding, the doc page at http://www.bakefile.org/doc/ch08.html reads as if only the Python functions listed there can be called by Bakefile ... I guess this actually is not true, but in fact any core function of the Python language can be called, the listed functions only being additional convenience functions, correct?
--
Sebastian Schuberth
Vaclav Slavik
2008-08-10 00:04:24 UTC
Permalink
Raw Message
Post by Sebastian Schuberth
For my better understanding, the doc page at
http://www.bakefile.org/doc/ch08.html reads as if only the Python
functions listed there can be called by Bakefile ...
Should be fixed now, thanks.

Vaclav

Loading...