Rebar: user defined macro

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Rebar: user defined macro

Zabrane Mickael
Hi guys,

I've this in my makefile:

compile:
        @$(REBAR) compile -Dfoo=17


I want to get the value of 'foo' (which is 17) inside my Erlang code.

-ifndef(foo).
-define(foo, 'unknown').
-endif.

But 'foo' is never defined.

How can I defined macro with value using rebar?

Regards,
Zabrane


_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: Rebar: user defined macro

bryan-basho
Administrator
On Fri, Nov 2, 2012 at 5:17 PM, Zabrane Mickael <[hidden email]> wrote:
> I've this in my makefile:
>
> compile:
>         @$(REBAR) compile -Dfoo=17
...snip...
> How can I defined macro with value using rebar?

Hi, Zabrane.

It looks to me like the command line -D option for rebar does not
support defining values for macros. The makefile line above causes
rebar to define the 'foo=17' macro, not a macro 'foo' with value 17.

I think the only way to do what you want is by adding 'd' tuples to
your 'erl_opts' list in your rebar.config:

    {erl_opts, [{d, foo, 17}]}.

The rebar mailing list may have better answers:
http://lists.basho.com/mailman/listinfo/rebar_lists.basho.com

-Bryan

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: Rebar: user defined macro

Zabrane Mickael
Thx Bryan, found it during the weekend ;)

Regards,
Zabrane

On Nov 5, 2012, at 4:45 PM, Bryan Fink wrote:

> On Fri, Nov 2, 2012 at 5:17 PM, Zabrane Mickael <[hidden email]> wrote:
>> I've this in my makefile:
>>
>> compile:
>>        @$(REBAR) compile -Dfoo=17
> ...snip...
>> How can I defined macro with value using rebar?
>
> Hi, Zabrane.
>
> It looks to me like the command line -D option for rebar does not
> support defining values for macros. The makefile line above causes
> rebar to define the 'foo=17' macro, not a macro 'foo' with value 17.
>
> I think the only way to do what you want is by adding 'd' tuples to
> your 'erl_opts' list in your rebar.config:
>
>    {erl_opts, [{d, foo, 17}]}.
>
> The rebar mailing list may have better answers:
> http://lists.basho.com/mailman/listinfo/rebar_lists.basho.com
>
> -Bryan




_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com