Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rework wasm conditional compilation #1704

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

hugocaillard
Copy link
Collaborator

@hugocaillard hugocaillard commented Mar 3, 2025

Context

Because it compiles to both native and wasm platform, clarinet uses conditional dependency management and compilation.
I could make dependency management mrpoe difficult than it should be

Description

Instead of managing conditional dependencies with cargo feature, we can use cargo target dependencies instead.

So instead of this

# package-a
[dependencies]
clap = { optional = true }

[features]
default = ["cli"]
cli = ["clap"]
wasm  = []

##########
#package-b
[dependencies]
package-a = { path = "../package-a", optional = true }

[features]
default = ["cli"]
cli = ["package-a/cli"]
wasm  = ["package-a/cli"]

We now do this

# package-a
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
clap = { optional = true }

##########
#package-b
[dependencies]
package-a = { path = "../package-a" }

With this feature, we remove 100 of toml config.

Future work

The idea of simplifying this depedency management topic on the repo, is mainly to famalirise myself with it so that I can use it in stacks-core to have a clean of handling clarity-vm compilation to wasm

Copy link

codecov bot commented Mar 3, 2025

Codecov Report

Attention: Patch coverage is 15.38462% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
components/clarity-repl/src/repl/session.rs 0.00% 10 Missing ⚠️
components/clarinet-files/src/lib.rs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@hugocaillard hugocaillard force-pushed the refactor/rework-conditional-compilation branch from 2f3f39e to 84dc327 Compare March 3, 2025 15:49
@hugocaillard hugocaillard requested a review from tippenein March 3, 2025 17:29
@hugocaillard hugocaillard marked this pull request as ready for review March 3, 2025 17:32
@hugocaillard hugocaillard force-pushed the refactor/rework-conditional-compilation branch from 84dc327 to f06d763 Compare March 3, 2025 17:34
@tippenein
Copy link
Collaborator

ah, looks like we're hitting some unreachables

@hugocaillard
Copy link
Collaborator Author

@tippenein
The unreachables were network issues in the unit tests (possibly rate limits) because some tx simulation integration tests call the hiro testnet api. (and also because it badly handles network errors)
I'll add an API key to increase the rate limit in ci

@hugocaillard hugocaillard merged commit f6544cf into main Mar 5, 2025
26 checks passed
@hugocaillard hugocaillard deleted the refactor/rework-conditional-compilation branch March 5, 2025 13:37
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.

2 participants