Parse transform and dependencies

Alessandro Sivieri alessandro.sivieri at gmail.com
Mon Feb 27 06:09:23 EST 2012


Ok, I will try it soon; thank you!

On Sat, Feb 25, 2012 at 12:54 AM, Tim Watson <watson.timothy at gmail.com>wrote:

> You don't need to move the parse_transform source at all. Instead, I
> think you'll find this can be done with the following steps. Firstly,
> you want to make sure that the compiler (that is to say, the compile
> module in stdlib) can 'find' the parse transform in the first place.
> Now this requires the following two things
>
> 1. the beam is on the code path during compilation
> 2. the header file via which you include the parse transform can be
> located when you do -include_lib(....)
>
> The first item is dealt with by rebar. After you run `rebar get-deps
> compile` the beams for the dependency should be on the code path for
> every future command. In theory this means that the parse_transform
> module should already be on the code path by the time your application
> modules are being compiled.
>
> The second item only matters if you're including the parse_transform
> in your application (not framework) modules by header inclusion. If
> you are doing that, then you need to add the following line to your
> (application) project's rebar config:
>
> {lib_dirs, ["deps"]}.
>
> This ensures that when the compile module is doing its work and the
> '-include_lib(...)' instruction is being processed, calls made by the
> compiler to resolve the location of the include file (probably using
> code:lib_dir) actually work.
>
> If you want *every* file in your application to be processed using the
> parse_transform however, then I'd suggest another approach. Set the
> parse_transform up in the erl_opts (compiler options) section of your
> rebar config. This would look something like
>
> {erl_opts, [{parse_transform, my_parse_transform}|MoreCompilerOptions]}.
>
> Hope that helps.
>
> Cheers,
>
> Tim
>
> On 24 February 2012 22:44, Alessandro Sivieri
> <alessandro.sivieri at gmail.com> wrote:
> > Hi all,
> >
> > I'm trying to write the configuration file for a framework that I'm
> writing,
> > and I have a doubt that I hope you can clarify. An application written
> with
> > this framework should have the following structure:
> >
> > myapplication/
> > |     src/*.erl
> > |     ebin/*.beam
> > |     deps/myframework
> > |     deps/myframework/src/*.erl
> > |     deps/myframework/src/my_parse_transform.erl
> > |     deps/myframework/ebin/*.beam
> > etc
> >
> > When I launch the compile target, rebar should do the following: a)
> compile
> > all the myframework sources (compile the parse transform module, BUT do
> not
> > use it to compile the other myframework sources), then b) compile
> > myapplication sources USING the parse transform module.
> > Is it possible to write this thing? How? The important part here is that
> > parse transform should be used only when compiling the application, but
> not
> > the dependencies; I know that rebar supports parse transform, but I don't
> > have a precise idea if this should be working or not.
> > I may move my_parse_transform.erl file into myapplication sources
> (because
> > an application using my framework is created with templates and rebar,
> so I
> > can include that file in the template directory), but given the fact
> that it
> > is part of the framework, I would really like to leave it there.
> >
> > Thanks for your help,
> > Alessandro
> >
> > --
> > Sivieri Alessandro
> > alessandro.sivieri at gmail.com
> > http://sivieri.wordpress.com/
> >
> >
> > _______________________________________________
> > rebar mailing list
> > rebar at lists.basho.com
> > http://lists.basho.com/mailman/listinfo/rebar_lists.basho.com
> >
>



-- 
Sivieri Alessandro
alessandro.sivieri at gmail.com
http://sivieri.wordpress.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/rebar_lists.basho.com/attachments/20120227/2e232a5b/attachment.html>


More information about the rebar mailing list