All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] Variable typing support
@ 2010-12-15 16:31 Chris Larson
  2010-12-15 16:38 ` Otavio Salvador
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Chris Larson @ 2010-12-15 16:31 UTC (permalink / raw)
  To: Openembedded Discussion

Greetings,

I'd like to propose inclusion of some work I've done on a branch to implement
variable typing.  This implementation consists of three components:

- oe.types python module, 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
- flags to mark up the variables with the appropriate types

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.types
    for pkg in oe.types.value("PACKAGES", d):
        bb.note("package: %s" % pkg)
}

LIBTOOL_HAS_SYSROOT = "yes"
LIBTOOL_HAS_SYSROOT[type] = "boolean"

python () {
    import oe.types
    assert(oe.types.value("LIBTOOL_HAS_SYSROOT", d) == True)
}

https://github.com/kergoth/openembedded/commit/c278cd7 shows the core
implementation, along with the description, which is shown above.
https://github.com/kergoth/openembedded/compare/master...typing shows
the changes I've done for it so far, including the python module,
variable type checking class, and examples of usage in both
bitbake.conf and classes.

Comments?  I'd love to hear what people think of this.  Note that the
main purpose of the type *checking* is to catch issues with user
configuration variables, as opposed to variables set by recipes or
classes, but of course the markup for the others is useful if one
wants to utilize oe.types in python code.
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] Variable typing support
  2010-12-15 16:31 [RFC] Variable typing support Chris Larson
@ 2010-12-15 16:38 ` Otavio Salvador
  2010-12-15 17:32 ` Esben Haabendal
  2010-12-18 11:41 ` Michael 'Mickey' Lauer
  2 siblings, 0 replies; 4+ messages in thread
From: Otavio Salvador @ 2010-12-15 16:38 UTC (permalink / raw)
  To: openembedded-devel

On Wed, Dec 15, 2010 at 14:31, Chris Larson <clarson@kergoth.com> wrote:
...

I think it is a nice features specially because it makes harder to
have multiple meanings for same type.

+1 from me.

-- 
Otavio Salvador                             O.S. Systems
E-mail: otavio@ossystems.com.br  http://www.ossystems.com.br
Mobile: +55 53 9981-7854              http://projetos.ossystems.com.br



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] Variable typing support
  2010-12-15 16:31 [RFC] Variable typing support Chris Larson
  2010-12-15 16:38 ` Otavio Salvador
@ 2010-12-15 17:32 ` Esben Haabendal
  2010-12-18 11:41 ` Michael 'Mickey' Lauer
  2 siblings, 0 replies; 4+ messages in thread
From: Esben Haabendal @ 2010-12-15 17:32 UTC (permalink / raw)
  To: openembedded-devel

On Wed, 2010-12-15 at 09:31 -0700, Chris Larson wrote:
> ....
> Comments?  I'd love to hear what people think of this.

Great stuff!

/Esben





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] Variable typing support
  2010-12-15 16:31 [RFC] Variable typing support Chris Larson
  2010-12-15 16:38 ` Otavio Salvador
  2010-12-15 17:32 ` Esben Haabendal
@ 2010-12-18 11:41 ` Michael 'Mickey' Lauer
  2 siblings, 0 replies; 4+ messages in thread
From: Michael 'Mickey' Lauer @ 2010-12-18 11:41 UTC (permalink / raw)
  To: openembedded-devel

This is a good idea, especially for boolean since we have
a nightmare with "0", "1", "True", "False", "Yes", "No" etc.
in our metadata.

Cheers,

-- 
:M:




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-12-18 11:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-15 16:31 [RFC] Variable typing support Chris Larson
2010-12-15 16:38 ` Otavio Salvador
2010-12-15 17:32 ` Esben Haabendal
2010-12-18 11:41 ` Michael 'Mickey' Lauer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.