Embedding assets of another project without using full path

Okay. So, I’m trying to access the source code and assets of project A (“shared”) via project B (“game”).

I created a local haxelib for “shared” by running:

haxelib dev shared C:/Shared/Source

The idea is to reference “shared” within “game” without having to use a full path.

The following line allows me to do just that (in game’s project.xml):

<haxelib name="shared" />

To embed the assets, I discovered the following works just fine:

<assets path="C:/Shared/Assets" rename="Assets" exclude="openfl.svg" />

The problem, however, is that I need to be able to embed the assets without using the full path, like so:

<assets path="shared/../Assets" rename="Assets" exclude="openfl.svg" />

Is this possible? (The above line does not work, obviously…)

If not, ideally, you would be able to access haxelib’s via the path attribute, like:

haxelib dev shared C:/Shared

<source path="$shared/Source" />
<assets path="$shared/Assets" rename="Assets" exclude="openfl.svg" />

Also, is there any way to get the full path to “shared” at run-time within “game” ?

Try defining C:/Shared/include.xml, and adding the appropriate <source /> and <asset /> tags to the file (as if it was a normal project).

Then run haxelib dev shared C:/Shared to point Haxelib at the right folder, and it should work.

1 Like

Alternatively, if you would prefer not to use a haxelib, you can use an asset XML file, and <include path="../to/shared.xml" /> but it sounds like “include.xml” is the trick you’re looking for :slight_smile:

Cool, thanks @player_03 and @singmajesty!! Using include.xml did the trick alright.

I also figured out how to determine the path to the “shared” project at run-time via the haxelib as well:

var sharedDevPath:String = Sys.getEnv("HAXEPATH") + "/lib/shared/.dev";

if (FileSystem.exists(sharedDevPath)) {
    var file:FileInput = File.read(sharedDevPath);
    trace(file.readLine()); // C:/Shared
}

Not sure if there’s an easier way / built-in method for this, however, but it’s working at least.

Try running “haxelib path”, and handling the output, though there might be a way to compile it in

though I’d expect instead of checking the path at runtime, you’d set any <asset /> node or other values you want, so that the tools copy whatever files you need to the output directory?