How to clear compilation server cache ?

202 views
Skip to first unread message

Fabien Antoine

unread,
Jul 12, 2013, 4:07:04 AM7/12/13
to haxe...@googlegroups.com
Hi list,

I currently have a problem with the compilation server cache and some build macros.

I have a class which is built thanks to @:build meta. The class fields are determined by a macro method I use with --macro compiler argument.
The issue is that if I change the macro method parameters after a first compilation, new values are not taken into account because the auto-generated class is already cached.

What is the best way to solve this problem?

Thanks for your help

Fabien Antoine

unread,
Jul 15, 2013, 2:58:36 AM7/15/13
to haxe...@googlegroups.com
I still not found a good solution to solve this problem.

I'm not sure if Context.registerModuleDependency or
Context.registerModuleReuseCall could help me. I didn't find examples
about them except their usage in std lib...but it's not really explicit.
It could be easier to have a kind of Context.forceRecompile(module :
String) method. Any thought about this?

Le 12/07/2013 10:07, Fabien Antoine a �crit :
> --
> To post to this group haxe...@googlegroups.com
> http://groups.google.com/group/haxelang?hl=en
> ---
> You received this message because you are subscribed to the Google
> Groups "Haxe" group.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Andreas Mokros

unread,
Jul 15, 2013, 3:29:55 AM7/15/13
to haxe...@googlegroups.com
Hi.

On Mon, 15 Jul 2013 08:58:36 +0200
Fabien Antoine <fab.a...@gmail.com> wrote:
> I'm not sure if Context.registerModuleDependency or
> Context.registerModuleReuseCall could help me.

Yes. Context.registerModuleDependency(modulePath, filePath) should do
the trick.

> It could be easier to have a kind of Context.forceRecompile(module :
> String) method.

You have to tell the compiler which file is used for the module, no?

--
Mockey

Fabien Antoine

unread,
Jul 15, 2013, 4:40:33 AM7/15/13
to haxe...@googlegroups.com, Andreas Mokros
Thanks for your answer,

Le 15/07/2013 09:29, Andreas Mokros a �crit :
>> It could be easier to have a kind of Context.forceRecompile(module :
>> String) method.
> You have to tell the compiler which file is used for the module, no?

Well, I know wich file should be recompiled but there is no external
dependency except a macro call. However registerModuleDependency expects
a filePath which I don't have...

To be clearer, take a look at the following use case :
I have a Foo class which should be built according to a macro called
from --macro compiler argument and thanks to the @:build meta.
If I set the dependency to Foo class, it won't work since I don't change
it directly. I should set the dependency to the --macro argument which
is not possible if I'm right.

Specifying Context.forceRecompile('Foo') could allow me to check if the
macro call is different for each compilation.

Any idea of how to handle this in a different way?

Fabien Antoine

unread,
Jul 16, 2013, 3:34:57 AM7/16/13
to Andreas Mokros, haxe...@googlegroups.com
So what? There is not a macro for that? ;)

The same cache problem can happen for other use cases...
If I want to initialize an array of instances from a list of files in a
specific folder it will only works the first time. If I add or remove a
file in this folder it will not be taken into account. To make it works
I have to edit the class where the macro is called just to change its
timestamp...and this is not a good design for shared libraries.

Am I the only one to have this kind of problem?

Seriously, the compilation server is great but a simple way to manage it
could be useful. We just need a method to remove the cache of a module...


Le 15/07/2013 15:01, Fabien Antoine a �crit :
> Well, of course the code of the macro is in a class. Sorry, I think
> I'm not very clear.
>
> Take this piece of code :
>
> #if !macro @:build(pack.Foo.build()) #end
> class Foo {
> #if macro
> private static var _params : Array<String>;
>
> // This is the macro method I call from --macro argument
> public static funcation bar(params : Array<String>) : Void {
> Foo._params = params;
> }
>
> public static function build() {
> // I need to use Foo._params here
> return Context.getBuildFields();
> }
> #end
> }
>
> I compile my project with : haxe --macro Foo.bar(['a','b']) ...
>
> So which dependency should I use?
> I tried to add "Context.registerModuleDependency("Foo", "Foo.hx");" in
> the build() method but it doesn't work.
> If I change the parameters in the Foo.bar(...) call the class is not
> built again.
>
> I would like to be able to call Foo.params() from my main() method but
> the class is built before the macro is called.
>
> Le 15/07/2013 14:26, Andreas Mokros a �crit :
>> Hi.
>>
>> On Mon, 15 Jul 2013 14:19:39 +0200
>> Fabien Antoine <fab.a...@gmail.com> wrote:
>>> The macro call is not in a file but specified with the "--macro"
>>> compiler argument.
>> But the code for the macro call is in a file, isn't it?
>>
>

Juraj Kirchheim

unread,
Jul 16, 2013, 3:58:13 AM7/16/13
to haxe...@googlegroups.com
You could try `Context.registerModuleDependency(affectedModule, dummyFile)` and in your "--macro"  macro, if the arguments change, you could cause the dummyFile to be modified if necessary.

Regards,
Juraj
Reply all
Reply to author
Forward
0 new messages