diff options
Diffstat (limited to 'scripts/lib/checklayer/__init__.py')
-rw-r--r-- | scripts/lib/checklayer/__init__.py | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/scripts/lib/checklayer/__init__.py b/scripts/lib/checklayer/__init__.py index fe545607bb..62ecdfe390 100644 --- a/scripts/lib/checklayer/__init__.py +++ b/scripts/lib/checklayer/__init__.py | |||
@@ -16,6 +16,7 @@ class LayerType(Enum): | |||
16 | BSP = 0 | 16 | BSP = 0 |
17 | DISTRO = 1 | 17 | DISTRO = 1 |
18 | SOFTWARE = 2 | 18 | SOFTWARE = 2 |
19 | CORE = 3 | ||
19 | ERROR_NO_LAYER_CONF = 98 | 20 | ERROR_NO_LAYER_CONF = 98 |
20 | ERROR_BSP_DISTRO = 99 | 21 | ERROR_BSP_DISTRO = 99 |
21 | 22 | ||
@@ -43,7 +44,7 @@ def _get_layer_collections(layer_path, lconf=None, data=None): | |||
43 | 44 | ||
44 | ldata.setVar('LAYERDIR', layer_path) | 45 | ldata.setVar('LAYERDIR', layer_path) |
45 | try: | 46 | try: |
46 | ldata = bb.parse.handle(lconf, ldata, include=True) | 47 | ldata = bb.parse.handle(lconf, ldata, include=True, baseconfig=True) |
47 | except: | 48 | except: |
48 | raise RuntimeError("Parsing of layer.conf from layer: %s failed" % layer_path) | 49 | raise RuntimeError("Parsing of layer.conf from layer: %s failed" % layer_path) |
49 | ldata.expandVarref('LAYERDIR') | 50 | ldata.expandVarref('LAYERDIR') |
@@ -106,7 +107,13 @@ def _detect_layer(layer_path): | |||
106 | if distros: | 107 | if distros: |
107 | is_distro = True | 108 | is_distro = True |
108 | 109 | ||
109 | if is_bsp and is_distro: | 110 | layer['collections'] = _get_layer_collections(layer['path']) |
111 | |||
112 | if layer_name == "meta" and "core" in layer['collections']: | ||
113 | layer['type'] = LayerType.CORE | ||
114 | layer['conf']['machines'] = machines | ||
115 | layer['conf']['distros'] = distros | ||
116 | elif is_bsp and is_distro: | ||
110 | layer['type'] = LayerType.ERROR_BSP_DISTRO | 117 | layer['type'] = LayerType.ERROR_BSP_DISTRO |
111 | elif is_bsp: | 118 | elif is_bsp: |
112 | layer['type'] = LayerType.BSP | 119 | layer['type'] = LayerType.BSP |
@@ -117,8 +124,6 @@ def _detect_layer(layer_path): | |||
117 | else: | 124 | else: |
118 | layer['type'] = LayerType.SOFTWARE | 125 | layer['type'] = LayerType.SOFTWARE |
119 | 126 | ||
120 | layer['collections'] = _get_layer_collections(layer['path']) | ||
121 | |||
122 | return layer | 127 | return layer |
123 | 128 | ||
124 | def detect_layers(layer_directories, no_auto): | 129 | def detect_layers(layer_directories, no_auto): |
@@ -146,7 +151,7 @@ def detect_layers(layer_directories, no_auto): | |||
146 | 151 | ||
147 | return layers | 152 | return layers |
148 | 153 | ||
149 | def _find_layer_depends(depend, layers): | 154 | def _find_layer(depend, layers): |
150 | for layer in layers: | 155 | for layer in layers: |
151 | if 'collections' not in layer: | 156 | if 'collections' not in layer: |
152 | continue | 157 | continue |
@@ -156,7 +161,28 @@ def _find_layer_depends(depend, layers): | |||
156 | return layer | 161 | return layer |
157 | return None | 162 | return None |
158 | 163 | ||
159 | def add_layer_dependencies(bblayersconf, layer, layers, logger): | 164 | def sanity_check_layers(layers, logger): |
165 | """ | ||
166 | Check that we didn't find duplicate collection names, as the layer that will | ||
167 | be used is non-deterministic. The precise check is duplicate collections | ||
168 | with different patterns, as the same pattern being repeated won't cause | ||
169 | problems. | ||
170 | """ | ||
171 | import collections | ||
172 | |||
173 | passed = True | ||
174 | seen = collections.defaultdict(set) | ||
175 | for layer in layers: | ||
176 | for name, data in layer.get("collections", {}).items(): | ||
177 | seen[name].add(data["pattern"]) | ||
178 | |||
179 | for name, patterns in seen.items(): | ||
180 | if len(patterns) > 1: | ||
181 | passed = False | ||
182 | logger.error("Collection %s found multiple times: %s" % (name, ", ".join(patterns))) | ||
183 | return passed | ||
184 | |||
185 | def get_layer_dependencies(layer, layers, logger): | ||
160 | def recurse_dependencies(depends, layer, layers, logger, ret = []): | 186 | def recurse_dependencies(depends, layer, layers, logger, ret = []): |
161 | logger.debug('Processing dependencies %s for layer %s.' % \ | 187 | logger.debug('Processing dependencies %s for layer %s.' % \ |
162 | (depends, layer['name'])) | 188 | (depends, layer['name'])) |
@@ -166,7 +192,7 @@ def add_layer_dependencies(bblayersconf, layer, layers, logger): | |||
166 | if depend == 'core': | 192 | if depend == 'core': |
167 | continue | 193 | continue |
168 | 194 | ||
169 | layer_depend = _find_layer_depends(depend, layers) | 195 | layer_depend = _find_layer(depend, layers) |
170 | if not layer_depend: | 196 | if not layer_depend: |
171 | logger.error('Layer %s depends on %s and isn\'t found.' % \ | 197 | logger.error('Layer %s depends on %s and isn\'t found.' % \ |
172 | (layer['name'], depend)) | 198 | (layer['name'], depend)) |
@@ -203,6 +229,11 @@ def add_layer_dependencies(bblayersconf, layer, layers, logger): | |||
203 | layer_depends = recurse_dependencies(depends, layer, layers, logger, layer_depends) | 229 | layer_depends = recurse_dependencies(depends, layer, layers, logger, layer_depends) |
204 | 230 | ||
205 | # Note: [] (empty) is allowed, None is not! | 231 | # Note: [] (empty) is allowed, None is not! |
232 | return layer_depends | ||
233 | |||
234 | def add_layer_dependencies(bblayersconf, layer, layers, logger): | ||
235 | |||
236 | layer_depends = get_layer_dependencies(layer, layers, logger) | ||
206 | if layer_depends is None: | 237 | if layer_depends is None: |
207 | return False | 238 | return False |
208 | else: | 239 | else: |
@@ -256,7 +287,7 @@ def check_command(error_msg, cmd, cwd=None): | |||
256 | raise RuntimeError(msg) | 287 | raise RuntimeError(msg) |
257 | return output | 288 | return output |
258 | 289 | ||
259 | def get_signatures(builddir, failsafe=False, machine=None): | 290 | def get_signatures(builddir, failsafe=False, machine=None, extravars=None): |
260 | import re | 291 | import re |
261 | 292 | ||
262 | # some recipes needs to be excluded like meta-world-pkgdata | 293 | # some recipes needs to be excluded like meta-world-pkgdata |
@@ -267,13 +298,16 @@ def get_signatures(builddir, failsafe=False, machine=None): | |||
267 | sigs = {} | 298 | sigs = {} |
268 | tune2tasks = {} | 299 | tune2tasks = {} |
269 | 300 | ||
270 | cmd = 'BB_ENV_EXTRAWHITE="$BB_ENV_EXTRAWHITE BB_SIGNATURE_HANDLER" BB_SIGNATURE_HANDLER="OEBasicHash" ' | 301 | cmd = 'BB_ENV_PASSTHROUGH_ADDITIONS="$BB_ENV_PASSTHROUGH_ADDITIONS BB_SIGNATURE_HANDLER" BB_SIGNATURE_HANDLER="OEBasicHash" ' |
302 | if extravars: | ||
303 | cmd += extravars | ||
304 | cmd += ' ' | ||
271 | if machine: | 305 | if machine: |
272 | cmd += 'MACHINE=%s ' % machine | 306 | cmd += 'MACHINE=%s ' % machine |
273 | cmd += 'bitbake ' | 307 | cmd += 'bitbake ' |
274 | if failsafe: | 308 | if failsafe: |
275 | cmd += '-k ' | 309 | cmd += '-k ' |
276 | cmd += '-S none world' | 310 | cmd += '-S lockedsigs world' |
277 | sigs_file = os.path.join(builddir, 'locked-sigs.inc') | 311 | sigs_file = os.path.join(builddir, 'locked-sigs.inc') |
278 | if os.path.exists(sigs_file): | 312 | if os.path.exists(sigs_file): |
279 | os.unlink(sigs_file) | 313 | os.unlink(sigs_file) |
@@ -290,8 +324,8 @@ def get_signatures(builddir, failsafe=False, machine=None): | |||
290 | else: | 324 | else: |
291 | raise | 325 | raise |
292 | 326 | ||
293 | sig_regex = re.compile("^(?P<task>.*:.*):(?P<hash>.*) .$") | 327 | sig_regex = re.compile(r"^(?P<task>.*:.*):(?P<hash>.*) .$") |
294 | tune_regex = re.compile("(^|\s)SIGGEN_LOCKEDSIGS_t-(?P<tune>\S*)\s*=\s*") | 328 | tune_regex = re.compile(r"(^|\s)SIGGEN_LOCKEDSIGS_t-(?P<tune>\S*)\s*=\s*") |
295 | current_tune = None | 329 | current_tune = None |
296 | with open(sigs_file, 'r') as f: | 330 | with open(sigs_file, 'r') as f: |
297 | for line in f.readlines(): | 331 | for line in f.readlines(): |