So I am working on getting modding working for Armory, but I am having a small issue. I want Armory mods to have have the ability to call the Kha, Iron, and Armory APIs. The way I do that is by Kha, Iron, and Armory being built like normal into the main game, while mods include the APIs as externs. This means that when mods are built, they include only the code that makes up the mod functionality and not the entire Kha and Iron code along with it. This work mostly great. The problem that I have is that if the main game doesn’t use a class from Iron, for example, Haxe won’t build that class at all and then when the mod needs to use that class, it won’t exist.
This is actually similar to the problem you have when building Haxe documentation, where you want to generate the .xml class reference file for a library, but by default haxe won’t include classes that aren’t used in a program. The solution is to use the include()
macro in your .hxml file. This is supposed to make Haxe include the whole package in the compliation, regardless of whether or not it is actually used ( reference ). For some reason, though, I have problems adding --macro include("iron")
. Each different library has it’s own reason for failing the build. To boil it down to the smallest number of variables I tried generating the documentation XML as a test:
-cp Kha/Sources
-cp Kha/Backends/Krom
-cp armory/Sources
-cp iron/Sources
--macro include("iron")
--no-output
-D doc-gen
-xml krom-doc.hxml
-js krom.js.test
Running this produces:
--macro:1: character 1 : Invalid package : iron.data should be <empty>
Including Kha results in:
Kha/Sources/kha/graphics4/hxsl/Eval.hx:108: characters 36-41 : Unexpected final
And including Armory results in:
Kha/Sources/kha/graphics4/hxsl/Eval.hx:108: characters 36-41 : Unexpected final
In practice I need to be able to add the following lines to a Khafile.js and have it work:
project.addParameter("--macro include('armory')");
project.addParameter("--macro include('kha')");
project.addParameter("--macro include('iron')");
Does anybody have any idea why I’m having issues with this? The doc generation at least should work somehow. How else can @lubos and @RobDangerous generate their API documentation sites?
Note: On a sidenote I am actually able to do
project.addParameter("--macro include('armory.logicnode')");
and it works as expected. I don’t know what the correlation is.