Add <preupdate /> tag.#2072
Conversation
moxie-coder
left a comment
There was a problem hiding this comment.
Sounds very cool on paper honestly, I might be able to think of use cases for this possibly (macros maybe)
|
I tried this out, and it works really well except for one minor nitpick: Like in the original issue (#1959), Lime will complain if the assets folder does not exist at build-time. Seems like this is checked before the preupdate script runs |
|
Ah, I see. It verifies the asset path when the The For
...I guess if assets are getting parsed in |
|
I feel like going with |
XML lifecycle hooks could be useful, but I would just note that hxp is canonically more useful here. |
|
Yeah, that was my thought process for the |
I agree. While HXP would definitely make sense here, most Lime/OpenFL projects ship with Project.xml by default. Needing to convert the entire project from XML to HXP for one feature definitely seems like a bit of an inconvenience (especially on larger projects), so it'd be nice if there was a way to accomplish something like this via XML too |
|
Sure. Anyway, I had a chance to take a deeper look at the PR. I don’t think this can close #1959 as written, though. The failing case in there is specifically a generated asset path that does not exist yet, and that still appears to fail before
if (!FileSystem.exists(path))
{
Log.error("Could not find asset path \"" + path + "\"");
return;
}The new case only records the command with parseCommandElement(element, preUpdateCallbacks). Those callbacks are not executed until So a project like: <preupdate command="pre-process.sh" />
<assets path="game/assets-final" rename="assets" if="final" />will still fail if game/assets-final does not already exist. |
I think there may be a small misconception here, which is why I brought up HXP to begin with. HXP was designed for this kind of escape hatch, and using it does not necessarily mean converting an entire You can use a very small Something like this: import lime.tools.HXProject;
import lime.tools.ProjectXMLParser;
import sys.FileSystem;
class Project extends HXProject {
public function new() {
super();
if (!FileSystem.exists("generated-assets")) {
FileSystem.createDirectory("generated-assets");
}
merge(new ProjectXMLParser("Project.xml", defines));
}
}That lets HXP generate the missng asset directory before ProjectXMLParser validates the I’m not against adding more XML hooks, but I wanted to clarify that using HXP here does not have to be a full project migration. |
|
honestly that's an very cool discovery, and kinda something I wish I knew beforehand since I thought it wasn't possible to use HXP and XML together lol |
Yeah, that's I was saying. Except, more thorough. You know, But no, I can kind of see why we want to traverse the directory immediately. There's a lot of attributes involved, and it's way easier to deal with them immediately than to store them. It would take an There are certainly two sides to this, but I'm leaning towards "assets should only be processed in the update step, and no one should expect to access them until then." It'd also save a bunch of file access operations during |
This allows users to pre-process (or even programmatically generate) their assets before Lime copies them. I've included a
<postupdate />tag for consistency (and so people don't ask why it's left out), but the main expected use case is pre-processing.This is a more specific alternative to #1993, which offered full control at the expense of more potential to shoot yourself in the foot. This version should behave more like people expect.