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.bbclass59
1 files changed, 59 insertions, 0 deletions
diff --git a/meta/classes/uboot-config.bbclass b/meta/classes/uboot-config.bbclass
new file mode 100644
index 0000000000..5068f49bfc
--- /dev/null
+++ b/meta/classes/uboot-config.bbclass
@@ -0,0 +1,59 @@
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 (C) O.S. Systems Software LTDA.
13
14python () {
15 ubootmachine = d.getVar("UBOOT_MACHINE", True)
16 ubootconfigflags = d.getVarFlags('UBOOT_CONFIG')
17
18 if not ubootmachine and not ubootconfigflags:
19 PN = d.getVar("PN", True)
20 FILE = os.path.basename(d.getVar("FILE", True))
21 bb.debug(1, "To build %s, see %s for instructions on \
22 setting up your machine config" % (PN, FILE))
23 raise bb.parse.SkipPackage("Either UBOOT_MACHINE or UBOOT_CONFIG must be set in the %s machine configuration." % d.getVar("MACHINE", True))
24
25 if ubootmachine and ubootconfigflags:
26 raise bb.parse.SkipPackage("You cannot use UBOOT_MACHINE and UBOOT_CONFIG at the same time.")
27
28 if not ubootconfigflags:
29 return
30
31 ubootconfig = (d.getVar('UBOOT_CONFIG', True) or "").split()
32 if len(ubootconfig) > 1:
33 raise bb.parse.SkipPackage('You can only have a single default for UBOOT_CONFIG.')
34 elif len(ubootconfig) == 0:
35 raise bb.parse.SkipPackage('You must set a default in UBOOT_CONFIG.')
36 ubootconfig = ubootconfig[0]
37
38 for f, v in ubootconfigflags.items():
39 if f == 'defaultval':
40 continue
41
42 items = v.split(',')
43 if items[0] and len(items) > 2:
44 raise bb.parse.SkipPackage('Only config,images can be specified!')
45
46 if ubootconfig == f:
47 bb.debug(1, "Setting UBOOT_MACHINE to %s." % items[0])
48 d.setVar('UBOOT_MACHINE', items[0])
49
50 # IMAGE_FSTYPES appending
51 if len(items) > 1 and items[1]:
52 bb.debug(1, "Appending '%s' to IMAGE_FSTYPES." % items[1])
53 d.appendVar('IMAGE_FSTYPES', ' ' + items[1])
54
55 # Go out as we found a match!
56 break
57 else:
58 raise ValueError("UBOOT_CONFIG %s is not supported" % ubootconfig)
59}