Seeking advice on best form to handle this situation:
I'm looking to make a GN file like this:
#deps and sources added.
deps = [ "a", "b", "c" ]
#Some conditional reason1 a,b shouldn't be included
deps -= [ "a", "b" ]
#Some conditional reason2 b,c shouldn't be included
deps -= [ "b", "c" ]
It's valuable to keep the conditional blocks separate, as they're fairly orthogonal logical reasons, but do have overlapping consequences of removing some of the same items.
I run into the error
You were trying to remove "b"
from the list but it wasn't there.
What's the recommended solution then?
a) I could only remove once, by munging together the logic blocks
if (reason1)
deps -= [ "a" ]
if (reason2)
deps -= [ "c" ]
if (reason1 || reason2)
deps -= [ "b" ]
b) I could have each block add to a list, to always be removed.
if (reason1)
deps_to_remove = [ "a", "b" ]
if (reason2)
deps_to_remove = [ "b", "c" ]
deps -= deps_to_remove
c) I could modify GN to support removal, without error if the item doesn't exist. Let's say -= has value producing a warning, I could add --=
if (reason1)
deps --= [ "a", "b" ]
if (reason2)
deps --= [ "b", "c" ]