diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-06-12 16:31:57 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-06-14 12:55:22 +0100 |
commit | bff73743280f9eafebe4591f7368ead91a4eb74d (patch) | |
tree | 59ebd0fa20f3e0345951c097ea69d6a485249190 /meta/classes | |
parent | 8b90f1becd40a7f857d2fbe30eaffe218a976419 (diff) | |
download | openembedded-core-contrib-bff73743280f9eafebe4591f7368ead91a4eb74d.tar.gz |
classes/conf: Add eventmasks for event handlers
Now that bitbake supports masking events for event handlers, lets use
this so event handlers are only called for events they care about. This
lets us simplify the code indentation a bit at least as well as mildly
improving the event handling performance.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/base.bbclass | 7 | ||||
-rw-r--r-- | meta/classes/bugzilla.bbclass | 1 | ||||
-rw-r--r-- | meta/classes/buildhistory.bbclass | 8 | ||||
-rw-r--r-- | meta/classes/buildstats.bbclass | 1 | ||||
-rw-r--r-- | meta/classes/cross.bbclass | 4 | ||||
-rw-r--r-- | meta/classes/distrodata.bbclass | 44 | ||||
-rw-r--r-- | meta/classes/migrate_localcount.bbclass | 68 | ||||
-rw-r--r-- | meta/classes/multilib.bbclass | 4 | ||||
-rw-r--r-- | meta/classes/multilib_global.bbclass | 1 | ||||
-rw-r--r-- | meta/classes/native.bbclass | 4 | ||||
-rw-r--r-- | meta/classes/nativesdk.bbclass | 4 | ||||
-rw-r--r-- | meta/classes/packageinfo.bbclass | 50 | ||||
-rw-r--r-- | meta/classes/prexport.bbclass | 1 | ||||
-rw-r--r-- | meta/classes/primport.bbclass | 1 | ||||
-rw-r--r-- | meta/classes/recipe_sanity.bbclass | 4 | ||||
-rw-r--r-- | meta/classes/sanity.bbclass | 1 | ||||
-rw-r--r-- | meta/classes/typecheck.bbclass | 8 |
17 files changed, 104 insertions, 107 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass index 8af104f7654..3a0ff6bd635 100644 --- a/meta/classes/base.bbclass +++ b/meta/classes/base.bbclass @@ -32,12 +32,12 @@ def oe_import(d): inject(toimport.split(".", 1)[0], imported) python oe_import_eh () { - if isinstance(e, bb.event.ConfigParsed): - oe_import(e.data) - e.data.setVar("NATIVELSBSTRING", lsb_distro_identifier(e.data)) + oe_import(e.data) + e.data.setVar("NATIVELSBSTRING", lsb_distro_identifier(e.data)) } addhandler oe_import_eh +oe_import_eh[eventmask] = "bb.event.ConfigParsed" def lsb_distro_identifier(d): adjust = d.getVar('LSB_DISTRO_ADJUST', True) @@ -299,6 +299,7 @@ def buildcfg_neededvars(d): bb.fatal('The following variable(s) were not set: %s\nPlease set them directly, or choose a MACHINE or DISTRO that sets them.' % ', '.join(pesteruser)) addhandler base_eventhandler +base_eventhandler[eventmask] = "bb.event.ConfigParsed bb.event.BuildStarted" python base_eventhandler() { if isinstance(e, bb.event.ConfigParsed): e.data.setVar('BB_VERSION', bb.__version__) diff --git a/meta/classes/bugzilla.bbclass b/meta/classes/bugzilla.bbclass index 006763d2c72..3fc89564281 100644 --- a/meta/classes/bugzilla.bbclass +++ b/meta/classes/bugzilla.bbclass @@ -71,6 +71,7 @@ def bugzilla_add_comment(debug_file, server, args, bug_number, text): return False addhandler bugzilla_eventhandler +bugzilla_eventhandler[eventmask] = "bb.event.MsgNote bb.build.TaskFailed" python bugzilla_eventhandler() { import glob import xmlrpclib, httplib diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass index 450eb7cb80a..c8fd68c39e0 100644 --- a/meta/classes/buildhistory.bbclass +++ b/meta/classes/buildhistory.bbclass @@ -525,13 +525,13 @@ END } python buildhistory_eventhandler() { - if isinstance(e, bb.event.BuildCompleted): - if e.data.getVar('BUILDHISTORY_FEATURES', True).strip(): - if e.data.getVar("BUILDHISTORY_COMMIT", True) == "1": - bb.build.exec_func("buildhistory_commit", e.data) + if e.data.getVar('BUILDHISTORY_FEATURES', True).strip(): + if e.data.getVar("BUILDHISTORY_COMMIT", True) == "1": + bb.build.exec_func("buildhistory_commit", e.data) } addhandler buildhistory_eventhandler +buildhistory_eventhandler[eventmask] = "bb.event.BuildCompleted" # FIXME this ought to be moved into the fetcher diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass index e12e14fcd6d..b98ba3bea79 100644 --- a/meta/classes/buildstats.bbclass +++ b/meta/classes/buildstats.bbclass @@ -278,4 +278,5 @@ python run_buildstats () { } addhandler run_buildstats +run_buildstats[eventmask] = "bb.event.BuildStarted bb.event.BuildCompleted bb.build.TaskStarted bb.build.TaskSucceeded bb.build.TaskFailed" diff --git a/meta/classes/cross.bbclass b/meta/classes/cross.bbclass index eaba4d113c6..54584fea528 100644 --- a/meta/classes/cross.bbclass +++ b/meta/classes/cross.bbclass @@ -58,9 +58,6 @@ do_populate_sysroot[sstate-inputdirs] = "${SYSROOT_DESTDIR}/${STAGING_DIR_NATIVE do_populate_sysroot[stamp-extra-info] = "" python cross_virtclass_handler () { - if not isinstance(e, bb.event.RecipePreFinalise): - return - classextend = e.data.getVar('BBCLASSEXTEND', True) or "" if "cross" not in classextend: return @@ -73,6 +70,7 @@ python cross_virtclass_handler () { } addhandler cross_virtclass_handler +cross_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise" do_install () { oe_runmake 'DESTDIR=${D}' install diff --git a/meta/classes/distrodata.bbclass b/meta/classes/distrodata.bbclass index cedacc214c3..3ff62684aa1 100644 --- a/meta/classes/distrodata.bbclass +++ b/meta/classes/distrodata.bbclass @@ -1,15 +1,14 @@ include conf/distro/include/package_regex.inc addhandler distro_eventhandler +distro_eventhandler[eventmask] = "bb.event.BuildStarted" python distro_eventhandler() { - - if bb.event.getName(e) == "BuildStarted": - import oe.distro_check as dc - logfile = dc.create_log_file(e.data, "distrodata.csv") - lf = bb.utils.lockfile("%s.lock" % logfile) - f = open(logfile, "a") - f.write("Package,Description,Owner,License,VerMatch,Version,Upsteam,Reason,Recipe Status,Distro 1,Distro 2,Distro 3\n") - f.close() - bb.utils.unlockfile(lf) + import oe.distro_check as dc + logfile = dc.create_log_file(e.data, "distrodata.csv") + lf = bb.utils.lockfile("%s.lock" % logfile) + f = open(logfile, "a") + f.write("Package,Description,Owner,License,VerMatch,Version,Upsteam,Reason,Recipe Status,Distro 1,Distro 2,Distro 3\n") + f.close() + bb.utils.unlockfile(lf) return } @@ -197,6 +196,7 @@ do_distrodataall() { } addhandler checkpkg_eventhandler + checkpkg_eventhandler[eventmask] = "bb.event.BuildStarted bb.event.BuildCompleted" python checkpkg_eventhandler() { def parse_csv_file(filename): package_dict = {} @@ -793,11 +793,11 @@ do_checkpkgall() { } addhandler distro_check_eventhandler +distro_check_eventhandler bb.event.BuildStarted python distro_check_eventhandler() { - if bb.event.getName(e) == "BuildStarted": - """initialize log files.""" - import oe.distro_check as dc - result_file = dc.create_log_file(e.data, "distrocheck.csv") + """initialize log files.""" + import oe.distro_check as dc + result_file = dc.create_log_file(e.data, "distrocheck.csv") return } @@ -839,16 +839,16 @@ do_distro_checkall() { #then we can search those recipes which license text isn't exsit in common-licenses directory # addhandler checklicense_eventhandler +checklicense_eventhandler[eventmask] = "bb.event.BuildStarted" python checklicense_eventhandler() { - if bb.event.getName(e) == "BuildStarted": - """initialize log files.""" - import oe.distro_check as dc - logfile = dc.create_log_file(e.data, "missinglicense.csv") - lf = bb.utils.lockfile("%s.lock" % logfile) - f = open(logfile, "a") - f.write("Package\tLicense\tMissingLicense\n") - f.close() - bb.utils.unlockfile(lf) + """initialize log files.""" + import oe.distro_check as dc + logfile = dc.create_log_file(e.data, "missinglicense.csv") + lf = bb.utils.lockfile("%s.lock" % logfile) + f = open(logfile, "a") + f.write("Package\tLicense\tMissingLicense\n") + f.close() + bb.utils.unlockfile(lf) return } diff --git a/meta/classes/migrate_localcount.bbclass b/meta/classes/migrate_localcount.bbclass index 3916ad44618..aa0df8bb76e 100644 --- a/meta/classes/migrate_localcount.bbclass +++ b/meta/classes/migrate_localcount.bbclass @@ -6,41 +6,41 @@ python migrate_localcount_handler () { if not e.data: return - if isinstance(e, bb.event.RecipeParsed): - pv = e.data.getVar('PV', True) - if not 'AUTOINC' in pv: - return - - localcounts = bb.persist_data.persist('BB_URI_LOCALCOUNT', e.data) - pn = e.data.getVar('PN', True) - revs = localcounts.get_by_pattern('%%-%s_rev' % pn) - counts = localcounts.get_by_pattern('%%-%s_count' % pn) - if not revs or not counts: - return - - if len(revs) != len(counts): - bb.warn("The number of revs and localcounts don't match in %s" % pn) - return - - version = e.data.getVar('PRAUTOINX', True) - srcrev = bb.fetch2.get_srcrev(e.data) - base_ver = 'AUTOINC-%s' % version[:version.find(srcrev)] - pkgarch = e.data.getVar('PACKAGE_ARCH', True) - value = max(int(count) for count in counts) - - if len(revs) == 1: - if srcrev != ('AUTOINC+%s' % revs[0]): - value += 1 - else: - value += 1 + pv = e.data.getVar('PV', True) + if not 'AUTOINC' in pv: + return + + localcounts = bb.persist_data.persist('BB_URI_LOCALCOUNT', e.data) + pn = e.data.getVar('PN', True) + revs = localcounts.get_by_pattern('%%-%s_rev' % pn) + counts = localcounts.get_by_pattern('%%-%s_count' % pn) + if not revs or not counts: + return - bb.utils.mkdirhier(e.data.getVar('PRSERV_DUMPDIR', True)) - df = e.data.getVar('LOCALCOUNT_DUMPFILE', True) - flock = bb.utils.lockfile("%s.lock" % df) - with open(df, 'a') as fd: - fd.write('PRAUTO$%s$%s$%s = "%s"\n' % - (base_ver, pkgarch, srcrev, str(value))) - bb.utils.unlockfile(flock) + if len(revs) != len(counts): + bb.warn("The number of revs and localcounts don't match in %s" % pn) + return + + version = e.data.getVar('PRAUTOINX', True) + srcrev = bb.fetch2.get_srcrev(e.data) + base_ver = 'AUTOINC-%s' % version[:version.find(srcrev)] + pkgarch = e.data.getVar('PACKAGE_ARCH', True) + value = max(int(count) for count in counts) + + if len(revs) == 1: + if srcrev != ('AUTOINC+%s' % revs[0]): + value += 1 + else: + value += 1 + + bb.utils.mkdirhier(e.data.getVar('PRSERV_DUMPDIR', True)) + df = e.data.getVar('LOCALCOUNT_DUMPFILE', True) + flock = bb.utils.lockfile("%s.lock" % df) + with open(df, 'a') as fd: + fd.write('PRAUTO$%s$%s$%s = "%s"\n' % + (base_ver, pkgarch, srcrev, str(value))) + bb.utils.unlockfile(flock) } addhandler migrate_localcount_handler +migrate_localcount_handler[eventmask] = "bb.event.RecipeParsed" diff --git a/meta/classes/multilib.bbclass b/meta/classes/multilib.bbclass index 9337f65a706..b04825f9876 100644 --- a/meta/classes/multilib.bbclass +++ b/meta/classes/multilib.bbclass @@ -1,7 +1,4 @@ python multilib_virtclass_handler () { - if not isinstance(e, bb.event.RecipePreFinalise): - return - cls = e.data.getVar("BBEXTENDCURR", True) variant = e.data.getVar("BBEXTENDVARIANT", True) if cls != "multilib" or not variant: @@ -60,6 +57,7 @@ python multilib_virtclass_handler () { } addhandler multilib_virtclass_handler +multilib_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise" STAGINGCC_prepend = "${BBEXTENDVARIANT}-" diff --git a/meta/classes/multilib_global.bbclass b/meta/classes/multilib_global.bbclass index 85f2d8d15d9..3315ba93278 100644 --- a/meta/classes/multilib_global.bbclass +++ b/meta/classes/multilib_global.bbclass @@ -43,4 +43,5 @@ python multilib_virtclass_handler_global () { } addhandler multilib_virtclass_handler_global +multilib_virtclass_handler_global[eventmask] = "bb.event.RecipePreFinalise bb.event.RecipeParsed" diff --git a/meta/classes/native.bbclass b/meta/classes/native.bbclass index cd930f0702f..04f0d06ad9f 100644 --- a/meta/classes/native.bbclass +++ b/meta/classes/native.bbclass @@ -104,9 +104,6 @@ CLASSOVERRIDE = "class-native" PATH_prepend = "${COREBASE}/scripts/native-intercept:" python native_virtclass_handler () { - if not isinstance(e, bb.event.RecipePreFinalise): - return - classextend = e.data.getVar('BBCLASSEXTEND', True) or "" if "native" not in classextend: return @@ -152,6 +149,7 @@ python native_virtclass_handler () { } addhandler native_virtclass_handler +native_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise" do_package[noexec] = "1" do_packagedata[noexec] = "1" diff --git a/meta/classes/nativesdk.bbclass b/meta/classes/nativesdk.bbclass index 8b689e760ac..96e1b42a49c 100644 --- a/meta/classes/nativesdk.bbclass +++ b/meta/classes/nativesdk.bbclass @@ -60,9 +60,6 @@ export PKG_CONFIG_DIR = "${STAGING_DIR_HOST}${libdir}/pkgconfig" export PKG_CONFIG_SYSROOT_DIR = "${STAGING_DIR_HOST}" python nativesdk_virtclass_handler () { - if not isinstance(e, bb.event.RecipePreFinalise): - return - pn = e.data.getVar("PN", True) if not pn.endswith("-nativesdk") or pn.startswith("nativesdk-"): return @@ -89,5 +86,6 @@ python () { } addhandler nativesdk_virtclass_handler +nativesdk_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise" do_populate_sysroot[stamp-extra-info] = "" diff --git a/meta/classes/packageinfo.bbclass b/meta/classes/packageinfo.bbclass index 4709bea3595..42fcd04150a 100644 --- a/meta/classes/packageinfo.bbclass +++ b/meta/classes/packageinfo.bbclass @@ -1,29 +1,29 @@ python packageinfo_handler () { - if isinstance(e, bb.event.RequestPackageInfo): - import oe.packagedata - pkginfolist = [] - tmpdir = e.data.getVar('TMPDIR', True) - target_vendor = e.data.getVar('TARGET_VENDOR', True) - target_os = e.data.getVar('TARGET_OS', True) - package_archs = e.data.getVar('PACKAGE_ARCHS', True) - packaging = e.data.getVar('PACKAGE_CLASSES', True).split()[0].split('_')[1] - deploy_dir = e.data.getVar('DEPLOY_DIR', True) + '/' + packaging - - for arch in package_archs.split(): - pkgdata_dir = tmpdir + '/pkgdata/' + arch + target_vendor + '-' + target_os + '/runtime/' - if os.path.exists(pkgdata_dir): - for root, dirs, files in os.walk(pkgdata_dir): - for pkgname in files: - if pkgname.endswith('.packaged'): - pkgname = pkgname[:-9] - pkgdatafile = root + pkgname - try: - sdata = oe.packagedata.read_pkgdatafile(pkgdatafile) - sdata['PKG'] = pkgname - pkginfolist.append(sdata) - except Exception as e: - bb.warn("Failed to read pkgdata file %s: %s: %s" % (pkgdatafile, e.__class__, str(e))) - bb.event.fire(bb.event.PackageInfo(pkginfolist), e.data) + import oe.packagedata + pkginfolist = [] + tmpdir = e.data.getVar('TMPDIR', True) + target_vendor = e.data.getVar('TARGET_VENDOR', True) + target_os = e.data.getVar('TARGET_OS', True) + package_archs = e.data.getVar('PACKAGE_ARCHS', True) + packaging = e.data.getVar('PACKAGE_CLASSES', True).split()[0].split('_')[1] + deploy_dir = e.data.getVar('DEPLOY_DIR', True) + '/' + packaging + + for arch in package_archs.split(): + pkgdata_dir = tmpdir + '/pkgdata/' + arch + target_vendor + '-' + target_os + '/runtime/' + if os.path.exists(pkgdata_dir): + for root, dirs, files in os.walk(pkgdata_dir): + for pkgname in files: + if pkgname.endswith('.packaged'): + pkgname = pkgname[:-9] + pkgdatafile = root + pkgname + try: + sdata = oe.packagedata.read_pkgdatafile(pkgdatafile) + sdata['PKG'] = pkgname + pkginfolist.append(sdata) + except Exception as e: + bb.warn("Failed to read pkgdata file %s: %s: %s" % (pkgdatafile, e.__class__, str(e))) + bb.event.fire(bb.event.PackageInfo(pkginfolist), e.data) } addhandler packageinfo_handler +packageinfo_handler[eventmask] = "bb.event.RequestPackageInfo" diff --git a/meta/classes/prexport.bbclass b/meta/classes/prexport.bbclass index 6b9d540989a..16c4bf2f237 100644 --- a/meta/classes/prexport.bbclass +++ b/meta/classes/prexport.bbclass @@ -55,3 +55,4 @@ python prexport_handler () { } addhandler prexport_handler +prexport_handler bb.event.RecipeParsed bb.event.ParseStarted bb.event.ParseCompleted" diff --git a/meta/classes/primport.bbclass b/meta/classes/primport.bbclass index 37b0d6b1b73..8ed45f03f00 100644 --- a/meta/classes/primport.bbclass +++ b/meta/classes/primport.bbclass @@ -18,3 +18,4 @@ python primport_handler () { } addhandler primport_handler +primport_handler[eventmask] = "bb.event.ParseCompleted bb.event.ParseStarted" diff --git a/meta/classes/recipe_sanity.bbclass b/meta/classes/recipe_sanity.bbclass index bf378eafc1f..8b3a1c9571e 100644 --- a/meta/classes/recipe_sanity.bbclass +++ b/meta/classes/recipe_sanity.bbclass @@ -140,9 +140,6 @@ do_recipe_sanity_all () { addtask recipe_sanity_all after do_recipe_sanity python recipe_sanity_eh () { - if bb.event.getName(e) != "ConfigParsed": - return - d = e.data cfgdata = {} @@ -168,3 +165,4 @@ python recipe_sanity_eh () { DataSmart.renameVar = myrename } addhandler recipe_sanity_eh +recipe_sanity_eh[eventmask] = "bb.event.ConfigParsed" diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass index e692f33839d..3b9934b488c 100644 --- a/meta/classes/sanity.bbclass +++ b/meta/classes/sanity.bbclass @@ -672,6 +672,7 @@ def copy_data(e): return sanity_data addhandler check_sanity_eventhandler +check_sanity_eventhandler[eventmask] = "bb.event.ConfigParsed bb.event.SanityCheck bb.event.NetworkTest" python check_sanity_eventhandler() { if bb.event.getName(e) == "ConfigParsed" and e.data.getVar("BB_WORKERCONTEXT", True) != "1" and e.data.getVar("DISABLE_SANITY_CHECKS", True) != "1": sanity_data = copy_data(e) diff --git a/meta/classes/typecheck.bbclass b/meta/classes/typecheck.bbclass index 353532d73cf..72da9322328 100644 --- a/meta/classes/typecheck.bbclass +++ b/meta/classes/typecheck.bbclass @@ -4,9 +4,9 @@ python check_types() { import oe.types - if isinstance(e, bb.event.ConfigParsed): - for key in e.data.keys(): - if e.data.getVarFlag(key, "type"): - oe.data.typed_value(key, e.data) + for key in e.data.keys(): + if e.data.getVarFlag(key, "type"): + oe.data.typed_value(key, e.data) } addhandler check_types +check_types[eventmask] = "bb.event.ConfigParsed" |