-
Notifications
You must be signed in to change notification settings - Fork 102
Support different lib.crate-type
#227
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -174,7 +174,7 @@ rec | |||||||||||||||||
| attrs = | ||||||||||||||||||
| # Since we pretend everything is a lib, we remove any mentions | ||||||||||||||||||
| # of binaries | ||||||||||||||||||
| removeAttrs cargotoml [ "bin" "example" "lib" "test" "bench" "default-run" ] | ||||||||||||||||||
| removeAttrs cargotoml [ "bin" "example" "test" "bench" "default-run" ] | ||||||||||||||||||
| // lib.optionalAttrs (builtins.hasAttr "package" cargotoml) ({ package = removeAttrs cargotoml.package [ "default-run" ] ; }) | ||||||||||||||||||
| ; | ||||||||||||||||||
| in | ||||||||||||||||||
|
|
@@ -209,7 +209,11 @@ rec | |||||||||||||||||
| pushd $out/$member > /dev/null | ||||||||||||||||||
| mkdir -p src | ||||||||||||||||||
| # Avoid accidentally pulling `std` for no-std crates. | ||||||||||||||||||
| echo '#![no_std]' >src/lib.rs | ||||||||||||||||||
| cat <<EOF >src/lib.rs | ||||||||||||||||||
| #![no_std] | ||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| #[panic_handler] | ||||||||||||||||||
| fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } | ||||||||||||||||||
|
Comment on lines
+214
to
+215
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what are these two lines for?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you compile with
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Added a code suggestion; worth having the clarification near the code. |
||||||||||||||||||
| EOF | ||||||||||||||||||
| # pretend there's a `build.rs`, otherwise cargo doesn't build | ||||||||||||||||||
| # the `[build-dependencies]`. Custom locations of build scripts | ||||||||||||||||||
| # aren't an issue because we strip the `build` field in | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if the project mentions a
[lib]that isn'tsrc/lib.rs? Won't cargo try to build that and, not finding any files, fail?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, this change in particular is the one I'm not sure about. In order for WASM dependencies to be built,
lib.crate-typeneeds to be retained. This was merely the quickest fix I could think of, I didn't really consider the other effects, and perhaps there's a better way to achieve the same goal.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see! I believe this will break on cargo tomls that have
lib = .... Can you give some exampleCargo.tomls that uselib.crate-type? Maybe we can just remove e.g. thepathof thelibattribute?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any example which uses
wasm-bindgenfor instance:https://github.com/rustwasm/wasm-bindgen/tree/main/examples