diff options
| author | Alberto Planas <aplanas@suse.com> | 2021-11-11 16:05:32 +0100 |
|---|---|---|
| committer | Alberto Planas <aplanas@suse.com> | 2021-11-14 17:04:32 +0100 |
| commit | afd9dfa89d9f7db67f6fe8c3dd0fda87c154fefe (patch) | |
| tree | 904102ba7228d1c4f3ad7695ed6e3959d904fc5f /src/bootstrap | |
| parent | 62efba8a050c64249dab942951bb28f710208bc8 (diff) | |
| download | rust-afd9dfa89d9f7db67f6fe8c3dd0fda87c154fefe.tar.gz rust-afd9dfa89d9f7db67f6fe8c3dd0fda87c154fefe.zip | |
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 #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.
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/bootstrap.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 38d3c7aec49..22f2e405a1e 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -1119,17 +1119,22 @@ class RustBuild(object): 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') |
