summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
authorTom Zanussi <tom.zanussi@linux.intel.com>2013-07-10 14:11:44 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-07-13 17:23:39 (GMT)
commit74e403705e25afec656b5e40921771a9c29bdc40 (patch)
treeb65f3d5ce4e54b93c2c60b303bea8341f7741126 /scripts/lib
parent46818e5227e173666f8ad704ff2fe622ffaa2414 (diff)
downloadpoky-74e403705e25afec656b5e40921771a9c29bdc40.tar.gz
yocto-kernel: make BBLAYERS parsing more robust
This allows the BBLAYERS parsing code to handle cases where BBLAYERS is spread across multiple assignments or all on a single line, within double or single quotes. Fixes [YOCTO #3746]. (From meta-yocto rev: 4ab26d9e655bab0069ffe9b135557d943cf1f524) Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/bsp/kernel.py38
1 files changed, 24 insertions, 14 deletions
diff --git a/scripts/lib/bsp/kernel.py b/scripts/lib/bsp/kernel.py
index c3592a3..1971e90 100644
--- a/scripts/lib/bsp/kernel.py
+++ b/scripts/lib/bsp/kernel.py
@@ -60,14 +60,12 @@ def find_bblayers(scripts_path):
60 in_bblayers = True 60 in_bblayers = True
61 quotes = line.strip().count('"') 61 quotes = line.strip().count('"')
62 if quotes > 1: 62 if quotes > 1:
63 break 63 in_bblayers = False
64 continue 64 continue
65 if in_bblayers: 65 if in_bblayers:
66 bblayers_lines.append(line) 66 bblayers_lines.append(line)
67 if line.strip().endswith("\""): 67 if line.strip().endswith("\""):
68 break 68 in_bblayers = False
69 else:
70 continue
71 69
72 for i, line in enumerate(bblayers_lines): 70 for i, line in enumerate(bblayers_lines):
73 if line.strip().endswith("\\"): 71 if line.strip().endswith("\\"):
@@ -75,19 +73,31 @@ def find_bblayers(scripts_path):
75 73
76 bblayers_line = " ".join(bblayers_lines) 74 bblayers_line = " ".join(bblayers_lines)
77 75
78 start_quote = bblayers_line.find("\"") 76 openquote = ''
79 if start_quote == -1: 77 for c in bblayers_line:
80 print "Invalid BBLAYERS found in %s, exiting" % bblayers_conf 78 if c == '\"' or c == '\'':
81 sys.exit(1) 79 if openquote:
80 if c != openquote:
81 print "Invalid BBLAYERS found in %s, exiting" % bblayers_conf
82 sys.exit(1)
83 else:
84 openquote = ''
85 else:
86 openquote = c
82 87
83 start_quote += 1 88 if openquote:
84 end_quote = bblayers_line.find("\"", start_quote)
85 if end_quote == -1:
86 print "Invalid BBLAYERS found in %s, exiting" % bblayers_conf 89 print "Invalid BBLAYERS found in %s, exiting" % bblayers_conf
87 sys.exit(1) 90 sys.exit(1)
88 91
89 bblayers_line = bblayers_line[start_quote:end_quote] 92 bblayers_line = bblayers_line.strip().replace('\"', '')
90 layers = bblayers_line.split() 93 bblayers_line = bblayers_line.strip().replace('\'', '')
94
95 raw_layers = bblayers_line.split()
96
97 for layer in raw_layers:
98 if layer == 'BBLAYERS' or '=' in layer:
99 continue
100 layers.append(layer)
91 101
92 f.close() 102 f.close()
93 103
@@ -114,7 +124,7 @@ def find_bsp_layer(scripts_path, machine):
114 layers = find_bblayers(scripts_path) 124 layers = find_bblayers(scripts_path)
115 125
116 for layer in layers: 126 for layer in layers:
117 if machine in layer: 127 if layer.endswith(machine):
118 return layer 128 return layer
119 129
120 print "Unable to find the BSP layer for machine %s." % machine 130 print "Unable to find the BSP layer for machine %s." % machine