Project.xml -- Macro Call


#1

Hello community,

I am new to openFl.

I have quite a simple question (sorry for demanding to little from you :wink: ):

How can I implement a macro call into the project.xml that is similar to the .hxml tag -macro ?

I did not find it in the discription of the project.xml. And I have also tried to google it, without any result.

Thank you in advance.

Kind regards
Arnim


#2

I think you could do it using <haxeflag name="--macro" value='keep("MyClass")' /> or something similar


#3

Thank you for your reply.

But doesn’t <haxeflag …/> set a compiler flag like

@:keep
class MyClass

?

What I am looking for is the equivalent of the project.xml element to

cpp.hxml

–macro “Main.aFunctionToExecuteOnCompileTime()”

So the compiler executes a function when it starts working.


#4

Taken from http://www.openfl.org/lime/docs/project-files/xml-format/

Use <haxeflag /> tags to add additional arguments in the Haxe compile process

<haxeflag name="-dce" value="std" />

This should be like adding to your HXML in normal Haxe projects


#5

Thanks again for your answer, Joshua,

When I have tried your first reply, I have got an error message and thought, that I was using the wrong project.xml tag.

But after your second one, I have experimented a little. Now I know, that the openFl does recognize the “–macro” directive correctly.

The problem is, that there seems to be a different issue (maybe a bug (?) )

When I hand set the following tag within the project.xml

<haxeflag name="–macro" value=“Main.macroCallInProjectXml()” />

… the following errors are thrown:

C:/HaxeToolkit/haxe/lib/lime/6,4,0/lime/system/System.hx:713: characters 19-58 : Class<lime._backend.native.NativeCFFI> has no field lime_system_get_device_model
C:/HaxeToolkit/haxe/lib/lime/6,4,0/lime/system/System.hx:744: characters 20-60 : Class<lime._backend.native.NativeCFFI> has no field lime_system_get_device_vendor
C:/HaxeToolkit/haxe/lib/lime/6,4,0/lime/system/System.hx:841: characters 22-63 : Class<lime._backend.native.NativeCFFI> has no field lime_system_get_platform_label
C:/HaxeToolkit/haxe/lib/lime/6,4,0/lime/system/System.hx:905: characters 23-66 : Class<lime._backend.native.NativeCFFI> has no field lime_system_get_platform_version

When I have the same function be executed as a macro on “classical” .hxml compilation, it works well…


#6

The function executed as a macro is merely a simple trace() function…

public static function macroCallInProjectXml() : Void
{
	trace( "MacroCall did work!" );
	trace( "MacroCall did work!" );
	trace( "MacroCall did work!" );
	trace( "MacroCall did work!" );
	trace( "MacroCall did work!" );
	trace( "MacroCall did work!" );
	trace( "MacroCall did work!" );
	trace( "MacroCall did work!" );
	trace( "MacroCall did work!" );
	trace( "MacroCall did work!" );
	trace( "MacroCall did work!" );
	trace( "MacroCall did work!" );
} // macro public static function macroCallInProjectXml() : Void

#7

If you (or anybody else) has an idea, what I am doing wrong, I would be thankful for any hint.

Until then I assume, that it is a bug.

I have opened an issue at openFl github.

Kind regards
Arnim


#8

Hmm, it sounds like perhaps now it is running, but it is hitting classes that are using CFFI. Is there way to make a new macro in its own file, and to test just a simple trace ("hello world") or something similar, to make sure that just calling a standard macro is not resulting in this problem?


#9

Hello Joshua.

Surprisingly that worked.

I did not expect the solution to be that simple…

So thank you very much for your answer, Joshua.

Kind regards
Arnim