diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2017-11-07 17:55:22 +0000 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2017-11-08 08:03:15 +0000 |
commit | 34ba445fd1963acada0733c196483c98a57fd753 (patch) | |
tree | 2d7cbd9de644aa8b28a3576de483cbfe0e03f685 /buildstream/_yaml.py | |
parent | 2780cdbde866a65108d10d030fe7d40015df1b27 (diff) | |
download | buildstream-34ba445fd1963acada0733c196483c98a57fd753.tar.gz |
Allow overwriting a list with an empty list using (=) operatorsam/overwrite-list-with-empty-list
I found myself writing the following split rules for an element:
public:
bst:
split-rules:
runtime:
(=): []
devel:
(>):
- |
%{bindir}/*
The aim was to put all of this element's binaries into the 'devel'
domain, and make sure nothing went into the 'runtime' domain by
replacing the built-in rules for that domain with an empty list.
That wasn't working though because BuildStream was using [] (empty list)
as a sentinel to mean "do nothing", which is fine for the prepend and
append operators (prepending an empty list to a list has no effect) but
is not really correct for the overwrite operator.
This commit fixes that issue and adds a test.
Diffstat (limited to 'buildstream/_yaml.py')
-rw-r--r-- | buildstream/_yaml.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/buildstream/_yaml.py b/buildstream/_yaml.py index 153e744f4..11b5fd219 100644 --- a/buildstream/_yaml.py +++ b/buildstream/_yaml.py @@ -552,8 +552,10 @@ def composite_list_append(target_node, target_key, source_node, source_key): # def composite_list_overwrite(target_node, target_key, source_node, source_key): - source_list = node_get(source_node, list, source_key, default_value=[]) - if not source_list: + # We need to handle the legitimate case of overwriting a list with an empty + # list, hence the slightly odd default_value of [None] rather than []. + source_list = node_get(source_node, list, source_key, default_value=[None]) + if source_list == [None]: return False target_provenance = node_get_provenance(target_node) |