From b40e33aeb842ad7b6831d8ec5926b99034690fd6 Mon Sep 17 00:00:00 2001 From: Gautham G Date: Sun, 3 May 2020 19:00:36 +0530 Subject: [PATCH] ARGV: Deprecate ARGV.cc and replace with Homebrew.args.cc --- Library/Homebrew/extend/ARGV.rb | 4 ---- Library/Homebrew/extend/ENV/shared.rb | 2 +- Library/Homebrew/formula_installer.rb | 4 ++-- Library/Homebrew/install.rb | 4 ++-- Library/Homebrew/test/formula_installer_bottle_spec.rb | 3 ++- Library/Homebrew/test/formula_installer_spec.rb | 8 +++----- 6 files changed, 10 insertions(+), 15 deletions(-) diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index c75c81b67c..784f714d0b 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -16,10 +16,6 @@ module HomebrewArgvExtension arch&.to_sym end - def cc - value "cc" - end - def env value "env" end diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb index 0f6fda16e4..cef4c07f63 100644 --- a/Library/Homebrew/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/ENV/shared.rb @@ -162,7 +162,7 @@ module SharedEnvExtension # ENV.append_to_cflags "-I ./missing/includes" # end def compiler - @compiler ||= if (cc = ARGV.cc) + @compiler ||= if (cc = Homebrew.args.cc) warn_about_non_apple_gcc($&) if cc =~ GNU_GCC_REGEXP fetch_compiler(cc, "--cc") elsif (cc = homebrew_cc) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index da9135767d..fb66acdb23 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -98,7 +98,7 @@ class FormulaInstaller return false if !formula.bottled? && !formula.local_bottle_path return true if force_bottle? return false if build_from_source? || build_bottle? || interactive? - return false if ARGV.cc + return false if Homebrew.args.cc return false unless options.empty? return false if formula.bottle_disabled? @@ -706,7 +706,7 @@ class FormulaInstaller args << "--interactive" if interactive? args << "--verbose" if verbose? args << "--debug" if debug? - args << "--cc=#{ARGV.cc}" if ARGV.cc + args << "--cc=#{Homebrew.args.cc}" if Homebrew.args.cc args << "--default-fortran-flags" if ARGV.include? "--default-fortran-flags" args << "--keep-tmp" if Homebrew.args.keep_tmp? diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb index 4a3f031327..18bc534d85 100644 --- a/Library/Homebrew/install.rb +++ b/Library/Homebrew/install.rb @@ -37,11 +37,11 @@ module Homebrew end def check_cc_argv - return unless ARGV.cc + return unless Homebrew.args.cc @checks ||= Diagnostic::Checks.new opoo <<~EOS - You passed `--cc=#{ARGV.cc}`. + You passed `--cc=#{Homebrew.args.cc}`. #{@checks.please_create_pull_requests} EOS end diff --git a/Library/Homebrew/test/formula_installer_bottle_spec.rb b/Library/Homebrew/test/formula_installer_bottle_spec.rb index d1a86b59c2..bf2d6576b4 100644 --- a/Library/Homebrew/test/formula_installer_bottle_spec.rb +++ b/Library/Homebrew/test/formula_installer_bottle_spec.rb @@ -4,6 +4,7 @@ require "formula" require "formula_installer" require "keg" require "tab" +require "cmd/install" require "test/support/fixtures/testball" require "test/support/fixtures/testball_bottle" @@ -46,7 +47,7 @@ describe FormulaInstaller do specify "basic bottle install" do allow(DevelopmentTools).to receive(:installed?).and_return(false) - + Homebrew.install_args.parse("testball_bottle") temporarily_install_bottle(TestballBottle.new) do |f| # Copied directly from formula_installer_spec.rb # as we expect the same behavior. diff --git a/Library/Homebrew/test/formula_installer_spec.rb b/Library/Homebrew/test/formula_installer_spec.rb index d7dcd713c1..6ddef8faad 100644 --- a/Library/Homebrew/test/formula_installer_spec.rb +++ b/Library/Homebrew/test/formula_installer_spec.rb @@ -4,6 +4,7 @@ require "formula" require "formula_installer" require "keg" require "tab" +require "cmd/install" require "test/support/fixtures/testball" require "test/support/fixtures/testball_bottle" require "test/support/fixtures/failball" @@ -89,11 +90,8 @@ describe FormulaInstaller do end specify "Formula is not poured from bottle when compiler specified" do - expect(ARGV.cc).to be nil - - cc_arg = "--cc=clang" - ARGV << cc_arg - + expect(Homebrew.args.cc).to be nil + Homebrew.install_args.parse(["--cc=clang", "testball_bottle"]) temporary_install(TestballBottle.new) do |f| tab = Tab.for_formula(f) expect(tab.compiler).to eq("clang")