Skip to content

Add <preupdate /> tag.#2072

Open
player-03 wants to merge 1 commit into
openfl:developfrom
player-03:preupdate
Open

Add <preupdate /> tag.#2072
player-03 wants to merge 1 commit into
openfl:developfrom
player-03:preupdate

Conversation

@player-03

Copy link
Copy Markdown
Contributor

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.

Closes #1959

@moxie-coder moxie-coder left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds very cool on paper honestly, I might be able to think of use cases for this possibly (macros maybe)

@ACrazyTown

Copy link
Copy Markdown
Contributor

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

@player-03

Copy link
Copy Markdown
Contributor Author

Ah, I see. It verifies the asset path when the <assets /> tag is first parsed. It has to do this because it has to be able to tell if the asset is a single file or a directory, since in the latter case it has to iterate through and enumerate the individual files.

The <execute /> tag would handle this, since it runs immediately and you can generate the asset before ProjectXMLParser reaches the <assets /> tag.

For <preupdate /> to work, we'd have to make some kind of change to how assets are handled.

  • Allow the user to specify if it's a file or directory, and defer directory traversal until the update step. But if anything examines the list of assets in the meantime, it would miss some.
  • Require missing assets to be files, not directories. At least then the correct number of assets can be found, even if the contents aren't there yet.
  • Run the <preupdate /> callbacks immediately whenever an asset isn't found. (With a variable to keep track of whether this was already done, so as not to do it twice.) But this means they'll get run every time the file is parsed, even in display mode.

...I guess if assets are getting parsed in display mode anyway, you might as well use <execute />, and not even bother with unless="display". It's going to check for the file every time, so you should also run your code every time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project prebuild command is running too late

3 participants