]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bitbake: cookerdata: Add a function to find TOPDIR
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 18 Jul 2017 21:18:53 +0000 (22:18 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 21 Jul 2017 07:41:11 +0000 (08:41 +0100)
Finding the top level build directory is currently hard and relies on
having a complete cooker being setup. Add a helper function which
does the same thing without all the extra overhead. This is needed
to be able to locate the bitbake lockfile and hence the socket
for connecting clients in the new server model.

(Bitbake rev: d196afe68032898c31a8599ca7d3ceba58d96b0a)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/bb/cookerdata.py

index c2aeee63fb3cfccccb8c08585f9f52de8b01cede..6511dcbfade40a30a9b617c4ef7ad5b587e50603 100644 (file)
@@ -230,6 +230,27 @@ def findConfigFile(configfile, data):
 
     return None
 
+#
+# We search for a conf/bblayers.conf under an entry in BBPATH or in cwd working 
+# up to /. If that fails, we search for a conf/bitbake.conf in BBPATH.
+#
+
+def findTopdir():
+    d = bb.data.init()
+    bbpath = None
+    if 'BBPATH' in os.environ:
+        bbpath = os.environ['BBPATH']
+        d.setVar('BBPATH', bbpath)
+
+    layerconf = findConfigFile("bblayers.conf", d)
+    if layerconf:
+        return os.path.dirname(os.path.dirname(layerconf))
+    if bbpath:
+        bitbakeconf = bb.utils.which(bbpath, "conf/bitbake.conf")
+        if bitbakeconf:
+            return os.path.dirname(os.path.dirname(bitbakeconf))
+    return None
+
 class CookerDataBuilder(object):
 
     def __init__(self, cookercfg, worker = False):