Jingwen Chen | 30f5aaa | 2020-11-19 05:38:02 -0500 | [diff] [blame] | 1 | // Copyright 2020 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package bazel |
| 16 | |
Rupert Shuttleworth | 2e4219b | 2021-03-12 11:04:21 +0000 | [diff] [blame] | 17 | import ( |
| 18 | "fmt" |
Liz Kammer | a060c45 | 2021-03-24 10:14:47 -0400 | [diff] [blame] | 19 | "regexp" |
Rupert Shuttleworth | 2e4219b | 2021-03-12 11:04:21 +0000 | [diff] [blame] | 20 | "sort" |
| 21 | ) |
Jingwen Chen | 5d86449 | 2021-02-24 07:20:12 -0500 | [diff] [blame] | 22 | |
Jingwen Chen | 7385067 | 2020-12-14 08:25:34 -0500 | [diff] [blame] | 23 | // BazelTargetModuleProperties contain properties and metadata used for |
| 24 | // Blueprint to BUILD file conversion. |
| 25 | type BazelTargetModuleProperties struct { |
| 26 | // The Bazel rule class for this target. |
Liz Kammer | fc46bc1 | 2021-02-19 11:06:17 -0500 | [diff] [blame] | 27 | Rule_class string `blueprint:"mutated"` |
Jingwen Chen | 40067de | 2021-01-26 21:58:43 -0500 | [diff] [blame] | 28 | |
| 29 | // The target label for the bzl file containing the definition of the rule class. |
Liz Kammer | fc46bc1 | 2021-02-19 11:06:17 -0500 | [diff] [blame] | 30 | Bzl_load_location string `blueprint:"mutated"` |
Jingwen Chen | 7385067 | 2020-12-14 08:25:34 -0500 | [diff] [blame] | 31 | } |
Liz Kammer | 356f7d4 | 2021-01-26 09:18:53 -0500 | [diff] [blame] | 32 | |
Jingwen Chen | fb4692a | 2021-02-07 10:05:16 -0500 | [diff] [blame] | 33 | const BazelTargetModuleNamePrefix = "__bp2build__" |
| 34 | |
Liz Kammer | a060c45 | 2021-03-24 10:14:47 -0400 | [diff] [blame] | 35 | var productVariableSubstitutionPattern = regexp.MustCompile("%(d|s)") |
| 36 | |
Liz Kammer | 356f7d4 | 2021-01-26 09:18:53 -0500 | [diff] [blame] | 37 | // Label is used to represent a Bazel compatible Label. Also stores the original bp text to support |
| 38 | // string replacement. |
| 39 | type Label struct { |
| 40 | Bp_text string |
| 41 | Label string |
| 42 | } |
| 43 | |
| 44 | // LabelList is used to represent a list of Bazel labels. |
| 45 | type LabelList struct { |
| 46 | Includes []Label |
| 47 | Excludes []Label |
| 48 | } |
| 49 | |
| 50 | // Append appends the fields of other labelList to the corresponding fields of ll. |
| 51 | func (ll *LabelList) Append(other LabelList) { |
| 52 | if len(ll.Includes) > 0 || len(other.Includes) > 0 { |
| 53 | ll.Includes = append(ll.Includes, other.Includes...) |
| 54 | } |
| 55 | if len(ll.Excludes) > 0 || len(other.Excludes) > 0 { |
| 56 | ll.Excludes = append(other.Excludes, other.Excludes...) |
| 57 | } |
| 58 | } |
Jingwen Chen | 5d86449 | 2021-02-24 07:20:12 -0500 | [diff] [blame] | 59 | |
Rupert Shuttleworth | 2e4219b | 2021-03-12 11:04:21 +0000 | [diff] [blame] | 60 | func UniqueBazelLabels(originalLabels []Label) []Label { |
| 61 | uniqueLabelsSet := make(map[Label]bool) |
| 62 | for _, l := range originalLabels { |
| 63 | uniqueLabelsSet[l] = true |
| 64 | } |
| 65 | var uniqueLabels []Label |
| 66 | for l, _ := range uniqueLabelsSet { |
| 67 | uniqueLabels = append(uniqueLabels, l) |
| 68 | } |
| 69 | sort.SliceStable(uniqueLabels, func(i, j int) bool { |
| 70 | return uniqueLabels[i].Label < uniqueLabels[j].Label |
| 71 | }) |
| 72 | return uniqueLabels |
| 73 | } |
| 74 | |
| 75 | func UniqueBazelLabelList(originalLabelList LabelList) LabelList { |
| 76 | var uniqueLabelList LabelList |
| 77 | uniqueLabelList.Includes = UniqueBazelLabels(originalLabelList.Includes) |
| 78 | uniqueLabelList.Excludes = UniqueBazelLabels(originalLabelList.Excludes) |
| 79 | return uniqueLabelList |
| 80 | } |
| 81 | |
Jingwen Chen | 0702791 | 2021-03-15 06:02:43 -0400 | [diff] [blame] | 82 | const ( |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 83 | // ArchType names in arch.go |
Jingwen Chen | 0702791 | 2021-03-15 06:02:43 -0400 | [diff] [blame] | 84 | ARCH_ARM = "arm" |
| 85 | ARCH_ARM64 = "arm64" |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 86 | ARCH_X86 = "x86" |
| 87 | ARCH_X86_64 = "x86_64" |
| 88 | |
| 89 | // OsType names in arch.go |
| 90 | OS_ANDROID = "android" |
| 91 | OS_DARWIN = "darwin" |
| 92 | OS_FUCHSIA = "fuchsia" |
| 93 | OS_LINUX = "linux_glibc" |
| 94 | OS_LINUX_BIONIC = "linux_bionic" |
| 95 | OS_WINDOWS = "windows" |
Jingwen Chen | 0702791 | 2021-03-15 06:02:43 -0400 | [diff] [blame] | 96 | ) |
| 97 | |
| 98 | var ( |
Jingwen Chen | c1c2650 | 2021-04-05 10:35:13 +0000 | [diff] [blame^] | 99 | // These are the list of OSes and architectures with a Bazel config_setting |
| 100 | // and constraint value equivalent. These exist in arch.go, but the android |
| 101 | // package depends on the bazel package, so a cyclic dependency prevents |
| 102 | // using those variables here. |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 103 | |
| 104 | // A map of architectures to the Bazel label of the constraint_value |
| 105 | // for the @platforms//cpu:cpu constraint_setting |
| 106 | PlatformArchMap = map[string]string{ |
| 107 | ARCH_ARM: "//build/bazel/platforms/arch:arm", |
| 108 | ARCH_ARM64: "//build/bazel/platforms/arch:arm64", |
| 109 | ARCH_X86: "//build/bazel/platforms/arch:x86", |
| 110 | ARCH_X86_64: "//build/bazel/platforms/arch:x86_64", |
| 111 | } |
| 112 | |
| 113 | // A map of target operating systems to the Bazel label of the |
| 114 | // constraint_value for the @platforms//os:os constraint_setting |
| 115 | PlatformOsMap = map[string]string{ |
| 116 | OS_ANDROID: "//build/bazel/platforms/os:android", |
| 117 | OS_DARWIN: "//build/bazel/platforms/os:darwin", |
| 118 | OS_FUCHSIA: "//build/bazel/platforms/os:fuchsia", |
| 119 | OS_LINUX: "//build/bazel/platforms/os:linux", |
| 120 | OS_LINUX_BIONIC: "//build/bazel/platforms/os:linux_bionic", |
| 121 | OS_WINDOWS: "//build/bazel/platforms/os:windows", |
| 122 | } |
Jingwen Chen | 0702791 | 2021-03-15 06:02:43 -0400 | [diff] [blame] | 123 | ) |
| 124 | |
Jingwen Chen | c1c2650 | 2021-04-05 10:35:13 +0000 | [diff] [blame^] | 125 | type Attribute interface { |
| 126 | HasConfigurableValues() bool |
| 127 | } |
| 128 | |
Jingwen Chen | 0702791 | 2021-03-15 06:02:43 -0400 | [diff] [blame] | 129 | // Arch-specific label_list typed Bazel attribute values. This should correspond |
| 130 | // to the types of architectures supported for compilation in arch.go. |
| 131 | type labelListArchValues struct { |
| 132 | X86 LabelList |
| 133 | X86_64 LabelList |
| 134 | Arm LabelList |
| 135 | Arm64 LabelList |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 136 | Common LabelList |
| 137 | } |
| 138 | |
| 139 | type labelListOsValues struct { |
| 140 | Android LabelList |
| 141 | Darwin LabelList |
| 142 | Fuchsia LabelList |
| 143 | Linux LabelList |
| 144 | LinuxBionic LabelList |
| 145 | Windows LabelList |
Jingwen Chen | 0702791 | 2021-03-15 06:02:43 -0400 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | // LabelListAttribute is used to represent a list of Bazel labels as an |
| 149 | // attribute. |
| 150 | type LabelListAttribute struct { |
| 151 | // The non-arch specific attribute label list Value. Required. |
| 152 | Value LabelList |
| 153 | |
| 154 | // The arch-specific attribute label list values. Optional. If used, these |
| 155 | // are generated in a select statement and appended to the non-arch specific |
| 156 | // label list Value. |
| 157 | ArchValues labelListArchValues |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 158 | |
| 159 | // The os-specific attribute label list values. Optional. If used, these |
| 160 | // are generated in a select statement and appended to the non-os specific |
| 161 | // label list Value. |
| 162 | OsValues labelListOsValues |
Jingwen Chen | 0702791 | 2021-03-15 06:02:43 -0400 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | // MakeLabelListAttribute initializes a LabelListAttribute with the non-arch specific value. |
| 166 | func MakeLabelListAttribute(value LabelList) LabelListAttribute { |
| 167 | return LabelListAttribute{Value: UniqueBazelLabelList(value)} |
| 168 | } |
| 169 | |
| 170 | // HasArchSpecificValues returns true if the attribute contains |
| 171 | // architecture-specific label_list values. |
Jingwen Chen | c1c2650 | 2021-04-05 10:35:13 +0000 | [diff] [blame^] | 172 | func (attrs LabelListAttribute) HasConfigurableValues() bool { |
| 173 | for arch := range PlatformArchMap { |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 174 | if len(attrs.GetValueForArch(arch).Includes) > 0 { |
| 175 | return true |
| 176 | } |
| 177 | } |
| 178 | |
Jingwen Chen | c1c2650 | 2021-04-05 10:35:13 +0000 | [diff] [blame^] | 179 | for os := range PlatformOsMap { |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 180 | if len(attrs.GetValueForOS(os).Includes) > 0 { |
Jingwen Chen | 0702791 | 2021-03-15 06:02:43 -0400 | [diff] [blame] | 181 | return true |
| 182 | } |
| 183 | } |
| 184 | return false |
| 185 | } |
| 186 | |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 187 | func (attrs *LabelListAttribute) archValuePtrs() map[string]*LabelList { |
| 188 | return map[string]*LabelList{ |
| 189 | ARCH_X86: &attrs.ArchValues.X86, |
| 190 | ARCH_X86_64: &attrs.ArchValues.X86_64, |
| 191 | ARCH_ARM: &attrs.ArchValues.Arm, |
| 192 | ARCH_ARM64: &attrs.ArchValues.Arm64, |
| 193 | } |
| 194 | } |
| 195 | |
Jingwen Chen | 0702791 | 2021-03-15 06:02:43 -0400 | [diff] [blame] | 196 | // GetValueForArch returns the label_list attribute value for an architecture. |
| 197 | func (attrs *LabelListAttribute) GetValueForArch(arch string) LabelList { |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 198 | var v *LabelList |
| 199 | if v = attrs.archValuePtrs()[arch]; v == nil { |
Jingwen Chen | 0702791 | 2021-03-15 06:02:43 -0400 | [diff] [blame] | 200 | panic(fmt.Errorf("Unknown arch: %s", arch)) |
| 201 | } |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 202 | return *v |
Jingwen Chen | 0702791 | 2021-03-15 06:02:43 -0400 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | // SetValueForArch sets the label_list attribute value for an architecture. |
| 206 | func (attrs *LabelListAttribute) SetValueForArch(arch string, value LabelList) { |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 207 | var v *LabelList |
| 208 | if v = attrs.archValuePtrs()[arch]; v == nil { |
Jingwen Chen | 0702791 | 2021-03-15 06:02:43 -0400 | [diff] [blame] | 209 | panic(fmt.Errorf("Unknown arch: %s", arch)) |
| 210 | } |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 211 | *v = value |
| 212 | } |
| 213 | |
| 214 | func (attrs *LabelListAttribute) osValuePtrs() map[string]*LabelList { |
| 215 | return map[string]*LabelList{ |
| 216 | OS_ANDROID: &attrs.OsValues.Android, |
| 217 | OS_DARWIN: &attrs.OsValues.Darwin, |
| 218 | OS_FUCHSIA: &attrs.OsValues.Fuchsia, |
| 219 | OS_LINUX: &attrs.OsValues.Linux, |
| 220 | OS_LINUX_BIONIC: &attrs.OsValues.LinuxBionic, |
| 221 | OS_WINDOWS: &attrs.OsValues.Windows, |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | // GetValueForOS returns the label_list attribute value for an OS target. |
| 226 | func (attrs *LabelListAttribute) GetValueForOS(os string) LabelList { |
| 227 | var v *LabelList |
| 228 | if v = attrs.osValuePtrs()[os]; v == nil { |
| 229 | panic(fmt.Errorf("Unknown os: %s", os)) |
| 230 | } |
| 231 | return *v |
| 232 | } |
| 233 | |
| 234 | // SetValueForArch sets the label_list attribute value for an OS target. |
| 235 | func (attrs *LabelListAttribute) SetValueForOS(os string, value LabelList) { |
| 236 | var v *LabelList |
| 237 | if v = attrs.osValuePtrs()[os]; v == nil { |
| 238 | panic(fmt.Errorf("Unknown os: %s", os)) |
| 239 | } |
| 240 | *v = value |
Jingwen Chen | 0702791 | 2021-03-15 06:02:43 -0400 | [diff] [blame] | 241 | } |
| 242 | |
Jingwen Chen | 5d86449 | 2021-02-24 07:20:12 -0500 | [diff] [blame] | 243 | // StringListAttribute corresponds to the string_list Bazel attribute type with |
| 244 | // support for additional metadata, like configurations. |
| 245 | type StringListAttribute struct { |
| 246 | // The base value of the string list attribute. |
| 247 | Value []string |
| 248 | |
Jingwen Chen | c1c2650 | 2021-04-05 10:35:13 +0000 | [diff] [blame^] | 249 | // The arch-specific attribute string list values. Optional. If used, these |
| 250 | // are generated in a select statement and appended to the non-arch specific |
| 251 | // label list Value. |
Jingwen Chen | 5d86449 | 2021-02-24 07:20:12 -0500 | [diff] [blame] | 252 | ArchValues stringListArchValues |
Jingwen Chen | c1c2650 | 2021-04-05 10:35:13 +0000 | [diff] [blame^] | 253 | |
| 254 | // The os-specific attribute string list values. Optional. If used, these |
| 255 | // are generated in a select statement and appended to the non-os specific |
| 256 | // label list Value. |
| 257 | OsValues stringListOsValues |
Jingwen Chen | 5d86449 | 2021-02-24 07:20:12 -0500 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | // Arch-specific string_list typed Bazel attribute values. This should correspond |
| 261 | // to the types of architectures supported for compilation in arch.go. |
| 262 | type stringListArchValues struct { |
Jingwen Chen | 0702791 | 2021-03-15 06:02:43 -0400 | [diff] [blame] | 263 | X86 []string |
| 264 | X86_64 []string |
| 265 | Arm []string |
| 266 | Arm64 []string |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 267 | Common []string |
Jingwen Chen | 5d86449 | 2021-02-24 07:20:12 -0500 | [diff] [blame] | 268 | } |
| 269 | |
Jingwen Chen | c1c2650 | 2021-04-05 10:35:13 +0000 | [diff] [blame^] | 270 | type stringListOsValues struct { |
| 271 | Android []string |
| 272 | Darwin []string |
| 273 | Fuchsia []string |
| 274 | Linux []string |
| 275 | LinuxBionic []string |
| 276 | Windows []string |
| 277 | } |
| 278 | |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 279 | // HasConfigurableValues returns true if the attribute contains |
Jingwen Chen | 5d86449 | 2021-02-24 07:20:12 -0500 | [diff] [blame] | 280 | // architecture-specific string_list values. |
Jingwen Chen | c1c2650 | 2021-04-05 10:35:13 +0000 | [diff] [blame^] | 281 | func (attrs StringListAttribute) HasConfigurableValues() bool { |
| 282 | for arch := range PlatformArchMap { |
Jingwen Chen | 5d86449 | 2021-02-24 07:20:12 -0500 | [diff] [blame] | 283 | if len(attrs.GetValueForArch(arch)) > 0 { |
| 284 | return true |
| 285 | } |
| 286 | } |
Jingwen Chen | c1c2650 | 2021-04-05 10:35:13 +0000 | [diff] [blame^] | 287 | |
| 288 | for os := range PlatformOsMap { |
| 289 | if len(attrs.GetValueForOS(os)) > 0 { |
| 290 | return true |
| 291 | } |
| 292 | } |
Jingwen Chen | 5d86449 | 2021-02-24 07:20:12 -0500 | [diff] [blame] | 293 | return false |
| 294 | } |
| 295 | |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 296 | func (attrs *StringListAttribute) archValuePtrs() map[string]*[]string { |
| 297 | return map[string]*[]string{ |
| 298 | ARCH_X86: &attrs.ArchValues.X86, |
| 299 | ARCH_X86_64: &attrs.ArchValues.X86_64, |
| 300 | ARCH_ARM: &attrs.ArchValues.Arm, |
| 301 | ARCH_ARM64: &attrs.ArchValues.Arm64, |
| 302 | } |
| 303 | } |
| 304 | |
Jingwen Chen | 5d86449 | 2021-02-24 07:20:12 -0500 | [diff] [blame] | 305 | // GetValueForArch returns the string_list attribute value for an architecture. |
| 306 | func (attrs *StringListAttribute) GetValueForArch(arch string) []string { |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 307 | var v *[]string |
| 308 | if v = attrs.archValuePtrs()[arch]; v == nil { |
Jingwen Chen | 5d86449 | 2021-02-24 07:20:12 -0500 | [diff] [blame] | 309 | panic(fmt.Errorf("Unknown arch: %s", arch)) |
| 310 | } |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 311 | return *v |
Jingwen Chen | 5d86449 | 2021-02-24 07:20:12 -0500 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | // SetValueForArch sets the string_list attribute value for an architecture. |
| 315 | func (attrs *StringListAttribute) SetValueForArch(arch string, value []string) { |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 316 | var v *[]string |
| 317 | if v = attrs.archValuePtrs()[arch]; v == nil { |
Jingwen Chen | 5d86449 | 2021-02-24 07:20:12 -0500 | [diff] [blame] | 318 | panic(fmt.Errorf("Unknown arch: %s", arch)) |
| 319 | } |
Jingwen Chen | 91220d7 | 2021-03-24 02:18:33 -0400 | [diff] [blame] | 320 | *v = value |
Jingwen Chen | 5d86449 | 2021-02-24 07:20:12 -0500 | [diff] [blame] | 321 | } |
Liz Kammer | a060c45 | 2021-03-24 10:14:47 -0400 | [diff] [blame] | 322 | |
Jingwen Chen | c1c2650 | 2021-04-05 10:35:13 +0000 | [diff] [blame^] | 323 | func (attrs *StringListAttribute) osValuePtrs() map[string]*[]string { |
| 324 | return map[string]*[]string{ |
| 325 | OS_ANDROID: &attrs.OsValues.Android, |
| 326 | OS_DARWIN: &attrs.OsValues.Darwin, |
| 327 | OS_FUCHSIA: &attrs.OsValues.Fuchsia, |
| 328 | OS_LINUX: &attrs.OsValues.Linux, |
| 329 | OS_LINUX_BIONIC: &attrs.OsValues.LinuxBionic, |
| 330 | OS_WINDOWS: &attrs.OsValues.Windows, |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | // GetValueForOS returns the string_list attribute value for an OS target. |
| 335 | func (attrs *StringListAttribute) GetValueForOS(os string) []string { |
| 336 | var v *[]string |
| 337 | if v = attrs.osValuePtrs()[os]; v == nil { |
| 338 | panic(fmt.Errorf("Unknown os: %s", os)) |
| 339 | } |
| 340 | return *v |
| 341 | } |
| 342 | |
| 343 | // SetValueForArch sets the string_list attribute value for an OS target. |
| 344 | func (attrs *StringListAttribute) SetValueForOS(os string, value []string) { |
| 345 | var v *[]string |
| 346 | if v = attrs.osValuePtrs()[os]; v == nil { |
| 347 | panic(fmt.Errorf("Unknown os: %s", os)) |
| 348 | } |
| 349 | *v = value |
| 350 | } |
| 351 | |
Liz Kammer | a060c45 | 2021-03-24 10:14:47 -0400 | [diff] [blame] | 352 | // TryVariableSubstitution, replace string substitution formatting within each string in slice with |
| 353 | // Starlark string.format compatible tag for productVariable. |
| 354 | func TryVariableSubstitutions(slice []string, productVariable string) ([]string, bool) { |
| 355 | ret := make([]string, 0, len(slice)) |
| 356 | changesMade := false |
| 357 | for _, s := range slice { |
| 358 | newS, changed := TryVariableSubstitution(s, productVariable) |
| 359 | ret = append(ret, newS) |
| 360 | changesMade = changesMade || changed |
| 361 | } |
| 362 | return ret, changesMade |
| 363 | } |
| 364 | |
| 365 | // TryVariableSubstitution, replace string substitution formatting within s with Starlark |
| 366 | // string.format compatible tag for productVariable. |
| 367 | func TryVariableSubstitution(s string, productVariable string) (string, bool) { |
| 368 | sub := productVariableSubstitutionPattern.ReplaceAllString(s, "{"+productVariable+"}") |
| 369 | return sub, s != sub |
| 370 | } |