Skip to content

Commit

Permalink
Rollup merge of rust-lang#90800 - aplanas:fix_cargo_config, r=Mark-Si…
Browse files Browse the repository at this point in the history
…mulacrum

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.
  • Loading branch information
matthiaskrgr authored Nov 18, 2021
2 parents 439afef + afd9dfa commit 2f371b0
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1119,17 +1119,22 @@ def check_vendored_status(self):
raise Exception("{} not found".format(vendor_dir))

if self.use_vendored_sources:
config = ("[source.crates-io]\n"
"replace-with = 'vendored-sources'\n"
"registry = 'https://example.com'\n"
"\n"
"[source.vendored-sources]\n"
"directory = '{}/vendor'\n"
.format(self.rust_root))
if not os.path.exists('.cargo'):
os.makedirs('.cargo')
with output('.cargo/config') as cargo_config:
cargo_config.write(
"[source.crates-io]\n"
"replace-with = 'vendored-sources'\n"
"registry = 'https://example.com'\n"
"\n"
"[source.vendored-sources]\n"
"directory = '{}/vendor'\n"
.format(self.rust_root))
with output('.cargo/config') as cargo_config:
cargo_config.write(config)
else:
print('info: using vendored source, but .cargo/config is already present.')
print(' Reusing the current configuration file. But you may want to '
'configure vendoring like this:')
print(config)
else:
if os.path.exists('.cargo'):
shutil.rmtree('.cargo')
Expand Down

0 comments on commit 2f371b0

Please sign in to comment.