Skip to content

Commit

Permalink
shims/super/cc: handle double dash in args
Browse files Browse the repository at this point in the history
  • Loading branch information
alebcay committed Jan 12, 2025
1 parent 1e91082 commit 3171a64
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions Library/Homebrew/shims/super/cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class Cmd

def initialize(arg0, args)
@arg0 = arg0
@args = args.freeze
provided_args = split_args(args)
@args = provided_args[0].freeze
@positional_args = provided_args[1].freeze
@config = ENV.fetch("HOMEBREW_CCCFG", "")
@prefix = ENV["HOMEBREW_PREFIX"]
@cellar = ENV["HOMEBREW_CELLAR"]
Expand All @@ -57,6 +59,15 @@ class Cmd
@keg_regex = %r{(#{Regexp.escape(opt)}|#{Regexp.escape(cellar)})/([\w+-.@]+)}
end

def split_args(args)
double_dash_index = args.find_index("--")
if double_dash_index
[args[0...double_dash_index], args[double_dash_index..-1]]
else
[args, []]
end
end

def mode
if @arg0 == "cpp"
:cpp
Expand Down Expand Up @@ -132,19 +143,19 @@ class Cmd

case mode
when :ccld
cflags + args + cppflags + ldflags
cflags + args + cppflags + ldflags + @positional_args
when :cxxld
cxxflags + args + cppflags + ldflags
cxxflags + args + cppflags + ldflags + @positional_args
when :cc
cflags + args + cppflags
cflags + args + cppflags + @positional_args
when :cxx
cxxflags + args + cppflags
cxxflags + args + cppflags + @positional_args
when :ccE
args + cppflags
args + cppflags + @positional_args
when :cpp
args + cppflags
args + cppflags + @positional_args
when :ld
ldflags + args
ldflags + args + @positional_args
end
end

Expand Down

0 comments on commit 3171a64

Please sign in to comment.