Skip to content

Commit

Permalink
formula: add std_cargo_args
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimyr committed Jun 22, 2020
1 parent a89b565 commit 8a62f89
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,11 @@ def inspect
"#<Formula #{name} (#{active_spec_sym}) #{path}>"
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
Expand Down Expand Up @@ -1930,6 +1935,8 @@ def system(cmd, *args)
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"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/formula_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def install
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",
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/rubocops/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)
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
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/rubocops/text_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class Foo < Formula
def install
system "cargo", "build"
^^^^^^^^^^^^^^^^^^^^^^^ use \"cargo\", \"install\", \"--root\", prefix, \"--path\", \".\"
^^^^^^^^^^^^^^^^^^^^^^^ use \"cargo\", \"install\", *std_cargo_args
end
end
RUBY
Expand Down

0 comments on commit 8a62f89

Please sign in to comment.