At compile time I need to generate two XML files which are very similar so I am wanting a way to use a single template to generate them both. Ideally I would like to generate one, then change a haxe define to have the other one output. So areas of my template would be excluded if that define was set. e.g.:
::if (DEFINE_SPECIALMODE)::
<product id="SPECIAL1"></product>
::end::
I know I can run lime a second time if I use a tag in my project XML like:
<haxeflag name="--cmd" value="lime build ./project.xml html5 -Dspecialmode -debug" />
but this adds a lot of compile time. Is there a way to just do the template processing without compiling the application? I would like to use it with native Lime or OpenFL compiling functions if I can.
I should mention that I tried using the project.xml by setting my define to a different value before each template tag but it didn’t seem to work as desired.
I think you can use the lime update
command to skip compiling.
lime update html5
Here’s the description of this command:
Copy assets for the specified project and target
1 Like
This works, thanks Josh! I added this to my main project.xml.
<haxeflag name="--cmd" value="lime update ./project-special.xml html5 -debug -Dspecialmode" />
For the record, my normal compile takes 33 seconds. At first I ran that lime update
command using the same project.xml and it ballooned the compile time up to a minute. I guess that despite not generating a new JavaScript file, it is still churning through all my code and libraries. So I created a new xml file (e.g. project-special.xml) containing my <template>
tag, and it uses a stub Main class. That new xml file processes in 3 seconds, which is much better. I don’t like the additional almost-useless files in my project but it’s not a bad trade-off all the same.
Edit: I am now realising that I have to duplicate some of my defines from the main project.xml, which is now defeating my reason for starting down this road. I’ll report if I attain the ultimate solution! I might have to look at using hxp instead of xml.