2024-09-09 08:52:07 +00:00
|
|
|
# Generate the bblayers.conf file for the current build workspace
|
|
|
|
# emitted to stdout for simplicity.
|
|
|
|
|
|
|
|
import os, sys, fnmatch, re
|
|
|
|
from operator import itemgetter
|
|
|
|
|
|
|
|
# Trawl the OEROOT as passed to us and find all the layer files that meet our
|
|
|
|
# metadata directory criteria...
|
|
|
|
def getLayerPaths(target, fnexpr) :
|
|
|
|
retList = []
|
|
|
|
for file in os.listdir(target) :
|
2024-09-09 08:57:42 +00:00
|
|
|
if (fnmatch.fnmatch(file, fnexpr) and not
|
|
|
|
(fnmatch.fnmatch(file, "meta-hob") or
|
|
|
|
fnmatch.fnmatch(file, "meta-skeleton") or
|
|
|
|
fnmatch.fnmatch(file, "meta-selftest"))):
|
2024-09-09 08:52:07 +00:00
|
|
|
# Found what might be a metadata layer...
|
|
|
|
layerPath = target + "/" + file
|
|
|
|
layerConfPath = layerPath + "/conf/layer.conf"
|
|
|
|
if os.path.exists(layerConfPath) :
|
|
|
|
# Found a layer. Find the priority for it...
|
|
|
|
confFile = open(layerConfPath, "r")
|
|
|
|
if (confFile != None) :
|
|
|
|
for line in confFile :
|
|
|
|
fields = line.split()
|
|
|
|
if (len(fields) > 0 and re.match("BBFILE_PRIORITY", fields[0])) :
|
|
|
|
# Add the path, priority as a tuple to the list for the layer.
|
|
|
|
retList += [( layerPath, int(fields[2].strip("\"")) )]
|
|
|
|
break
|
|
|
|
confFile.close()
|
|
|
|
# In order to avoid potential namespace conflicts, between recipes on layers
|
|
|
|
# we sort the list in descending order of priority.
|
|
|
|
return sorted(retList, key=itemgetter(1), reverse=True)
|
|
|
|
|
|
|
|
|
|
|
|
# Just spool the tuple list's paths out in order to a string...
|
|
|
|
def generatePathString ( pathList ):
|
|
|
|
retString = ""
|
|
|
|
for path, priority in pathList:
|
|
|
|
retString = retString + path + " "
|
|
|
|
return retString.strip()
|
|
|
|
|
|
|
|
|
|
|
|
# Emit our config file...
|
|
|
|
print "# This configuration file is dynamically generated every time"
|
|
|
|
print "# set_bb_env.sh is sourced to set up a workspace. DO NOT EDIT."
|
|
|
|
print "#--------------------------------------------------------------"
|
2024-09-09 08:57:42 +00:00
|
|
|
print "LCONF_VERSION = \"6\""
|
2024-09-09 08:52:07 +00:00
|
|
|
print
|
|
|
|
print "export WORKSPACE := \"${@os.path.abspath(os.path.join(os.path.dirname(bb.data.getVar('FILE', d)),'../../..'))}\""
|
2024-09-09 08:57:42 +00:00
|
|
|
#print "# Make sure WORKSPACE isn't exported"
|
|
|
|
#print "WORKSPACE[unexport] = \"1\""
|
2024-09-09 08:52:07 +00:00
|
|
|
print
|
2024-09-09 08:57:42 +00:00
|
|
|
print "BBPATH = \"${TOPDIR}\""
|
2024-09-09 08:52:07 +00:00
|
|
|
print "BBFILES ?= \"\""
|
|
|
|
print "BBLAYERS = \"" + generatePathString(getLayerPaths(sys.argv[1].strip("\""), sys.argv[2].strip("\""))) + "\""
|
|
|
|
|
|
|
|
|
|
|
|
|