diff options
| author | Trevor Radcliffe <tradical@google.com> | 2023-09-21 13:05:21 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2023-09-21 13:05:21 +0000 |
| commit | 9483e4873cb6487c9c79ca7a7c95ecfa8a7c7892 (patch) | |
| tree | 4cbaa7c282b75a8a167982446372cf39d2d689cb /bazel | |
| parent | 53b33d07b12a86b5be288e2bf967567520fa7d69 (diff) | |
| parent | f9abec0987feb81132201179217ad0ea66ae4074 (diff) | |
Merge "Block CFI on static libraries" into main
Diffstat (limited to 'bazel')
| -rw-r--r-- | bazel/properties.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/bazel/properties.go b/bazel/properties.go index 9c63bc04b..29e44afb3 100644 --- a/bazel/properties.go +++ b/bazel/properties.go @@ -1296,6 +1296,42 @@ func (sla StringListAttribute) IsEmpty() bool { return len(sla.Value) == 0 && !sla.HasConfigurableValues() } +// RemoveFromAllConfigs removes all instances of the specified value from all configurations +// of the givenStringListAttribute +func (sla *StringListAttribute) RemoveFromAllConfigs(toRemove string) { + if removed, removalResult := removeFromList(toRemove, sla.Value); removed { + if len(removalResult) > 0 { + sla.Value = removalResult + } else { + sla.Value = nil + } + } + for axis, slsv := range sla.ConfigurableValues { + for config, sl := range slsv { + if removed, removalResult := removeFromList(toRemove, sl); removed { + if len(removalResult) > 0 { + sla.SetSelectValue(axis, config, removalResult) + } else { + sla.SetSelectValue(axis, config, nil) + } + } + } + } +} + +func removeFromList(s string, list []string) (bool, []string) { + result := make([]string, 0, len(list)) + var removed bool + for _, item := range list { + if item != s { + result = append(result, item) + } else { + removed = true + } + } + return removed, result +} + type configurableStringLists map[ConfigurationAxis]stringListSelectValues func (csl configurableStringLists) Append(other configurableStringLists) { |
