Skip to content

Commit 2f371b0

Browse files
authored
Rollup merge of rust-lang#90800 - aplanas:fix_cargo_config, r=Mark-Simulacrum
bootstap: create .cargo/config only if not present In some situations we should want on influence into the .cargo/config when we use vendored source. One example is rust-lang#90764, when we want to workaround some references to crates forked and living in git, that are missing in the vendor/ directory. This commit will create the .cargo/config file only when the .cargo/ directory needs to be created.
2 parents 439afef + afd9dfa commit 2f371b0

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/bootstrap/bootstrap.py

+14-9
Original file line numberDiff line numberDiff line change
@@ -1119,17 +1119,22 @@ def check_vendored_status(self):
11191119
raise Exception("{} not found".format(vendor_dir))
11201120

11211121
if self.use_vendored_sources:
1122+
config = ("[source.crates-io]\n"
1123+
"replace-with = 'vendored-sources'\n"
1124+
"registry = 'https://example.com'\n"
1125+
"\n"
1126+
"[source.vendored-sources]\n"
1127+
"directory = '{}/vendor'\n"
1128+
.format(self.rust_root))
11221129
if not os.path.exists('.cargo'):
11231130
os.makedirs('.cargo')
1124-
with output('.cargo/config') as cargo_config:
1125-
cargo_config.write(
1126-
"[source.crates-io]\n"
1127-
"replace-with = 'vendored-sources'\n"
1128-
"registry = 'https://example.com'\n"
1129-
"\n"
1130-
"[source.vendored-sources]\n"
1131-
"directory = '{}/vendor'\n"
1132-
.format(self.rust_root))
1131+
with output('.cargo/config') as cargo_config:
1132+
cargo_config.write(config)
1133+
else:
1134+
print('info: using vendored source, but .cargo/config is already present.')
1135+
print(' Reusing the current configuration file. But you may want to '
1136+
'configure vendoring like this:')
1137+
print(config)
11331138
else:
11341139
if os.path.exists('.cargo'):
11351140
shutil.rmtree('.cargo')

0 commit comments

Comments
 (0)