Write cargo configuration to .cargo/config.toml instead of .cargo/config

(Synced from rust-packaging into rust-toolset.)

Co-authored-by: Fabio Valentini <decathorpe@gmail.com>

[skip changelog]
This commit is contained in:
Josh Stone 2024-05-17 12:05:26 -07:00
parent 110b2ab26e
commit e2464021a8

View File

@ -48,7 +48,7 @@
# __cargo: cargo command with environment variables # __cargo: cargo command with environment variables
# #
# CARGO_HOME: This ensures cargo reads configuration file from .cargo/config, # CARGO_HOME: This ensures cargo reads configuration file from .cargo/config.toml,
# and prevents writing any files to $HOME during RPM builds. # and prevents writing any files to $HOME during RPM builds.
%__cargo /usr/bin/env CARGO_HOME=.cargo RUSTFLAGS='%{build_rustflags}' /usr/bin/cargo %__cargo /usr/bin/env CARGO_HOME=.cargo RUSTFLAGS='%{build_rustflags}' /usr/bin/cargo
@ -61,7 +61,7 @@
# #
# This involves four steps: # This involves four steps:
# - create the ".cargo" directory if it doesn't exist yet # - create the ".cargo" directory if it doesn't exist yet
# - dump custom cargo configuration into ".cargo/config" # - dump custom cargo configuration into ".cargo/config.toml"
# - remove "Cargo.lock" if it exists (it breaks builds with custom cargo config) # - remove "Cargo.lock" if it exists (it breaks builds with custom cargo config)
# - remove "Cargo.toml.orig" if it exists (it breaks running "cargo package") # - remove "Cargo.toml.orig" if it exists (it breaks running "cargo package")
# #
@ -79,7 +79,7 @@ set -euo pipefail\
/usr/bin/ln -s rpm target/release\ /usr/bin/ln -s rpm target/release\
%{__rm} -rf .cargo/\ %{__rm} -rf .cargo/\
%{__mkdir} -p .cargo\ %{__mkdir} -p .cargo\
cat > .cargo/config << EOF\ cat > .cargo/config.toml << EOF\
[build]\ [build]\
rustc = "%{__rustc}"\ rustc = "%{__rustc}"\
rustdoc = "%{__rustdoc}"\ rustdoc = "%{__rustdoc}"\
@ -104,7 +104,7 @@ verbose = true\
EOF\ EOF\
%{-V:%{__tar} -xoaf %{S:%{-V*}}}\ %{-V:%{__tar} -xoaf %{S:%{-V*}}}\
%{!?-N:\ %{!?-N:\
cat >> .cargo/config << EOF\ cat >> .cargo/config.toml << EOF\
[source.vendored-sources]\ [source.vendored-sources]\
directory = "%{-v*}%{-V:./vendor}"\ directory = "%{-v*}%{-V:./vendor}"\
\ \