Refactor how bp2build gets arch-specific props.
Then plumb them to LabelAttribute.
This refactoring is required because the previous implementation did not
handle properties in shards other than the first one (e.g.
version_script) well. In addition, it also makes the code paths between
bp2build and analysis more similar.
Bug: 186650430
Test: Presubmits.
Change-Id: Ic4393e8ae47f4e88816bf45c89399efd61494d22
diff --git a/bazel/properties.go b/bazel/properties.go
index 12dfcaf..a71b12b 100644
--- a/bazel/properties.go
+++ b/bazel/properties.go
@@ -229,11 +229,47 @@
// Represents an attribute whose value is a single label
type LabelAttribute struct {
- Value Label
+ Value Label
+ X86 Label
+ X86_64 Label
+ Arm Label
+ Arm64 Label
}
-func (LabelAttribute) HasConfigurableValues() bool {
- return false
+func (attr *LabelAttribute) GetValueForArch(arch string) Label {
+ switch arch {
+ case ARCH_ARM:
+ return attr.Arm
+ case ARCH_ARM64:
+ return attr.Arm64
+ case ARCH_X86:
+ return attr.X86
+ case ARCH_X86_64:
+ return attr.X86_64
+ case CONDITIONS_DEFAULT:
+ return attr.Value
+ default:
+ panic("Invalid arch type")
+ }
+}
+
+func (attr *LabelAttribute) SetValueForArch(arch string, value Label) {
+ switch arch {
+ case ARCH_ARM:
+ attr.Arm = value
+ case ARCH_ARM64:
+ attr.Arm64 = value
+ case ARCH_X86:
+ attr.X86 = value
+ case ARCH_X86_64:
+ attr.X86_64 = value
+ default:
+ panic("Invalid arch type")
+ }
+}
+
+func (attr LabelAttribute) HasConfigurableValues() bool {
+ return attr.Arm.Label != "" || attr.Arm64.Label != "" || attr.X86.Label != "" || attr.X86_64.Label != ""
}
// Arch-specific label_list typed Bazel attribute values. This should correspond