aboutsummaryrefslogtreecommitdiffstats
path: root/meta/classes/base.bbclass
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-11-09 14:48:13 -0700
committerChris Larson <chris_larson@mentor.com>2011-05-18 13:58:14 -0700
commit785364ad1a2e6ce898d2a99e2e1c943d9a40767d (patch)
tree9f9421ebb89291f0861701865ccc1f8d5f66052c /meta/classes/base.bbclass
parent1eb0207a7ae8cbc31ecde313a020ed4f12f70dd8 (diff)
downloadopenembedded-core-contrib-785364ad1a2e6ce898d2a99e2e1c943d9a40767d.tar.gz
Implement variable typing (sync from OE)
This implementation consists of two components: - Type creation python modules, whose job it is to construct objects of the defined type for a given variable in the metadata - typecheck.bbclass, which iterates over all configuration variables with a type defined and uses oe.types to check the validity of the values This gives us a few benefits: - Automatic sanity checking of all configuration variables with a defined type - Avoid duplicating the "how do I make use of the value of this variable" logic between its users. For variables like PATH, this is simply a split(), for boolean variables, the duplication can result in confusing, or even mismatched semantics (is this 0/1, empty/nonempty, what?) - Make it easier to create a configuration UI, as the type information could be used to provide a better interface than a text edit box (e.g checkbox for 'boolean', dropdown for 'choice') This functionality is entirely opt-in right now. To enable the configuration variable type checking, simply INHERIT += "typecheck". Example of a failing type check: BAZ = "foo" BAZ[type] = "boolean" $ bitbake -p FATAL: BAZ: Invalid boolean value 'foo' $ Examples of leveraging oe.types in a python snippet: PACKAGES[type] = "list" python () { import oe.data for pkg in oe.data.typed_value("PACKAGES", d): bb.note("package: %s" % pkg) } LIBTOOL_HAS_SYSROOT = "yes" LIBTOOL_HAS_SYSROOT[type] = "boolean" python () { import oe.data assert(oe.data.typed_value("LIBTOOL_HAS_SYSROOT", d) == True) } Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'meta/classes/base.bbclass')
-rw-r--r--meta/classes/base.bbclass1
1 files changed, 1 insertions, 0 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 23095eca3b..b552de2948 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -28,6 +28,7 @@ python sys_path_eh () {
import oe.path
import oe.utils
+ import oe.data
inject("bb", bb)
inject("sys", sys)
inject("time", time)