bitbake: bitbake-layers: make show-cross-depends avoid long path
The "bitbake-layers show-cross-depends" print the absolute path in the past, now it will print the relative path (relative to the layer dir) by default, and add the "-f" option to make it print the absolute path. For example: $ bitbake-layers show-cross-depends [snip] meta-intel/meta-jasperforest/conf/machine/jasperforest.conf requires meta/conf/machine/include/ia32-base.inc [snip] $ bitbake-layers show-cross-depends -f [snip] /path/to/poky/meta-intel/meta-jasperforest/conf/machine/jasperforest.conf requires /path/to/poky/meta/conf/machine/include/ia32-base.inc [snip] [YOCTO #3824] (Bitbake rev: df217701318d60559be0b10214b883b8ce4f5d2a) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
2c5ad4059e
commit
86ac3b53b5
|
@ -463,6 +463,21 @@ build results (as the layer priority order has effectively changed).
|
||||||
return self.get_layer_name(layerdir)
|
return self.get_layer_name(layerdir)
|
||||||
return "?"
|
return "?"
|
||||||
|
|
||||||
|
def get_file_layerdir(self, filename):
|
||||||
|
for layer, _, regex, _ in self.bbhandler.cooker.status.bbfile_config_priorities:
|
||||||
|
if regex.match(filename):
|
||||||
|
for layerdir in self.bblayers:
|
||||||
|
if regex.match(os.path.join(layerdir, 'test')) and re.match(layerdir, filename):
|
||||||
|
return layerdir
|
||||||
|
return "?"
|
||||||
|
|
||||||
|
def remove_layer_prefix(self, f):
|
||||||
|
"""Remove the layer_dir prefix, e.g., f = /path/to/layer_dir/foo/blah, the
|
||||||
|
return value will be: layer_dir/foo/blah"""
|
||||||
|
f_layerdir = self.get_file_layerdir(f)
|
||||||
|
prefix = os.path.join(os.path.dirname(f_layerdir), '')
|
||||||
|
return f[len(prefix):] if f.startswith(prefix) else f
|
||||||
|
|
||||||
def get_layer_name(self, layerdir):
|
def get_layer_name(self, layerdir):
|
||||||
return os.path.basename(layerdir.rstrip(os.sep))
|
return os.path.basename(layerdir.rstrip(os.sep))
|
||||||
|
|
||||||
|
@ -545,14 +560,27 @@ Recipes are listed with the bbappends that apply to them as subitems.
|
||||||
def do_show_cross_depends(self, args):
|
def do_show_cross_depends(self, args):
|
||||||
"""figure out the dependency between recipes that crosses a layer boundary.
|
"""figure out the dependency between recipes that crosses a layer boundary.
|
||||||
|
|
||||||
usage: show-cross-depends
|
usage: show-cross-depends [-f]
|
||||||
|
|
||||||
Figure out the dependency between recipes that crosses a layer boundary.
|
Figure out the dependency between recipes that crosses a layer boundary.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-f show full file path
|
||||||
|
|
||||||
NOTE:
|
NOTE:
|
||||||
The .bbappend file can impact the dependency.
|
The .bbappend file can impact the dependency.
|
||||||
"""
|
"""
|
||||||
self.bbhandler.prepare()
|
self.bbhandler.prepare()
|
||||||
|
|
||||||
|
show_filenames = False
|
||||||
|
for arg in args.split():
|
||||||
|
if arg == '-f':
|
||||||
|
show_filenames = True
|
||||||
|
else:
|
||||||
|
sys.stderr.write("show-cross-depends: invalid option %s\n" % arg)
|
||||||
|
self.do_help('')
|
||||||
|
return
|
||||||
|
|
||||||
pkg_fn = self.bbhandler.cooker_data.pkg_fn
|
pkg_fn = self.bbhandler.cooker_data.pkg_fn
|
||||||
bbpath = str(self.bbhandler.config_data.getVar('BBPATH', True))
|
bbpath = str(self.bbhandler.config_data.getVar('BBPATH', True))
|
||||||
self.require_re = re.compile(r"require\s+(.+)")
|
self.require_re = re.compile(r"require\s+(.+)")
|
||||||
|
@ -573,7 +601,7 @@ The .bbappend file can impact the dependency.
|
||||||
self.bbhandler.cooker.configuration.data,
|
self.bbhandler.cooker.configuration.data,
|
||||||
self.bbhandler.cooker_data,
|
self.bbhandler.cooker_data,
|
||||||
self.bbhandler.cooker_data.pkg_pn)
|
self.bbhandler.cooker_data.pkg_pn)
|
||||||
self.check_cross_depends("DEPENDS", layername, f, best[3])
|
self.check_cross_depends("DEPENDS", layername, f, best[3], show_filenames)
|
||||||
|
|
||||||
# The RDPENDS
|
# The RDPENDS
|
||||||
all_rdeps = self.bbhandler.cooker_data.rundeps[f].values()
|
all_rdeps = self.bbhandler.cooker_data.rundeps[f].values()
|
||||||
|
@ -590,7 +618,7 @@ The .bbappend file can impact the dependency.
|
||||||
best = bb.providers.filterProvidersRunTime(all_p, rdep,
|
best = bb.providers.filterProvidersRunTime(all_p, rdep,
|
||||||
self.bbhandler.cooker.configuration.data,
|
self.bbhandler.cooker.configuration.data,
|
||||||
self.bbhandler.cooker_data)[0][0]
|
self.bbhandler.cooker_data)[0][0]
|
||||||
self.check_cross_depends("RDEPENDS", layername, f, best)
|
self.check_cross_depends("RDEPENDS", layername, f, best, show_filenames)
|
||||||
|
|
||||||
# The inherit class
|
# The inherit class
|
||||||
cls_re = re.compile('classes/')
|
cls_re = re.compile('classes/')
|
||||||
|
@ -602,7 +630,12 @@ The .bbappend file can impact the dependency.
|
||||||
if not cls_re.match(cls):
|
if not cls_re.match(cls):
|
||||||
inherit_layername = self.get_file_layer(cls)
|
inherit_layername = self.get_file_layer(cls)
|
||||||
if inherit_layername != layername:
|
if inherit_layername != layername:
|
||||||
logger.plain("%s inherits %s" % (f, cls))
|
if not show_filenames:
|
||||||
|
f_short = self.remove_layer_prefix(f)
|
||||||
|
cls = self.remove_layer_prefix(cls)
|
||||||
|
else:
|
||||||
|
f_short = f
|
||||||
|
logger.plain("%s inherits %s" % (f_short, cls))
|
||||||
|
|
||||||
# The 'require/include xxx' in the bb file
|
# The 'require/include xxx' in the bb file
|
||||||
pv_re = re.compile(r"\${PV}")
|
pv_re = re.compile(r"\${PV}")
|
||||||
|
@ -617,7 +650,7 @@ The .bbappend file can impact the dependency.
|
||||||
if pv_re.search(needed_file) and f in self.bbhandler.cooker_data.pkg_pepvpr:
|
if pv_re.search(needed_file) and f in self.bbhandler.cooker_data.pkg_pepvpr:
|
||||||
pv = self.bbhandler.cooker_data.pkg_pepvpr[f][1]
|
pv = self.bbhandler.cooker_data.pkg_pepvpr[f][1]
|
||||||
needed_file = re.sub(r"\${PV}", pv, needed_file)
|
needed_file = re.sub(r"\${PV}", pv, needed_file)
|
||||||
self.print_cross_files(bbpath, keyword, layername, f, needed_file)
|
self.print_cross_files(bbpath, keyword, layername, f, needed_file, show_filenames)
|
||||||
line = fnfile.readline()
|
line = fnfile.readline()
|
||||||
fnfile.close()
|
fnfile.close()
|
||||||
|
|
||||||
|
@ -644,17 +677,20 @@ The .bbappend file can impact the dependency.
|
||||||
bbclass=".bbclass"
|
bbclass=".bbclass"
|
||||||
# Find a 'require/include xxxx'
|
# Find a 'require/include xxxx'
|
||||||
if m:
|
if m:
|
||||||
self.print_cross_files(bbpath, keyword, layername, f, m.group(1) + bbclass)
|
self.print_cross_files(bbpath, keyword, layername, f, m.group(1) + bbclass, show_filenames)
|
||||||
line = ffile.readline()
|
line = ffile.readline()
|
||||||
ffile.close()
|
ffile.close()
|
||||||
|
|
||||||
def print_cross_files(self, bbpath, keyword, layername, f, needed_filename):
|
def print_cross_files(self, bbpath, keyword, layername, f, needed_filename, show_filenames):
|
||||||
"""Print the depends that crosses a layer boundary"""
|
"""Print the depends that crosses a layer boundary"""
|
||||||
needed_file = bb.utils.which(bbpath, needed_filename)
|
needed_file = bb.utils.which(bbpath, needed_filename)
|
||||||
if needed_file:
|
if needed_file:
|
||||||
# Which layer is this file from
|
# Which layer is this file from
|
||||||
needed_layername = self.get_file_layer(needed_file)
|
needed_layername = self.get_file_layer(needed_file)
|
||||||
if needed_layername != layername:
|
if needed_layername != layername:
|
||||||
|
if not show_filenames:
|
||||||
|
f = self.remove_layer_prefix(f)
|
||||||
|
needed_file = self.remove_layer_prefix(needed_file)
|
||||||
logger.plain("%s %s %s" %(f, keyword, needed_file))
|
logger.plain("%s %s %s" %(f, keyword, needed_file))
|
||||||
def match_inherit(self, line):
|
def match_inherit(self, line):
|
||||||
"""Match the inherit xxx line"""
|
"""Match the inherit xxx line"""
|
||||||
|
@ -669,11 +705,15 @@ The .bbappend file can impact the dependency.
|
||||||
keyword = "includes"
|
keyword = "includes"
|
||||||
return (m, keyword)
|
return (m, keyword)
|
||||||
|
|
||||||
def check_cross_depends(self, keyword, layername, f, needed_file):
|
def check_cross_depends(self, keyword, layername, f, needed_file, show_filenames):
|
||||||
"""Print the DEPENDS/RDEPENDS file that crosses a layer boundary"""
|
"""Print the DEPENDS/RDEPENDS file that crosses a layer boundary"""
|
||||||
best_realfn = bb.cache.Cache.virtualfn2realfn(needed_file)[0]
|
best_realfn = bb.cache.Cache.virtualfn2realfn(needed_file)[0]
|
||||||
needed_layername = self.get_file_layer(best_realfn)
|
needed_layername = self.get_file_layer(best_realfn)
|
||||||
if needed_layername != layername:
|
if needed_layername != layername:
|
||||||
|
if not show_filenames:
|
||||||
|
f = self.remove_layer_prefix(f)
|
||||||
|
best_realfn = self.remove_layer_prefix(best_realfn)
|
||||||
|
|
||||||
logger.plain("%s %s %s" % (f, keyword, best_realfn))
|
logger.plain("%s %s %s" % (f, keyword, best_realfn))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue