[Rake-devel] make like variables?
ittay.dror at gmail.com
Sat Sep 6 13:18:47 EDT 2008
Jim Weirich wrote:
> On Sep 6, 2008, at 2:21 AM, Ittay Dror wrote:
>> in make, if in my Makefile I have
>> FOO = 1
>> FOO += 2
>> echo $(FOO)
>> then running:
>> > make
>> 1 2
>> > make FOO=3
>> That is, if passed in the command line, any assignments to FOO are
>> ignored. In Makefile, this can be changed by using the 'override'
>> method. It is not that important, just an idiom that people coming
>> from Make expect. Obviously, Rakefile being Ruby this sort of
>> behavior can be done.
> I think if I had to do this, I would use an idiom like:
> ENV['FOO'] ||= 1
yes, but then ENV['FOO'] += 1 will increase FOO by one, which is not the
> I really don't have control over how ruby variables are assigned. I'm
> not sure how to do it in rake for any arbitrary variable.
I didn't mean to do it for arbitrary variables, instead, accessing
variables through an object that controls the behavior.
I don't think this in itself (mimicking the exact behavior of Make) is
worth the hassle, but providing a nicer interface to dealing with
command line variables might be, for example, if the object controlling
variables also knows how to handle 'FOO+=a' and 'FOO-=b' in the command
line, it could be a nice feature, mainly for C/C++ builds.
If you like, since I need such behavior anyway, I can post it when it is
Ittay Dror <ittay.dror at gmail.com>
More information about the Rake-devel