From 79b724dce8d5a745d5ca2933c64ccfffbda6e367 Mon Sep 17 00:00:00 2001 From: Gustavo Jose de Sousa Date: Tue, 1 Mar 2016 19:19:22 -0300 Subject: [PATCH] waf: ardupilotwaf: fix board env processing Two things are fixed with this patch: 1. We sort dictionaries' keys if they aren't OrderedDict instances. Since dict objects don't guarantee order, environment variables may have contents in wrong order, causing unnecessary rebuilds. 2. We only use prepend_value() if there's already a value set for the key and that value is list. Before this change, boards couldn't set non-iterable values. --- Tools/ardupilotwaf/boards.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Tools/ardupilotwaf/boards.py b/Tools/ardupilotwaf/boards.py index e11b3dbc46..ce4fbc9354 100644 --- a/Tools/ardupilotwaf/boards.py +++ b/Tools/ardupilotwaf/boards.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # encoding: utf-8 +from collections import OrderedDict import sys import waflib @@ -26,10 +27,15 @@ class Board: # Dictionaries (like 'DEFINES') are converted to lists to # conform to waf conventions. if isinstance(val, dict): - for item in val.items(): - cfg.env.prepend_value(k, '%s=%s' % item) - else: + keys = list(val.keys()) + if not isinstance(val, OrderedDict): + keys.sort() + val = ['%s=%s' % (vk, val[vk]) for vk in keys] + + if k in cfg.env and isinstance(cfg.env, list): cfg.env.prepend_value(k, val) + else: + cfg.env[k] = val def configure_env(self, env): # Use a dictionary instead of the convetional list for definitions to