bug 2975: Find brew-installed dependencies
authorTom Henderson <tomh@tomh.org>
Fri, 24 Aug 2018 17:21:33 -0700
changeset 411 a9bc3124a563
parent 410 0a2832dd34ce
child 412 b11b3c0dbe80
bug 2975: Find brew-installed dependencies
bake/ModuleEnvironment.py
--- a/bake/ModuleEnvironment.py	Thu Aug 16 17:02:40 2018 -0700
+++ b/bake/ModuleEnvironment.py	Fri Aug 24 17:21:33 2018 -0700
@@ -266,7 +266,7 @@
             index=program.find(".so") + program.find(".a")
             if index>0 :
                 toFindIn=['/usr/lib','/usr/lib64','/usr/lib32','/usr/local/lib',
-                     '/lib','/opt/local/lib','/opt/local/Library']
+                     '/lib','/opt/local/lib','/opt/local/Library', '/usr/local/opt']
                 for libpath in self._libpaths:
                     toFindIn.append(libpath)
                 stdLibs = []
@@ -280,25 +280,21 @@
                 tofindIn=toFindIn+stdLibs+[self._lib_path()]
 
             elif program.endswith(".h"):
-                toFindIn=['/usr/include', '/usr/local/include', '/usr/lib','/opt/local/include']  
+                toFindIn=['/usr/include', '/usr/local/include', '/usr/lib','/opt/local/include', '/usr/local/opt']  
                  
             if toFindIn : 
                 for eachdir in toFindIn:
-                    for dirname, dirnames, filenames in os.walk(eachdir):
-#                        print (dirname)
-                    # print path to all filenames.
-                        for filename in filenames:
-                            if filename==name:
-                                return os.path.join(dirname, filename)
-#
-#
-#
-#
-#                for path in (stdLibs + tmp + 
-#                             [self._lib_path()]):
-#                    lib_file = os.path.join(path, program)
-#                    if os.path.exists(lib_file):
-#                        return lib_file
+                    if sys.platform == "darwin":
+                        # enable symlink walking for MacOS only (bug 2975)
+                        for dirname, dirnames, filenames in os.walk(eachdir, True, None, True):
+                            for filename in filenames:
+                                if filename==name:
+                                    return os.path.join(dirname, filename)
+                    else:
+                        for dirname, dirnames, filenames in os.walk(eachdir):
+                            for filename in filenames:
+                                if filename==name:
+                                    return os.path.join(dirname, filename)
              
         return None