aboutsummaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/types.py
AgeCommit message (Collapse)Author
2013-08-26oe.types: add 'path' typeChristopher Larson
- path normalization ('normalize' flag, defaults to enabled) - existence verification for paths we know should exist ('mustexist' flag) - supports clean handling of relative paths ('relativeto' flag) Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
2013-05-09clases/lib: Use modern exception syntaxRichard Purdie
Update older code to use modern exception handling syntax which is the form accepted by python 3. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-05-17oe.types: give the regex type more sane semanticsChristopher Larson
Currently, if a variable is unset or has an empty value, the regex type will return a match object which always matches. Not all variable types will necessarily have the same behavior for handling defaults. I believe that returning a match object which matches nothing when a variable is unset is superior to returning one which matches anything, and the user can always explicitly request anything via '.*', if that's what they want. This constructs a null pattern object which will never match, and uses it when encountering an unset or empty variable (currently, these two things are one and the same, as maketype is handling the default. we may well want to shift that logic into the individual types, giving them more control over default behavior, but currently the behavior is at least relatively consistent -- no difference between unset and empty variables). Signed-off-by: Christopher Larson <chris_larson@mentor.com>
2011-05-20Implement variable typing (sync from OE)Chris Larson
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>