aboutsummaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-04-21 19:55:20 -0700
committerChris Larson <chris_larson@mentor.com>2010-04-21 19:57:13 -0700
commit38e03c6721fa068d40d1517892c1bad079a64c1f (patch)
tree6dcd1d2846bb640e65b56260c092890cac16469f /classes
parentb3bff5fa134083244d26c2afd8bf86d5ee910896 (diff)
downloadopenembedded-38e03c6721fa068d40d1517892c1bad079a64c1f.tar.gz
Add emit_data.bbclass, which emits the metadata and displays diffs from previous
This can be useful for making invasive changes, to see if you inadvertantly broke something. Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'classes')
-rw-r--r--classes/emit_data.bbclass55
1 files changed, 55 insertions, 0 deletions
diff --git a/classes/emit_data.bbclass b/classes/emit_data.bbclass
new file mode 100644
index 0000000000..127af4a44c
--- /dev/null
+++ b/classes/emit_data.bbclass
@@ -0,0 +1,55 @@
+# Emit the datastore to a file, and if it was previously emitted, display the
+# differences to the user.
+
+EMIT_DIR = "${TMPDIR}/emit-data"
+EMIT_BLACKLIST += "BUILDSTART DATE TIME DATETIME \
+ __* _ PWD \
+ DISPLAY XDG_SESSION_COOKIE \
+ SSH_AUTH_SOCK SSH_TTY SSH_CLIENT SSH_CONNECTION \
+ SESSION_MANAGER DESKTOP_SESSION COLORTERM TERM \
+ XAUTHORITY GTK_RC_FILES DBUS_SESSION_BUS_ADDRESS \
+ GREP_OPTIONS \
+ GNOME_KEYRING GNOME_KEYRING_PID"
+
+def diff_datadict(d, old_data, data):
+ from itertools import chain
+ from difflib import Differ
+ from fnmatch import fnmatchcase
+
+ blacklist = d.getVar("EMIT_BLACKLIST", True).split()
+
+ keys = sorted(set(chain(old_data.iterkeys(), data.iterkeys())))
+ keys = [key for key in keys
+ if not any(fnmatchcase(key, pat) for pat in blacklist)]
+
+ old = ["%s: %s\n" % (key, old_data.get(key)) for key in keys]
+ new = ["%s: %s\n" % (key, data.get(key)) for key in keys]
+ return Differ().compare(old, new)
+
+
+python do_emit_data () {
+ import pickle
+
+ data = dict((key, repr(d.getVar(key, False))) for key in d.keys())
+ outfile = os.path.join(d.getVar("EMIT_DIR", True), d.getVar("PF", True))
+ bb.mkdirhier(os.path.dirname(outfile))
+ if os.path.exists(outfile):
+ f = open(outfile, "rb")
+ old_data = pickle.load(f)
+ f.close()
+
+ diff = diff_datadict(d, old_data, data)
+ differences = [line for line in diff if not line.startswith(" ")]
+ if differences:
+ bb.note(bb.data.expand("${PF}: data has changed:", d))
+ for line in differences:
+ bb.note(line.rstrip())
+
+ pickle.dump(data, open(outfile, "wb"))
+}
+do_emit_data[nostamp] = "1"
+addtask emit_data
+
+do_emit_data_all[recrdeptask] = "do_emit_data"
+do_emit_data_all[nostamp] = "1"
+addtask emit_data_all after do_emit_data