linebender / piet

An abstraction for 2D graphics.
Apache License 2.0
1.24k stars 93 forks source link

Is it possible/desired to put `piet-web` behind a Cargo feature? #445

Closed kud1ing closed 3 years ago

kud1ing commented 3 years ago

Background: i had a GUI app in a workspace where js-sys is used in a different crate. The version used there clashed with js-sys used by some of piet-web's dependencies. A cargo update resolved this but i think it would be nice to only build piet-web if desired. Not sure whether/how this works for workspaces.

piet-common uses the web feature to select piet-web.

cmyr commented 3 years ago

How are you using piet? is it on its own, or through druid or similar?

In druid projects, we don't build any of the web stuff, including piet-web, unless targeting wasm; or at least I'm pretty sure this is the case.

kud1ing commented 3 years ago

Through Druid.

piet-web is part of piet's workspace and I don’t see how compilation is disabled in the piet-web crate. It may not be used but it is compiled - at least this is what cargo told me.

cmyr commented 3 years ago

hmm.

My understanding: compiling druid doesn't compile the whole piet workspace. It compiles the piet-common crate; and this brings in the top-level piet crate, as well as one of the piet backends. The choice of backend is a function of the target-os.

One weird thing about this is that there is a feature that can cause compilation of the web backend. I don't remember what the rationale for this was? It might have been for testing or CI, or something like that? I'm not totally sure what's going on here, but you're welcome to investigate.

kud1ing commented 3 years ago

Hm, strange. I can see neither piet-web nor js_sys in cargo tree. Something must have changed after the cargo update. Sorry for the false alarm.

cmyr commented 3 years ago

No worries, there's definitely some weirdness around how some of these dependencies are declared, and I don't myself fully understand it all. 🤷