Copy declared Flutter assets/shaders/fonts into cljd dep stubs#378
Open
dankinsoid wants to merge 1 commit into
Open
Copy declared Flutter assets/shaders/fonts into cljd dep stubs#378dankinsoid wants to merge 1 commit into
dankinsoid wants to merge 1 commit into
Conversation
…p stubs
sync-pubspec! mirrors each cljd dependency into
.clojuredart/deps/<sha256-of-pubspec>/ but writes only the pubspec.yaml
stub — the asset, shader and font files that pubspec declares under
`flutter: assets:` / `shaders:` / `fonts:` are never copied in. Dart
sources still resolve from the dep's real checkout (~/.gitlibs or
:local/root), but Flutter resolves a package's declared assets relative
to that package's own pubspec directory, i.e. the stub. So the files are
missing at that path and load fails at runtime, e.g.:
FragmentProgram.fromAsset("packages/<pkg>/shaders/foo.frag")
throws "unable to load asset", even though Flutter itself parses the
dependency pubspecs correctly.
find-pubspec now also returns the pubspec's base directory, and
sync-pubspec! copies every declared asset/shader/font (files and asset
directories, plus the `{path: ...}` entry form) from that directory into
the stub when creating it. Copy is skipped when the target already
exists; jar deps (assets live inside the archive) keep their current
behaviour.
662d724 to
54e61bd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
sync-pubspec!mirrors every ClojureDart dependency into.clojuredart/deps/<sha256-of-pubspec>/, but it spits only thepubspec.yamlinto that stub. The asset, shader and font files that pubspec declares underflutter: assets:/shaders:/fonts:are never copied in.Dart sources are still pulled from the dependency's real checkout (
~/.gitlibsor:local/root), so compilation is fine. But Flutter resolves a package's declared assets relative to that package's ownpubspec.yamldirectory — i.e. the stub (seeflutter_toolsasset.dart, which iterates package pubspecs). The declared files aren't there, so loading fails at runtime.Concretely, a dep whose pubspec has:
ships a stub containing that declaration but not the
.frag, and:throws unable to load asset at runtime. Flutter itself parses the dependency pubspecs correctly — the gap is purely that ClojureDart doesn't place the physical files in the stub.
Fix
find-pubspecnow returns[pubspec-contents base-dir]— the directory the pubspec's paths resolve against (nilfor jar deps).sync-pubspec!copies each declared asset/shader/font from that base dir into the stub. Handles plain file entries, asset directory entries (recursively), the richer{path: ...}asset form, and nestedfonts: [{fonts: [{asset: ...}]}]. Copy is skipped when the target already exists; jar deps (assets live inside the archive) are unchanged.Testing
Verified in isolation that files, shaders, asset directories,
{path: ...}entries and fonts are mirrored, and that anilbase-dir (jar) and a missing source file are both no-ops rather than errors. Namespace loads clean.This replaces a post-
compilebabashka script we were running to work around the missing files.