Skip to content

Allow changing the name of the project in Cargo.toml #30

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

Merged
merged 3 commits into from
Mar 27, 2023

Conversation

SergioGasquez
Copy link
Contributor

Before, if a user modified the "name" property of Cargo.toml, the build would fail. Now, the name provided by the user will be replaced by the correct one and the build wont fail.

Also updated the Xtensa Rust version

@urish
Copy link
Contributor

urish commented Mar 27, 2023

Awesome, thanks!

Re replacing the project name - very cool. Maybe update the regexp to support zero or more spaces before/after the = sign, and also at the start of the line? so something like name= "Hello-project" will still be recognized and replaced.

I'm not sure if Cargo.toml also supports single quotes, but if it does - it may make sense to support this case as well.

Perhaps just adding the name again at the end of the toml file will do the trick and overriding the name the user defined? i.e. always appending the following to Cargo.toml:

[package]
name = "${PROJECT_NAME_UNDERSCORE}" 

@SergioGasquez
Copy link
Contributor Author

Re replacing the project name - very cool. Maybe update the regexp to support zero or more spaces before/after the = sign, and also at the start of the line? so something like name= "Hello-project" will still be recognized and replaced.

I'm not sure if Cargo.toml also supports single quotes, but if it does - it may make sense to support this case as well.

Cargo.toml does support single quotes, just updated the regex with all you cases covered, thanks for the feedback!

Perhaps just adding the name again at the end of the toml file will do the trick and overriding the name the user defined? i.e. always appending the following to Cargo.toml:

[package]
name = "${PROJECT_NAME_UNDERSCORE}" 

Just did some testing and you can't have the “name” or the whole package section duplicated in the Cargo.toml.

@urish urish merged commit 3883538 into wokwi:main Mar 27, 2023
@urish
Copy link
Contributor

urish commented Mar 27, 2023

I'm trying to build this, but getting

 => ERROR [ 4/13] RUN cargo generate -a esp-rs/esp-template --name rust-project-esp32 --vcs none --silent -d mcu=esp32 -d devcontainer=false -d alloc=true                                       0.6s
------
 > [ 4/13] RUN cargo generate -a esp-rs/esp-template --name rust-project-esp32 --vcs none --silent -d mcu=esp32 -d devcontainer=false -d alloc=true:
#7 0.575 error: no such command: `generate`
#7 0.575
#7 0.575        View all installed commands with `cargo --list`
------
executor failed running [/bin/sh -c cargo generate -a esp-rs/esp-template --name rust-project-esp32 --vcs none --silent -d mcu=esp32 -d devcontainer=false -d alloc=true]: exit code: 101

any idea what could be wrong?

@SergioGasquez
Copy link
Contributor Author

any idea what could be wrong?

Yes, just created #31 fixing this. We recently slimmed the tags and removed all the unnecessary crates.

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