summaryrefslogtreecommitdiffstats
path: root/meta/classes/uboot-config.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/uboot-config.bbclass')
-rw-r--r--meta/classes/uboot-config.bbclass61
1 files changed, 61 insertions, 0 deletions
diff --git a/meta/classes/uboot-config.bbclass b/meta/classes/uboot-config.bbclass
new file mode 100644
index 0000000000..8ac1b71bc2
--- /dev/null
+++ b/meta/classes/uboot-config.bbclass
@@ -0,0 +1,61 @@
1# Handle U-Boot config for a machine
2#
3# The format to specify it, in the machine, is:
4#
5# UBOOT_CONFIG ??= <default>
6# UBOOT_CONFIG[foo] = "config,images"
7#
8# or
9#
10# UBOOT_MACHINE = "config"
11#
12# Copyright 2013, 2014 (C) O.S. Systems Software LTDA.
13
14python () {
15 ubootmachine = d.getVar("UBOOT_MACHINE", True)
16 ubootconfigflags = d.getVarFlags('UBOOT_CONFIG')
17 # The "doc" varflag is special, we don't want to see it here
18 ubootconfigflags.pop('doc', None)
19
20 if not ubootmachine and not ubootconfigflags:
21 PN = d.getVar("PN", True)
22 FILE = os.path.basename(d.getVar("FILE", True))
23 bb.debug(1, "To build %s, see %s for instructions on \
24 setting up your machine config" % (PN, FILE))
25 raise bb.parse.SkipPackage("Either UBOOT_MACHINE or UBOOT_CONFIG must be set in the %s machine configuration." % d.getVar("MACHINE", True))
26
27 if ubootmachine and ubootconfigflags:
28 raise bb.parse.SkipPackage("You cannot use UBOOT_MACHINE and UBOOT_CONFIG at the same time.")
29
30 if not ubootconfigflags:
31 return
32
33 ubootconfig = (d.getVar('UBOOT_CONFIG', True) or "").split()
34 if len(ubootconfig) > 1:
35 raise bb.parse.SkipPackage('You can only have a single default for UBOOT_CONFIG.')
36 elif len(ubootconfig) == 0:
37 raise bb.parse.SkipPackage('You must set a default in UBOOT_CONFIG.')
38 ubootconfig = ubootconfig[0]
39
40 for f, v in ubootconfigflags.items():
41 if f == 'defaultval':
42 continue
43
44 items = v.split(',')
45 if items[0] and len(items) > 2:
46 raise bb.parse.SkipPackage('Only config,images can be specified!')
47
48 if ubootconfig == f:
49 bb.debug(1, "Setting UBOOT_MACHINE to %s." % items[0])
50 d.setVar('UBOOT_MACHINE', items[0])
51
52 # IMAGE_FSTYPES appending
53 if len(items) > 1 and items[1]:
54 bb.debug(1, "Appending '%s' to IMAGE_FSTYPES." % items[1])
55 d.appendVar('IMAGE_FSTYPES', ' ' + items[1])
56
57 # Go out as we found a match!
58 break
59 else:
60 raise bb.parse.SkipPackage("UBOOT_CONFIG %s is not supported" % ubootconfig)
61}