[bitbake-devel] [PATCH 1/1] bitbake: Add new otpion --environment-more

Lianhao Lu lianhao.lu at intel.com
Thu Feb 23 08:49:26 UTC 2012


Added a new otpion --environment-more, similar to --environment but
displaying addtional file dependency informations in the shell variable
"__depends".

Signed-off-by: Lianhao Lu <lianhao.lu at intel.com>
---
 bitbake/bin/bitbake       |    3 +++
 bitbake/lib/bb/command.py |    6 ++++--
 bitbake/lib/bb/cooker.py  |   22 ++++++++++++++++++----
 scripts/bitbake           |    2 +-
 4 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
index 6da4980..efe9980 100755
--- a/bitbake/bin/bitbake
+++ b/bitbake/bin/bitbake
@@ -144,6 +144,9 @@ Default BBFILES are the .bb files in the current directory.""")
     parser.add_option("-e", "--environment", help = "show the global or per-package environment (this is what used to be bbread)",
                action = "store_true", dest = "show_environment", default = False)
 
+    parser.add_option("", "--environment-more", help = "same as --environment, but with more information",
+               action = "store_true", dest = "show_environment_more", default = False)
+
     parser.add_option("-g", "--graphviz", help = "emit the dependency trees of the specified packages in the dot syntax",
                 action = "store_true", dest = "dot_graph", default = False)
 
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index 2a3a3af..d2dd99c 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -299,8 +299,9 @@ class CommandsAsync:
         (needs the cache to work out which recipe to use)
         """
         pkg = params[0]
+        more = params[1]
 
-        command.cooker.showEnvironment(None, pkg)
+        command.cooker.showEnvironment(None, pkg, more)
         command.finishAsyncCommand()
     showEnvironmentTarget.needcache = True
 
@@ -310,8 +311,9 @@ class CommandsAsync:
         or if specified the environment for a specified recipe
         """
         bfile = params[0]
+        more = params[1]
 
-        command.cooker.showEnvironment(bfile)
+        command.cooker.showEnvironment(bfile, [], more)
         command.finishAsyncCommand()
     showEnvironment.needcache = False
 
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index f0778e5..b241bc0 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -212,7 +212,7 @@ class BBCooker:
     def parseCommandLine(self):
         # Parse any commandline into actions
         self.commandlineAction = {'action':None, 'msg':None}
-        if self.configuration.show_environment:
+        if self.configuration.show_environment or self.configuration.show_environment_more:
             if 'world' in self.configuration.pkgs_to_build:
                 self.commandlineAction['msg'] = "'world' is not a valid target for --environment."
             elif 'universe' in self.configuration.pkgs_to_build:
@@ -222,9 +222,9 @@ class BBCooker:
             elif self.configuration.buildfile and len(self.configuration.pkgs_to_build) > 0:
                 self.commandlineAction['msg'] = "No target should be used with the --environment and --buildfile options."
             elif len(self.configuration.pkgs_to_build) > 0:
-                self.commandlineAction['action'] = ["showEnvironmentTarget", self.configuration.pkgs_to_build]
+                self.commandlineAction['action'] = ["showEnvironmentTarget", self.configuration.pkgs_to_build, self.configuration.show_environment_more]
             else:
-                self.commandlineAction['action'] = ["showEnvironment", self.configuration.buildfile]
+                self.commandlineAction['action'] = ["showEnvironment", self.configuration.buildfile, self.configuration.show_environment_more]
         elif self.configuration.buildfile is not None:
             self.commandlineAction['action'] = ["buildFile", self.configuration.buildfile, self.configuration.cmd]
         elif self.configuration.revisions_changed:
@@ -277,7 +277,7 @@ class BBCooker:
 
             logger.plain("%-35s %25s %25s", p, lateststr, prefstr)
 
-    def showEnvironment(self, buildfile = None, pkgs_to_build = []):
+    def showEnvironment(self, buildfile = None, pkgs_to_build = [], more = False):
         """
         Show the outer or per-package environment
         """
@@ -330,6 +330,20 @@ class BBCooker:
             if data.getVarFlag( e, 'python', envdata ):
                 logger.plain("\npython %s () {\n%s}\n", e, data.getVar(e, envdata, 1))
 
+        # more depends data
+        if more:
+            if fn:
+                realfn, _ = bb.cache.Cache.virtualfn2realfn(fn)
+                logger.plain("\n__file=\"%s\"", realfn)
+            dep_files = []
+            depends = envdata.getVar('__depends', True) or set()
+            depends = depends.union(self.configuration.data.getVar('__base_depends', True) or set())
+            depends = depends.union(self.configuration.data.getVar('__depends', True) or set())
+            for (fn, ctime) in depends:
+                dep_files.append(os.path.abspath(fn))
+            if dep_files:
+                logger.plain("__depends=\"%s\"\n" , " ".join(dep_files))
+
     def prepareTreeData(self, pkgs_to_build, task):
         """
         Prepare a runqueue and taskdata object for iteration over pkgs_to_build
diff --git a/scripts/bitbake b/scripts/bitbake
index dda3b26..d77ecb5 100755
--- a/scripts/bitbake
+++ b/scripts/bitbake
@@ -3,7 +3,7 @@
 export BBFETCH2=True
 export BB_ENV_EXTRAWHITE="PSEUDO_BUILD PSEUDO_DISABLED $BB_ENV_EXTRAWHITE"
 
-NO_BUILD_OPTS="--version -h --help -p --parse-only -s --show-versions -e --environment -g --graphviz"
+NO_BUILD_OPTS="--version -h --help -p --parse-only -s --show-versions -e --environment --environment-more -g --graphviz"
 PASSTHROUGH_OPTS="-D -DD -DDD -DDDD -v"
 needpseudo="1"
 for opt in $@; do
-- 
1.7.0.4





More information about the bitbake-devel mailing list