Brad Bishop | 93fb535 | 2015-09-09 03:59:20 +0000 | [diff] [blame] | 1 | # Helper functions for checking feature variables. |
| 2 | |
| 3 | inherit utils |
| 4 | |
Brad Bishop | 6ba6a51 | 2016-07-10 19:44:42 -0400 | [diff] [blame] | 5 | |
Brad Bishop | 93fb535 | 2015-09-09 03:59:20 +0000 | [diff] [blame] | 6 | def df_enabled(feature, value, d): |
Brad Bishop | 6ba6a51 | 2016-07-10 19:44:42 -0400 | [diff] [blame] | 7 | return base_contains("DISTRO_FEATURES", feature, value, "", d) |
| 8 | |
Brad Bishop | 93fb535 | 2015-09-09 03:59:20 +0000 | [diff] [blame] | 9 | |
| 10 | def mf_enabled(feature, value, d): |
Brad Bishop | 6ba6a51 | 2016-07-10 19:44:42 -0400 | [diff] [blame] | 11 | return base_contains("MACHINE_FEATURES", feature, value, "", d) |
| 12 | |
Brad Bishop | 93fb535 | 2015-09-09 03:59:20 +0000 | [diff] [blame] | 13 | |
| 14 | def cf_enabled(feature, value, d): |
Brad Bishop | 6ba6a51 | 2016-07-10 19:44:42 -0400 | [diff] [blame] | 15 | return value if df_enabled(feature, value, d) \ |
| 16 | and mf_enabled(feature, value, d) \ |
| 17 | else "" |
Brad Bishop | 9dc5671 | 2016-07-07 15:56:02 -0400 | [diff] [blame] | 18 | |
| 19 | |
| 20 | def set_append(d, var, val, sep=' '): |
| 21 | values = (d.getVar(var, True) or '').split(sep) |
| 22 | if filter(bool, values): |
| 23 | d.appendVar(var, '%s%s' %(sep, val)) |
| 24 | else: |
| 25 | d.setVar(var, val) |
| 26 | |
| 27 | |
| 28 | def listvar_to_list(d, list_var, sep=' '): |
| 29 | return filter(bool, (d.getVar(list_var, True) or '').split(sep)) |