Merge pull request #17122 from Homebrew/deps-simulated-os-and-arch

cmd/deps: add `--os` and `--arch`
This commit is contained in:
Mike McQuaid 2024-04-22 13:37:09 +01:00 committed by GitHub
commit af2d356c39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -66,6 +66,10 @@ module Homebrew
"debugging the `--installed`/`--eval-all` display mode." "debugging the `--installed`/`--eval-all` display mode."
switch "--HEAD", switch "--HEAD",
description: "Show dependencies for HEAD version instead of stable version." description: "Show dependencies for HEAD version instead of stable version."
flag "--os=",
description: "Show dependencies for the given operating system."
flag "--arch=",
description: "Show dependencies for the given CPU architecture."
switch "--formula", "--formulae", switch "--formula", "--formulae",
description: "Treat all named arguments as formulae." description: "Treat all named arguments as formulae."
switch "--cask", "--casks", switch "--cask", "--casks",
@ -82,10 +86,15 @@ module Homebrew
sig { override.void } sig { override.void }
def run def run
raise UsageError, "`brew deps --os=all` is not supported" if args.os == "all"
raise UsageError, "`brew deps --arch=all` is not supported" if args.arch == "all"
os, arch = T.must(args.os_arch_combinations.first)
all = args.eval_all? all = args.eval_all?
Formulary.enable_factory_cache! Formulary.enable_factory_cache!
SimulateSystem.with(os:, arch:) do
recursive = !args.direct? recursive = !args.direct?
installed = args.installed? || dependents(args.named.to_formulae_and_casks).all?(&:any_version_installed?) installed = args.installed? || dependents(args.named.to_formulae_and_casks).all?(&:any_version_installed?)
@ -97,7 +106,9 @@ module Homebrew
!args.include_test? && !args.include_test? &&
!args.include_optional? && !args.include_optional? &&
!args.skip_recommended? && !args.skip_recommended? &&
!args.missing? !args.missing? &&
args.os.nil? &&
args.arch.nil?
if args.tree? || args.graph? if args.tree? || args.graph?
dependents = if args.named.present? dependents = if args.named.present?
@ -162,6 +173,7 @@ module Homebrew
all_deps.sort! unless args.topological? all_deps.sort! unless args.topological?
puts all_deps puts all_deps
end end
end
private private