Express no{,_lib}crt via features vs attrs
Given that we can map them directly to disabling the
corresponding Bazel features: `-{link_,use_lib}crt`
Test: Existing (adapted) Unit Tests
Test: bp2build.sh
Change-Id: Ib502f6fb929ace8e86a1001e3cc21f399317500c
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 6c5505a..250241c 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -965,8 +965,6 @@
systemDynamicDeps bazel.LabelListAttribute
usedSystemDynamicDepAsDynamicDep map[string]bool
- linkCrt bazel.BoolAttribute
- useLibcrt bazel.BoolAttribute
useVersionLib bazel.BoolAttribute
linkopts bazel.StringListAttribute
additionalLinkerInputs bazel.LabelListAttribute
@@ -1138,6 +1136,13 @@
}
}
+ if !props.libCrt() {
+ axisFeatures = append(axisFeatures, "-use_libcrt")
+ }
+ if !props.crt() {
+ axisFeatures = append(axisFeatures, "-link_crt")
+ }
+
// This must happen before the addition of flags for Version Script and
// Dynamic List, as these flags must be split on spaces and those must not
linkerFlags = parseCommandLineFlags(linkerFlags, filterOutClangUnknownCflags)
@@ -1157,16 +1162,6 @@
la.additionalLinkerInputs.SetSelectValue(axis, config, additionalLinkerInputs)
la.linkopts.SetSelectValue(axis, config, linkerFlags)
- la.useLibcrt.SetSelectValue(axis, config, props.libCrt())
-
- // it's very unlikely for nocrt to be arch variant, so bp2build doesn't support it.
- if props.crt() != nil {
- if axis == bazel.NoConfigAxis {
- la.linkCrt.SetSelectValue(axis, config, props.crt())
- } else if axis == bazel.ArchConfigurationAxis {
- ctx.ModuleErrorf("nocrt is not supported for arch variants")
- }
- }
if axisFeatures != nil {
la.features.SetSelectValue(axis, config, axisFeatures)