Merge pull request #19082 from alebcay/cc-handle-double-dash

shims/super/cc: handle double dash in args
This commit is contained in:
Mike McQuaid 2025-01-13 09:03:20 +00:00 committed by GitHub
commit 880bfb577c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -40,7 +40,9 @@ class Cmd
def initialize(arg0, args)
@arg0 = arg0
@args = args.freeze
split_args = split_args_at_double_dash(args)
@args = split_args[0].freeze
@positional_args = split_args[1].freeze
@config = ENV.fetch("HOMEBREW_CCCFG", "")
@prefix = ENV["HOMEBREW_PREFIX"]
@cellar = ENV["HOMEBREW_CELLAR"]
@ -57,6 +59,15 @@ class Cmd
@keg_regex = %r{(#{Regexp.escape(opt)}|#{Regexp.escape(cellar)})/([\w+-.@]+)}
end
def split_args_at_double_dash(args)
double_dash_index = args.find_index("--")
if double_dash_index
[args[...double_dash_index], args[double_dash_index..]]
else
[args, []]
end
end
def mode
if @arg0 == "cpp"
:cpp
@ -130,7 +141,7 @@ class Cmd
end
end
case mode
optional_args = case mode
when :ccld
cflags + args + cppflags + ldflags
when :cxxld
@ -146,6 +157,8 @@ class Cmd
when :ld
ldflags + args
end
optional_args + @positional_args
end
def refurbished_args