dtolnay / watt

Runtime for executing procedural macros as WebAssembly
Apache License 2.0
1.25k stars 29 forks source link

PoC: feature passthrough #36

Closed CAD97 closed 4 years ago

CAD97 commented 4 years ago

Closes #35

This is a very Proof of Concept execution of this feature. Notable limitations:

But this implementation does work!

D:\repos\dtolnay\watt\demo\caller>cargo run --quiet --features=""
message=Hello from WASM! My name is S.

D:\repos\dtolnay\watt\demo\caller>cargo run --quiet --features="feat_a"
message=Hello from WASM! My name is S. feat_a is enabled.

D:\repos\dtolnay\watt\demo\caller>cargo run --quiet --features="feat_b"
message=Hello from WASM! My name is S. feat_b is enabled.

D:\repos\dtolnay\watt\demo\caller>cargo run --quiet --features="feat_a feat_b"
message=Hello from WASM! My name is S. feat_a is enabled. feat_b is enabled.

Simple overview of how the feature information flows into the wasm module:

While the details of an impl may change, the rough shape will stay the same:

The wasm interface types proposal could potentially allow passing an "abstract string" more simply, but for the time being, we have to compress the feature string into a 32 bit or 64 bit integer via some hash function.

CAD97 commented 4 years ago

CI failure is MSRV because Vec::new is not const-stable in 1.35. Even though it says it was const stabilized in 1.32.

CAD97 commented 4 years ago

Potential strategy changes:

CAD97 commented 4 years ago

Closing in favor of #37.