From 8a62f891e1dbd816e5ea55e644d09c3d92fb2afb Mon Sep 17 00:00:00 2001 From: Dario Vladovic Date: Mon, 22 Jun 2020 13:24:41 +0200 Subject: [PATCH] formula: add std_cargo_args --- Library/Homebrew/formula.rb | 7 +++++++ Library/Homebrew/formula_creator.rb | 2 +- Library/Homebrew/rubocops/text.rb | 2 +- Library/Homebrew/test/rubocops/text_spec.rb | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 90448c1549..ca7e93514e 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1354,6 +1354,11 @@ class Formula "#" end + # Standard parameters for cargo builds. + def std_cargo_args + ["--locked", "--root", prefix, "--path", "."] + end + # Standard parameters for CMake builds. # Setting `CMAKE_FIND_FRAMEWORK` to "LAST" tells CMake to search for our # libraries before trying to utilize Frameworks, many of which will be from @@ -1930,6 +1935,8 @@ class Formula case cmd when "./configure" pretty_args -= %w[--disable-dependency-tracking --disable-debug --disable-silent-rules] + when "cargo" + pretty_args -= std_cargo_args when "cmake" pretty_args -= std_cmake_args when "go" diff --git a/Library/Homebrew/formula_creator.rb b/Library/Homebrew/formula_creator.rb index caa1d81891..5e734c9072 100644 --- a/Library/Homebrew/formula_creator.rb +++ b/Library/Homebrew/formula_creator.rb @@ -175,7 +175,7 @@ module Homebrew bin.install libexec/"bin/\#{name}" bin.env_script_all_files(libexec/"bin", :GEM_HOME => ENV["GEM_HOME"]) <% elsif mode == :rust %> - system "cargo", "install", "--locked", "--root", prefix, "--path", "." + system "cargo", "install", *std_cargo_args <% else %> # Remove unrecognized options if warned by configure system "./configure", "--disable-debug", diff --git a/Library/Homebrew/rubocops/text.rb b/Library/Homebrew/rubocops/text.rb index 97508b9b33..6938d5f5fc 100644 --- a/Library/Homebrew/rubocops/text.rb +++ b/Library/Homebrew/rubocops/text.rb @@ -60,7 +60,7 @@ module RuboCop end find_method_with_args(body_node, :system, "cargo", "build") do - problem "use \"cargo\", \"install\", \"--root\", prefix, \"--path\", \".\"" + problem "use \"cargo\", \"install\", *std_cargo_args" end end end diff --git a/Library/Homebrew/test/rubocops/text_spec.rb b/Library/Homebrew/test/rubocops/text_spec.rb index b446cebd26..38204d4ef6 100644 --- a/Library/Homebrew/test/rubocops/text_spec.rb +++ b/Library/Homebrew/test/rubocops/text_spec.rb @@ -210,7 +210,7 @@ describe RuboCop::Cop::FormulaAudit::Text do def install system "cargo", "build" - ^^^^^^^^^^^^^^^^^^^^^^^ use \"cargo\", \"install\", \"--root\", prefix, \"--path\", \".\" + ^^^^^^^^^^^^^^^^^^^^^^^ use \"cargo\", \"install\", *std_cargo_args end end RUBY