summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorHolger Freyther <zecke@selfish.org>2006-11-18 16:55:13 +0000
committerHolger Freyther <zecke@selfish.org>2006-11-18 16:55:13 +0000
commit56b7d78a034187f66e08f3b3e2de55bd878cf9b5 (patch)
treed6f4033c0064f41c2205502d10c651e8710c96aa /classes
parent9e61974759ef6e4ff9538a33bab0e82b1b4381dd (diff)
Micro-Optimisation decreasing initial parsing time by 10%
python () {} and python __anonymous () {} are as the same says functions without a name. They get executed when the main bb file is completely parsed. This is used to set information like FILESDIR. This is a python method so it gets evaled which means compiled and executed a lot of times. By moving the code of the anonfunc into a proper method this is only compiled once. The result is is the 10% speed up when parsing. Reindent anonfuncs and new defs without tabs and four spaces
Diffstat (limited to 'classes')
-rw-r--r--classes/base.bbclass94
-rw-r--r--classes/flow-lossage.bbclass4
-rw-r--r--classes/gettext.bbclass18
-rw-r--r--classes/multimachine.bbclass31
-rw-r--r--classes/update-alternatives.bbclass12
-rw-r--r--classes/update-rc.d.bbclass15
6 files changed, 100 insertions, 74 deletions
diff --git a/classes/base.bbclass b/classes/base.bbclass
index cbf164fac7..18e6aec814 100644
--- a/classes/base.bbclass
+++ b/classes/base.bbclass
@@ -676,55 +676,61 @@ python read_subpackage_metadata () {
bb.data.setVar(key, sdata[key], d)
}
-python __anonymous () {
- import exceptions
- need_host = bb.data.getVar('COMPATIBLE_HOST', d, 1)
- if need_host:
- import re
- this_host = bb.data.getVar('HOST_SYS', d, 1)
- if not re.match(need_host, this_host):
- raise bb.parse.SkipPackage("incompatible with host %s" % this_host)
-
- need_machine = bb.data.getVar('COMPATIBLE_MACHINE', d, 1)
- if need_machine:
- import re
- this_machine = bb.data.getVar('MACHINE', d, 1)
- if this_machine and not re.match(need_machine, this_machine):
- raise bb.parse.SkipPackage("incompatible with machine %s" % this_machine)
-
- pn = bb.data.getVar('PN', d, 1)
-
- # OBSOLETE in bitbake 1.7.4
- srcdate = bb.data.getVar('SRCDATE_%s' % pn, d, 1)
- if srcdate != None:
- bb.data.setVar('SRCDATE', srcdate, d)
+def base_after_parse_two(d):
+ import bb
+ import exceptions
+ need_host = bb.data.getVar('COMPATIBLE_HOST', d, 1)
+ if need_host:
+ import re
+ this_host = bb.data.getVar('HOST_SYS', d, 1)
+ if not re.match(need_host, this_host):
+ raise bb.parse.SkipPackage("incompatible with host %s" % this_host)
+
+ need_machine = bb.data.getVar('COMPATIBLE_MACHINE', d, 1)
+ if need_machine:
+ import re
+ this_machine = bb.data.getVar('MACHINE', d, 1)
+ if this_machine and not re.match(need_machine, this_machine):
+ raise bb.parse.SkipPackage("incompatible with machine %s" % this_machine)
+
+ pn = bb.data.getVar('PN', d, 1)
+
+ # OBSOLETE in bitbake 1.7.4
+ srcdate = bb.data.getVar('SRCDATE_%s' % pn, d, 1)
+ if srcdate != None:
+ bb.data.setVar('SRCDATE', srcdate, d)
+
+ use_nls = bb.data.getVar('USE_NLS_%s' % pn, d, 1)
+ if use_nls != None:
+ bb.data.setVar('USE_NLS', use_nls, d)
+
+def base_after_parse(d):
+ import bb, os
+ mach_arch = bb.data.getVar('MACHINE_ARCH', d, 1)
+ old_arch = bb.data.getVar('PACKAGE_ARCH', d, 1)
+ if (old_arch == mach_arch):
+ # Nothing to do
+ return
+ if (bb.data.getVar('SRC_URI_OVERRIDES_PACKAGE_ARCH', d, 1) == '0'):
+ return
+ paths = []
+ for p in [ "${FILE_DIRNAME}/${PF}", "${FILE_DIRNAME}/${P}", "${FILE_DIRNAME}/${PN}", "${FILE_DIRNAME}/files", "${FILE_DIRNAME}" ]:
+ paths.append(bb.data.expand(os.path.join(p, mach_arch), d))
+ for s in bb.data.getVar('SRC_URI', d, 1).split():
+ local = bb.data.expand(bb.fetch.localpath(s, d), d)
+ for mp in paths:
+ if local.startswith(mp):
+ #bb.note("overriding PACKAGE_ARCH from %s to %s" % (old_arch, mach_arch))
+ bb.data.setVar('PACKAGE_ARCH', mach_arch, d)
+ return
- use_nls = bb.data.getVar('USE_NLS_%s' % pn, d, 1)
- if use_nls != None:
- bb.data.setVar('USE_NLS', use_nls, d)
-}
python () {
- import bb, os
- mach_arch = bb.data.getVar('MACHINE_ARCH', d, 1)
- old_arch = bb.data.getVar('PACKAGE_ARCH', d, 1)
- if (old_arch == mach_arch):
- # Nothing to do
- return
- if (bb.data.getVar('SRC_URI_OVERRIDES_PACKAGE_ARCH', d, 1) == '0'):
- return
- paths = []
- for p in [ "${FILE_DIRNAME}/${PF}", "${FILE_DIRNAME}/${P}", "${FILE_DIRNAME}/${PN}", "${FILE_DIRNAME}/files", "${FILE_DIRNAME}" ]:
- paths.append(bb.data.expand(os.path.join(p, mach_arch), d))
- for s in bb.data.getVar('SRC_URI', d, 1).split():
- local = bb.data.expand(bb.fetch.localpath(s, d), d)
- for mp in paths:
- if local.startswith(mp):
-# bb.note("overriding PACKAGE_ARCH from %s to %s" % (old_arch, mach_arch))
- bb.data.setVar('PACKAGE_ARCH', mach_arch, d)
- return
+ base_after_parse_two(d)
+ base_after_parse(d)
}
+
# Patch handling
inherit patch
diff --git a/classes/flow-lossage.bbclass b/classes/flow-lossage.bbclass
index 3e841e3cae..00e6bf0257 100644
--- a/classes/flow-lossage.bbclass
+++ b/classes/flow-lossage.bbclass
@@ -1,5 +1,5 @@
# gcc-3.4 blows up in gtktext with -frename-registers on arm-linux
python () {
- cflags = (bb.data.getVar('CFLAGS', d, 1) or '').replace('-frename-registers', '')
- bb.data.setVar('CFLAGS', cflags, d)
+ cflags = (bb.data.getVar('CFLAGS', d, 1) or '').replace('-frename-registers', '')
+ bb.data.setVar('CFLAGS', cflags, d)
}
diff --git a/classes/gettext.bbclass b/classes/gettext.bbclass
index 3785f5acd3..a1e00e72c1 100644
--- a/classes/gettext.bbclass
+++ b/classes/gettext.bbclass
@@ -1,11 +1,15 @@
+def gettext_after_parse(d):
+ import bb
+ # Remove the NLS bits if USE_NLS is no.
+ if bb.data.getVar('USE_NLS', d, 1) == 'no':
+ cfg = oe_filter_out('^--(dis|en)able-nls$', bb.data.getVar('EXTRA_OECONF', d, 1) or "", d)
+ cfg += " --disable-nls"
+ depends = bb.data.getVar('DEPENDS', d, 1) or ""
+ bb.data.setVar('DEPENDS', oe_filter_out('^(virtual/libiconv|virtual/libintl)$', depends, d), d)
+ bb.data.setVar('EXTRA_OECONF', cfg, d)
+
python () {
- # Remove the NLS bits if USE_NLS is no.
- if bb.data.getVar('USE_NLS', d, 1) == 'no':
- cfg = oe_filter_out('^--(dis|en)able-nls$', bb.data.getVar('EXTRA_OECONF', d, 1) or "", d)
- cfg += " --disable-nls"
- depends = bb.data.getVar('DEPENDS', d, 1) or ""
- bb.data.setVar('DEPENDS', oe_filter_out('^(virtual/libiconv|virtual/libintl)$', depends, d), d)
- bb.data.setVar('EXTRA_OECONF', cfg, d)
+ gettext_after_parse(d)
}
DEPENDS =+ "gettext-native"
diff --git a/classes/multimachine.bbclass b/classes/multimachine.bbclass
index 30a285e5f3..d63aeb6d73 100644
--- a/classes/multimachine.bbclass
+++ b/classes/multimachine.bbclass
@@ -4,19 +4,26 @@ STAGING_KERNEL_DIR = "${STAGING_DIR}/${MULTIMACH_ARCH}${TARGET_VENDOR}-${TARGET_
# Find any machine specific sub packages and if present, mark the
# whole package as machine specific for multimachine purposes.
-python __anonymous () {
- packages = bb.data.getVar('PACKAGES', d, 1).split()
- macharch = bb.data.getVar('MACHINE_ARCH', d, 1)
- multiarch = bb.data.getVar('PACKAGE_ARCH', d, 1)
- for pkg in packages:
- pkgarch = bb.data.getVar("PACKAGE_ARCH_%s" % pkg, d, 1)
- # We could look for != PACKAGE_ARCH here but how to choose
- # if multiple differences are present?
- # Look through IPKG_ARCHS for the priority order?
- if pkgarch and pkgarch == macharch:
- multiarch = macharch
+def multi_machine_after_parse(d):
+ import bb
+ packages = bb.data.getVar('PACKAGES', d, 1).split()
+ macharch = bb.data.getVar('MACHINE_ARCH', d, 1)
+ multiarch = bb.data.getVar('PACKAGE_ARCH', d, 1)
+
+ for pkg in packages:
+ pkgarch = bb.data.getVar("PACKAGE_ARCH_%s" % pkg, d, 1)
+
+ # We could look for != PACKAGE_ARCH here but how to choose
+ # if multiple differences are present?
+ # Look through IPKG_ARCHS for the priority order?
+ if pkgarch and pkgarch == macharch:
+ multiarch = macharch
- bb.data.setVar('MULTIMACH_ARCH', multiarch, d)
+ bb.data.setVar('MULTIMACH_ARCH', multiarch, d)
+
+
+python __anonymous () {
+ multi_machine_after_parse(d)
}
diff --git a/classes/update-alternatives.bbclass b/classes/update-alternatives.bbclass
index 6b2b547d5f..2e24eeec48 100644
--- a/classes/update-alternatives.bbclass
+++ b/classes/update-alternatives.bbclass
@@ -10,11 +10,15 @@ update_alternatives_postrm() {
update-alternatives --remove ${ALTERNATIVE_NAME} ${ALTERNATIVE_PATH}
}
+def updatealternativesafterparse(d):
+ import bb
+ if bb.data.getVar('ALTERNATIVE_NAME', d) == None:
+ raise bb.build.FuncFailed, "%s inherits update-alternatives but doesn't set ALTERNATIVE_NAME" % bb.data.getVar('FILE', d)
+ if bb.data.getVar('ALTERNATIVE_PATH', d) == None:
+ raise bb.build.FuncFailed, "%s inherits update-alternatives but doesn't set ALTERNATIVE_PATH" % bb.data.getVar('FILE', d)
+
python __anonymous() {
- if bb.data.getVar('ALTERNATIVE_NAME', d) == None:
- raise bb.build.FuncFailed, "%s inherits update-alternatives but doesn't set ALTERNATIVE_NAME" % bb.data.getVar('FILE', d)
- if bb.data.getVar('ALTERNATIVE_PATH', d) == None:
- raise bb.build.FuncFailed, "%s inherits update-alternatives but doesn't set ALTERNATIVE_PATH" % bb.data.getVar('FILE', d)
+ updatealternativesafterparse(d)
}
python populate_packages_prepend () {
diff --git a/classes/update-rc.d.bbclass b/classes/update-rc.d.bbclass
index 0bfba467c1..581859ad48 100644
--- a/classes/update-rc.d.bbclass
+++ b/classes/update-rc.d.bbclass
@@ -26,12 +26,17 @@ updatercd_postrm() {
update-rc.d $D ${INITSCRIPT_NAME} remove
}
+
+def update_rc_after_parse(d):
+ import bb
+ if bb.data.getVar('INITSCRIPT_PACKAGES', d) == None:
+ if bb.data.getVar('INITSCRIPT_NAME', d) == None:
+ raise bb.build.FuncFailed, "%s inherits update-rc.d but doesn't set INITSCRIPT_NAME" % bb.data.getVar('FILE', d)
+ if bb.data.getVar('INITSCRIPT_PARAMS', d) == None:
+ raise bb.build.FuncFailed, "%s inherits update-rc.d but doesn't set INITSCRIPT_PARAMS" % bb.data.getVar('FILE', d)
+
python __anonymous() {
- if bb.data.getVar('INITSCRIPT_PACKAGES', d) == None:
- if bb.data.getVar('INITSCRIPT_NAME', d) == None:
- raise bb.build.FuncFailed, "%s inherits update-rc.d but doesn't set INITSCRIPT_NAME" % bb.data.getVar('FILE', d)
- if bb.data.getVar('INITSCRIPT_PARAMS', d) == None:
- raise bb.build.FuncFailed, "%s inherits update-rc.d but doesn't set INITSCRIPT_PARAMS" % bb.data.getVar('FILE', d)
+ update_rc_after_parse(d)
}
python populate_packages_prepend () {