Skip to content

Copy declared Flutter assets/shaders/fonts into cljd dep stubs#378

Open
dankinsoid wants to merge 1 commit into
Tensegritics:mainfrom
dankinsoid:fix/sync-pubspec-assets
Open

Copy declared Flutter assets/shaders/fonts into cljd dep stubs#378
dankinsoid wants to merge 1 commit into
Tensegritics:mainfrom
dankinsoid:fix/sync-pubspec-assets

Conversation

@dankinsoid

@dankinsoid dankinsoid commented Jul 5, 2026

Copy link
Copy Markdown

Problem

sync-pubspec! mirrors every ClojureDart dependency into .clojuredart/deps/<sha256-of-pubspec>/, but it spits only the pubspec.yaml into that stub. The asset, shader and font files that pubspec declares under flutter: assets: / shaders: / fonts: are never copied in.

Dart sources are still pulled from the dependency's real checkout (~/.gitlibs or :local/root), so compilation is fine. But Flutter resolves a package's declared assets relative to that package's own pubspec.yaml directory — i.e. the stub (see flutter_tools asset.dart, which iterates package pubspecs). The declared files aren't there, so loading fails at runtime.

Concretely, a dep whose pubspec has:

flutter:
  shaders:
    - shaders/oklab_gradient.frag

ships a stub containing that declaration but not the .frag, and:

FragmentProgram.fromAsset("packages/<pkg>/shaders/oklab_gradient.frag")

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-pubspec now returns [pubspec-contents base-dir] — the directory the pubspec's paths resolve against (nil for jar deps).
  • When creating a stub, 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 nested fonts: [{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 a nil base-dir (jar) and a missing source file are both no-ops rather than errors. Namespace loads clean.

This replaces a post-compile babashka script we were running to work around the missing files.

…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.
@dankinsoid dankinsoid force-pushed the fix/sync-pubspec-assets branch from 662d724 to 54e61bd Compare July 5, 2026 18:44
@dankinsoid dankinsoid changed the title Copy declared Flutter assets/shaders into cljd dep stubs Copy declared Flutter assets/shaders/fonts into cljd dep stubs Jul 5, 2026
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.

1 participant