aboutsummaryrefslogtreecommitdiffstats
path: root/Library/ENV
diff options
context:
space:
mode:
authorMisty De Meo2016-03-24 11:18:30 -0700
committerMisty De Meo2016-04-04 15:30:22 -0700
commit4fd5c5c159c0f8d2f848524e98d4cc938e2207e8 (patch)
treed0275f9243e26782756b3995ce8641020a847705 /Library/ENV
parentfa3c55aa650e815ce548e1276845171def2847f4 (diff)
downloadbrew-4fd5c5c159c0f8d2f848524e98d4cc938e2207e8.tar.bz2
superenv: filter -I/-L paths on dependencies
Previously, superenv did not try to filter -I or -L flags based on the list of requested dependencies; as a result, buildsystems which opportunistically discover Homebrew-installed libraries were able to link against them even under superenv. This adds a list of all requested dependencies to the superenv environment, and compares all -I and -L flags against those; any Cellar and opt paths found which resolve to unrequested dependencies are filtered out.
Diffstat (limited to 'Library/ENV')
-rwxr-xr-xLibrary/ENV/4.3/cc19
1 files changed, 16 insertions, 3 deletions
diff --git a/Library/ENV/4.3/cc b/Library/ENV/4.3/cc
index 0d07db00f..28c78b4f5 100755
--- a/Library/ENV/4.3/cc
+++ b/Library/ENV/4.3/cc
@@ -14,8 +14,8 @@ require "pathname"
require "set"
class Cmd
- attr_reader :config, :prefix, :cellar, :tmpdir, :sysroot
- attr_reader :archflags, :optflags
+ attr_reader :config, :prefix, :cellar, :opt, :tmpdir, :sysroot, :deps
+ attr_reader :archflags, :optflags, :keg_regex
def initialize(arg0, args)
@arg0 = arg0
@@ -23,10 +23,14 @@ class Cmd
@config = ENV.fetch("HOMEBREW_CCCFG") { "" }
@prefix = ENV["HOMEBREW_PREFIX"]
@cellar = ENV["HOMEBREW_CELLAR"]
+ @opt = ENV["HOMEBREW_OPT"]
@tmpdir = ENV["HOMEBREW_TEMP"]
@sysroot = ENV["HOMEBREW_SDKROOT"]
@archflags = ENV.fetch("HOMEBREW_ARCHFLAGS") { "" }.split(" ")
@optflags = ENV.fetch("HOMEBREW_OPTFLAGS") { "" }.split(" ")
+ @deps = Set.new(ENV.fetch("HOMEBREW_DEPENDENCIES") { "" }.split(","))
+ # matches opt or cellar prefix and formula name
+ @keg_regex = %r[(#{Regexp.escape(opt)}|#{Regexp.escape(cellar)})/([\w\-_\+]+)]
end
def mode
@@ -197,7 +201,16 @@ class Cmd
end
def keep?(path)
- path.start_with?(prefix, cellar, tmpdir) || !path.start_with?("/opt", "/sw", "/usr/X11")
+ # first two paths: reject references to Cellar or opt paths
+ # for unspecified dependencies
+ if path.start_with?(cellar) || path.start_with?(opt)
+ dep = path[keg_regex, 2]
+ dep && @deps.include?(dep)
+ elsif path.start_with?(prefix)
+ true
+ else
+ !path.start_with?("/opt", "/sw", "/usr/X11")
+ end
end
def cflags