Skip to content

Commit

Permalink
allow repeat runs of cargo build
Browse files Browse the repository at this point in the history
Summary:
The cargo config was being unconditionally added, resutling in "duplicate key `crates-io` in table `source`" error

check if snippet is present before writing

Reviewed By: mzr

Differential Revision: D59803494

fbshipit-source-id: 701773d604c91fd6724069b0451b212cf0018251
  • Loading branch information
ahornby authored and facebook-github-bot committed Jul 16, 2024
1 parent 6efab05 commit 826a113
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions build/fbcode_builder/getdeps/cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,26 @@ def _create_cargo_config(self):
if override not in cargo_content:
new_content += override

if self.build_opts.fbsource_dir:
# Point to vendored crates.io if possible
try:
from .facebook.rust import vendored_crates

new_content = vendored_crates(
self.build_opts.fbsource_dir, new_content
)
except ImportError:
# This FB internal module isn't shippped to github,
# so just rely on cargo downloading crates on it's own
pass

if new_content != cargo_content:
with open(cargo_config_file, "w") as f:
print(
f"Writing cargo config for {self.manifest.name} to {cargo_config_file}"
)
f.write(new_content)

if self.build_opts.fbsource_dir:
# Point to vendored crates.io if possible
try:
from .facebook.rust import vendored_crates

vendored_crates(self.build_opts.fbsource_dir, cargo_config_file)
except ImportError:
# This FB internal module isn't shippped to github,
# so just rely on cargo downloading crates on it's own
pass

return dep_to_git

def _prepare(self, reconfigure) -> None:
Expand Down

0 comments on commit 826a113

Please sign in to comment.