diff --git a/Library/Homebrew/build_options.rb b/Library/Homebrew/build_options.rb index 6c6952d710..8d9e349049 100644 --- a/Library/Homebrew/build_options.rb +++ b/Library/Homebrew/build_options.rb @@ -83,6 +83,11 @@ class BuildOptions include?("c++11") && option_defined?("c++11") end + # True if the build has any arguments or options specified. + def any_args_or_options? + !@args.empty? || !@options.empty? + end + # @private def used_options @options & @args diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 2e89d14197..fdb9fc1324 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1525,7 +1525,12 @@ class Formula def declared_runtime_dependencies recursive_dependencies do |_, dependency| Dependency.prune if dependency.build? - Dependency.prune if !dependency.required? && build.without?(dependency) + next if dependency.required? + if build.any_args_or_options? + Dependency.prune if build.without?(dependency) + elsif !dependency.recommended? + Dependency.prune + end end end