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

can I run with a specified Cargo.toml path #1090

Open
tiye opened this issue Dec 6, 2021 · 6 comments
Open

can I run with a specified Cargo.toml path #1090

tiye opened this issue Dec 6, 2021 · 6 comments

Comments

@tiye
Copy link

tiye commented Dec 6, 2021

💡 Feature description

like:

wasm-pack build --manifest-path folder/Cargo.toml

so I can keep 2 copies of Cargo.toml and use one of them for wasm-pack.

original problem was I need to build both staticlib dylib and cdylib, they produce a conflict. I want to keep multiple versions of Cargo.toml for switching.

💻 Basic example

same as above.

@tijlleenders
Copy link

Hi Jon,

What problem are you trying to solve with the Cargo switching?

For now, I'm guessing you want two Cargo.toml files for building to different targets.
If not, why else would you want this?

Have you read the Cargo docs?
It supports release profiles.

Cargo also supports conditional dependencies:

[target.'cfg(target_arch = "wasm32")'.dependencies]
crate = "0.1.0"
etc...

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
crate = "0.2.1
etc...

If this somehow doesn't suit you... can you use git branches?

@gthb
Copy link
Contributor

gthb commented Dec 6, 2021

I use a separate crate for the WebAssembly wrapper code and build config, so a top-level my-project/Cargo.toml:

[workspace]

members = [
	"my-rust-lib",
	"my-wasm-wrapper",
]

... and then those crates have separate files my-rust-lib/Cargo.toml and my-wasm-wrapper/Cargo.toml.

Keep things simple and clear. Does this kind of workspace separation suit you, @jiyinyiyong ?

@tiye
Copy link
Author

tiye commented Dec 6, 2021

@tijlleenders I thought about that for a while, it was not for dependencies, but for lib types:

[lib]
crate-types = [...]

it appears that it's still not supported according to rust-lang/cargo#4881 so I cannot use in that way.

@tiye
Copy link
Author

tiye commented Dec 6, 2021

@gthb thanks, it might work, but I think it does not fit my current case. I have to compile a same piece of code to multiple targets. Splitting code into multiple crates add extra complexities. I have a dirty solution at now.

@tijlleenders
Copy link

Wow... that issue is three years old.
Seems pretty clear it's not solvable at the moment.

My workaround would be to swap the cargo.toml in the build pipeline.

@tiye
Copy link
Author

tiye commented Dec 6, 2021

My workaround would be to swap the cargo.toml in the build pipeline.

yep. my current dirty way.

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

No branches or pull requests

3 participants