├── .gitignore ├── Cargo.toml ├── README.md ├── src └── main.rs └── Cargo.lock /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mksettings" 3 | version = "0.1.0" 4 | edition = "2021" 5 | authors = [ 6 | "Björn Quentin ", 7 | ] 8 | license = "MIT OR Apache-2.0" 9 | 10 | [dependencies] 11 | clap = { version = "4.3.0", features = ["derive"] } 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VSCode Rust Analyzer Settings Generator 2 | 3 | This is for my personal use but might be helpful for others. 4 | 5 | Installation: 6 | `cargo install --path .` 7 | or directly from GitHub 8 | 9 | Example: 10 | ``` 11 | git clone https://github.com/esp-rs/esp-hal.git 12 | cd esp-hal 13 | cd esp-hal-common 14 | mksettings --features=esp32c3 15 | code . 16 | ``` 17 | 18 | This will overwrite `.vscode/settings.json` without asking! 19 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use clap::Parser; 2 | 3 | #[derive(Parser, Debug)] 4 | #[command(author, version, about, long_about = None)] 5 | struct Args { 6 | #[arg(short, long)] 7 | features: Option, 8 | #[arg(short, long)] 9 | chip: Option, 10 | } 11 | 12 | fn main() { 13 | let args = Args::parse(); 14 | 15 | let features: Vec = if let Some(features) = args.features { 16 | features.split(&[' ', ',']).map(|v| v.to_string()).collect() 17 | } else { 18 | vec![] 19 | }; 20 | 21 | let features_list = features 22 | .iter() 23 | .map(|v| format!("\"{}\"", v)) 24 | .collect::>() 25 | .join(", "); 26 | 27 | let chip = args.chip.unwrap_or("esp32c3".to_string()).to_lowercase(); 28 | 29 | let target = match chip.as_str() { 30 | "esp32" => "xtensa-esp32-none-elf", 31 | "esp32s2" => "xtensa-esp32s2-none-elf", 32 | "esp32s3" => "xtensa-esp32s3-none-elf", 33 | "esp32c2" | "esp32c3" => "riscv32imc-unknown-none-elf", 34 | _ => "riscv32imac-unknown-none-elf", 35 | }; 36 | 37 | let content = format!( 38 | " 39 | {{ 40 | \"rust-analyzer.cargo.target\": \"{target}\", 41 | \"rust-analyzer.cargo.features\": [ 42 | {features_list} 43 | ], 44 | \"rust-analyzer.cargo.buildScripts.useRustcWrapper\": true, 45 | \"rust-analyzer.cargo.allTargets\": false, 46 | \"rust-analyzer.check.allTargets\": false, 47 | \"rust-analyzer.showUnlinkedFileNotification\": false, 48 | }} 49 | " 50 | ) 51 | .trim() 52 | .to_string(); 53 | 54 | std::fs::create_dir_all(".vscode/").unwrap(); 55 | std::fs::write(".vscode/settings.json", content).unwrap(); 56 | } 57 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "anstream" 7 | version = "0.6.4" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" 10 | dependencies = [ 11 | "anstyle", 12 | "anstyle-parse", 13 | "anstyle-query", 14 | "anstyle-wincon", 15 | "colorchoice", 16 | "utf8parse", 17 | ] 18 | 19 | [[package]] 20 | name = "anstyle" 21 | version = "1.0.4" 22 | source = "registry+https://github.com/rust-lang/crates.io-index" 23 | checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" 24 | 25 | [[package]] 26 | name = "anstyle-parse" 27 | version = "0.2.2" 28 | source = "registry+https://github.com/rust-lang/crates.io-index" 29 | checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" 30 | dependencies = [ 31 | "utf8parse", 32 | ] 33 | 34 | [[package]] 35 | name = "anstyle-query" 36 | version = "1.0.0" 37 | source = "registry+https://github.com/rust-lang/crates.io-index" 38 | checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" 39 | dependencies = [ 40 | "windows-sys", 41 | ] 42 | 43 | [[package]] 44 | name = "anstyle-wincon" 45 | version = "3.0.1" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" 48 | dependencies = [ 49 | "anstyle", 50 | "windows-sys", 51 | ] 52 | 53 | [[package]] 54 | name = "clap" 55 | version = "4.4.7" 56 | source = "registry+https://github.com/rust-lang/crates.io-index" 57 | checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" 58 | dependencies = [ 59 | "clap_builder", 60 | "clap_derive", 61 | ] 62 | 63 | [[package]] 64 | name = "clap_builder" 65 | version = "4.4.7" 66 | source = "registry+https://github.com/rust-lang/crates.io-index" 67 | checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" 68 | dependencies = [ 69 | "anstream", 70 | "anstyle", 71 | "clap_lex", 72 | "strsim", 73 | ] 74 | 75 | [[package]] 76 | name = "clap_derive" 77 | version = "4.4.7" 78 | source = "registry+https://github.com/rust-lang/crates.io-index" 79 | checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" 80 | dependencies = [ 81 | "heck", 82 | "proc-macro2", 83 | "quote", 84 | "syn", 85 | ] 86 | 87 | [[package]] 88 | name = "clap_lex" 89 | version = "0.6.0" 90 | source = "registry+https://github.com/rust-lang/crates.io-index" 91 | checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" 92 | 93 | [[package]] 94 | name = "colorchoice" 95 | version = "1.0.0" 96 | source = "registry+https://github.com/rust-lang/crates.io-index" 97 | checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" 98 | 99 | [[package]] 100 | name = "heck" 101 | version = "0.4.1" 102 | source = "registry+https://github.com/rust-lang/crates.io-index" 103 | checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" 104 | 105 | [[package]] 106 | name = "mksettings" 107 | version = "0.1.0" 108 | dependencies = [ 109 | "clap", 110 | ] 111 | 112 | [[package]] 113 | name = "proc-macro2" 114 | version = "1.0.69" 115 | source = "registry+https://github.com/rust-lang/crates.io-index" 116 | checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" 117 | dependencies = [ 118 | "unicode-ident", 119 | ] 120 | 121 | [[package]] 122 | name = "quote" 123 | version = "1.0.33" 124 | source = "registry+https://github.com/rust-lang/crates.io-index" 125 | checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" 126 | dependencies = [ 127 | "proc-macro2", 128 | ] 129 | 130 | [[package]] 131 | name = "strsim" 132 | version = "0.10.0" 133 | source = "registry+https://github.com/rust-lang/crates.io-index" 134 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 135 | 136 | [[package]] 137 | name = "syn" 138 | version = "2.0.39" 139 | source = "registry+https://github.com/rust-lang/crates.io-index" 140 | checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" 141 | dependencies = [ 142 | "proc-macro2", 143 | "quote", 144 | "unicode-ident", 145 | ] 146 | 147 | [[package]] 148 | name = "unicode-ident" 149 | version = "1.0.12" 150 | source = "registry+https://github.com/rust-lang/crates.io-index" 151 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" 152 | 153 | [[package]] 154 | name = "utf8parse" 155 | version = "0.2.1" 156 | source = "registry+https://github.com/rust-lang/crates.io-index" 157 | checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" 158 | 159 | [[package]] 160 | name = "windows-sys" 161 | version = "0.48.0" 162 | source = "registry+https://github.com/rust-lang/crates.io-index" 163 | checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 164 | dependencies = [ 165 | "windows-targets", 166 | ] 167 | 168 | [[package]] 169 | name = "windows-targets" 170 | version = "0.48.5" 171 | source = "registry+https://github.com/rust-lang/crates.io-index" 172 | checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 173 | dependencies = [ 174 | "windows_aarch64_gnullvm", 175 | "windows_aarch64_msvc", 176 | "windows_i686_gnu", 177 | "windows_i686_msvc", 178 | "windows_x86_64_gnu", 179 | "windows_x86_64_gnullvm", 180 | "windows_x86_64_msvc", 181 | ] 182 | 183 | [[package]] 184 | name = "windows_aarch64_gnullvm" 185 | version = "0.48.5" 186 | source = "registry+https://github.com/rust-lang/crates.io-index" 187 | checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" 188 | 189 | [[package]] 190 | name = "windows_aarch64_msvc" 191 | version = "0.48.5" 192 | source = "registry+https://github.com/rust-lang/crates.io-index" 193 | checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" 194 | 195 | [[package]] 196 | name = "windows_i686_gnu" 197 | version = "0.48.5" 198 | source = "registry+https://github.com/rust-lang/crates.io-index" 199 | checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" 200 | 201 | [[package]] 202 | name = "windows_i686_msvc" 203 | version = "0.48.5" 204 | source = "registry+https://github.com/rust-lang/crates.io-index" 205 | checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" 206 | 207 | [[package]] 208 | name = "windows_x86_64_gnu" 209 | version = "0.48.5" 210 | source = "registry+https://github.com/rust-lang/crates.io-index" 211 | checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" 212 | 213 | [[package]] 214 | name = "windows_x86_64_gnullvm" 215 | version = "0.48.5" 216 | source = "registry+https://github.com/rust-lang/crates.io-index" 217 | checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" 218 | 219 | [[package]] 220 | name = "windows_x86_64_msvc" 221 | version = "0.48.5" 222 | source = "registry+https://github.com/rust-lang/crates.io-index" 223 | checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" 224 | --------------------------------------------------------------------------------