Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 1 | // Copyright 2021 Google LLC |
| 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 mk2rbc |
| 16 | |
| 17 | import ( |
| 18 | "bytes" |
Sasha Smundak | 6609ba7 | 2021-07-22 18:32:56 -0700 | [diff] [blame] | 19 | "io/fs" |
| 20 | "path/filepath" |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 21 | "strings" |
| 22 | "testing" |
| 23 | ) |
| 24 | |
| 25 | var testCases = []struct { |
| 26 | desc string |
| 27 | mkname string |
| 28 | in string |
| 29 | expected string |
| 30 | }{ |
| 31 | { |
| 32 | desc: "Comment", |
| 33 | mkname: "product.mk", |
| 34 | in: ` |
| 35 | # Comment |
| 36 | # FOO= a\ |
| 37 | b |
| 38 | `, |
| 39 | expected: `# Comment |
| 40 | # FOO= a |
| 41 | # b |
| 42 | load("//build/make/core:product_config.rbc", "rblf") |
| 43 | |
| 44 | def init(g, handle): |
| 45 | cfg = rblf.cfg(handle) |
| 46 | `, |
| 47 | }, |
| 48 | { |
| 49 | desc: "Name conversion", |
| 50 | mkname: "path/bar-baz.mk", |
| 51 | in: ` |
| 52 | # Comment |
| 53 | `, |
| 54 | expected: `# Comment |
| 55 | load("//build/make/core:product_config.rbc", "rblf") |
| 56 | |
| 57 | def init(g, handle): |
| 58 | cfg = rblf.cfg(handle) |
| 59 | `, |
| 60 | }, |
| 61 | { |
| 62 | desc: "Item variable", |
| 63 | mkname: "pixel3.mk", |
| 64 | in: ` |
| 65 | PRODUCT_NAME := Pixel 3 |
| 66 | PRODUCT_MODEL := |
| 67 | local_var = foo |
Cole Faust | 3c4fc99 | 2022-02-28 16:05:01 -0800 | [diff] [blame] | 68 | local-var-with-dashes := bar |
| 69 | $(warning local-var-with-dashes: $(local-var-with-dashes)) |
| 70 | GLOBAL-VAR-WITH-DASHES := baz |
| 71 | $(warning GLOBAL-VAR-WITH-DASHES: $(GLOBAL-VAR-WITH-DASHES)) |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 72 | `, |
| 73 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 74 | |
| 75 | def init(g, handle): |
| 76 | cfg = rblf.cfg(handle) |
| 77 | cfg["PRODUCT_NAME"] = "Pixel 3" |
| 78 | cfg["PRODUCT_MODEL"] = "" |
| 79 | _local_var = "foo" |
Cole Faust | 3c4fc99 | 2022-02-28 16:05:01 -0800 | [diff] [blame] | 80 | _local_var_with_dashes = "bar" |
| 81 | rblf.mkwarning("pixel3.mk", "local-var-with-dashes: %s" % _local_var_with_dashes) |
| 82 | g["GLOBAL-VAR-WITH-DASHES"] = "baz" |
| 83 | rblf.mkwarning("pixel3.mk", "GLOBAL-VAR-WITH-DASHES: %s" % g["GLOBAL-VAR-WITH-DASHES"]) |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 84 | `, |
| 85 | }, |
| 86 | { |
| 87 | desc: "List variable", |
| 88 | mkname: "pixel4.mk", |
| 89 | in: ` |
| 90 | PRODUCT_PACKAGES = package1 package2 |
| 91 | PRODUCT_COPY_FILES += file2:target |
| 92 | PRODUCT_PACKAGES += package3 |
| 93 | PRODUCT_COPY_FILES = |
| 94 | `, |
| 95 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 96 | |
| 97 | def init(g, handle): |
| 98 | cfg = rblf.cfg(handle) |
| 99 | cfg["PRODUCT_PACKAGES"] = [ |
| 100 | "package1", |
| 101 | "package2", |
| 102 | ] |
| 103 | rblf.setdefault(handle, "PRODUCT_COPY_FILES") |
| 104 | cfg["PRODUCT_COPY_FILES"] += ["file2:target"] |
| 105 | cfg["PRODUCT_PACKAGES"] += ["package3"] |
| 106 | cfg["PRODUCT_COPY_FILES"] = [] |
| 107 | `, |
| 108 | }, |
| 109 | { |
| 110 | desc: "Unknown function", |
| 111 | mkname: "product.mk", |
| 112 | in: ` |
Sasha Smundak | 6609ba7 | 2021-07-22 18:32:56 -0700 | [diff] [blame] | 113 | PRODUCT_NAME := $(call foo1, bar) |
| 114 | PRODUCT_NAME := $(call foo0) |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 115 | `, |
Sasha Smundak | 422b614 | 2021-11-11 18:31:59 -0800 | [diff] [blame] | 116 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 117 | |
| 118 | def init(g, handle): |
| 119 | cfg = rblf.cfg(handle) |
Cole Faust | 1e27586 | 2022-04-26 14:28:04 -0700 | [diff] [blame] | 120 | cfg["PRODUCT_NAME"] = rblf.mk2rbc_error("product.mk:2", "cannot handle invoking foo1") |
| 121 | cfg["PRODUCT_NAME"] = rblf.mk2rbc_error("product.mk:3", "cannot handle invoking foo0") |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 122 | `, |
| 123 | }, |
| 124 | { |
| 125 | desc: "Inherit configuration always", |
| 126 | mkname: "product.mk", |
| 127 | in: ` |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 128 | $(call inherit-product, part.mk) |
Sasha Smundak | 868c5e3 | 2021-09-23 16:20:58 -0700 | [diff] [blame] | 129 | ifdef PRODUCT_NAME |
| 130 | $(call inherit-product, part1.mk) |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 131 | else # Comment |
Sasha Smundak | 6bc132a | 2022-01-10 17:02:16 -0800 | [diff] [blame] | 132 | $(call inherit-product, $(LOCAL_PATH)/part.mk) |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 133 | endif |
| 134 | `, |
| 135 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 136 | load(":part.star", _part_init = "init") |
Sasha Smundak | 868c5e3 | 2021-09-23 16:20:58 -0700 | [diff] [blame] | 137 | load(":part1.star|init", _part1_init = "init") |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 138 | |
| 139 | def init(g, handle): |
| 140 | cfg = rblf.cfg(handle) |
Sasha Smundak | 868c5e3 | 2021-09-23 16:20:58 -0700 | [diff] [blame] | 141 | rblf.inherit(handle, "part", _part_init) |
Cole Faust | 71514c0 | 2022-01-27 17:21:41 -0800 | [diff] [blame] | 142 | if cfg.get("PRODUCT_NAME", ""): |
Sasha Smundak | 6bc132a | 2022-01-10 17:02:16 -0800 | [diff] [blame] | 143 | if not _part1_init: |
| 144 | rblf.mkerror("product.mk", "Cannot find %s" % (":part1.star")) |
Sasha Smundak | 868c5e3 | 2021-09-23 16:20:58 -0700 | [diff] [blame] | 145 | rblf.inherit(handle, "part1", _part1_init) |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 146 | else: |
| 147 | # Comment |
Sasha Smundak | 6bc132a | 2022-01-10 17:02:16 -0800 | [diff] [blame] | 148 | rblf.inherit(handle, "part", _part_init) |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 149 | `, |
| 150 | }, |
| 151 | { |
| 152 | desc: "Inherit configuration if it exists", |
| 153 | mkname: "product.mk", |
| 154 | in: ` |
| 155 | $(call inherit-product-if-exists, part.mk) |
| 156 | `, |
| 157 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 158 | load(":part.star|init", _part_init = "init") |
| 159 | |
| 160 | def init(g, handle): |
| 161 | cfg = rblf.cfg(handle) |
Sasha Smundak | 6609ba7 | 2021-07-22 18:32:56 -0700 | [diff] [blame] | 162 | if _part_init: |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 163 | rblf.inherit(handle, "part", _part_init) |
| 164 | `, |
| 165 | }, |
| 166 | |
| 167 | { |
| 168 | desc: "Include configuration", |
| 169 | mkname: "product.mk", |
| 170 | in: ` |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 171 | include part.mk |
Sasha Smundak | 868c5e3 | 2021-09-23 16:20:58 -0700 | [diff] [blame] | 172 | ifdef PRODUCT_NAME |
| 173 | include part1.mk |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 174 | else |
Sasha Smundak | 868c5e3 | 2021-09-23 16:20:58 -0700 | [diff] [blame] | 175 | -include $(LOCAL_PATH)/part1.mk) |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 176 | endif |
| 177 | `, |
| 178 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
Sasha Smundak | 868c5e3 | 2021-09-23 16:20:58 -0700 | [diff] [blame] | 179 | load(":part.star", _part_init = "init") |
| 180 | load(":part1.star|init", _part1_init = "init") |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 181 | |
| 182 | def init(g, handle): |
| 183 | cfg = rblf.cfg(handle) |
Sasha Smundak | 868c5e3 | 2021-09-23 16:20:58 -0700 | [diff] [blame] | 184 | _part_init(g, handle) |
Cole Faust | 71514c0 | 2022-01-27 17:21:41 -0800 | [diff] [blame] | 185 | if cfg.get("PRODUCT_NAME", ""): |
Sasha Smundak | 6bc132a | 2022-01-10 17:02:16 -0800 | [diff] [blame] | 186 | if not _part1_init: |
| 187 | rblf.mkerror("product.mk", "Cannot find %s" % (":part1.star")) |
Sasha Smundak | 868c5e3 | 2021-09-23 16:20:58 -0700 | [diff] [blame] | 188 | _part1_init(g, handle) |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 189 | else: |
Sasha Smundak | 868c5e3 | 2021-09-23 16:20:58 -0700 | [diff] [blame] | 190 | if _part1_init != None: |
| 191 | _part1_init(g, handle) |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 192 | `, |
| 193 | }, |
| 194 | |
| 195 | { |
| 196 | desc: "Synonymous inherited configurations", |
| 197 | mkname: "path/product.mk", |
| 198 | in: ` |
Sasha Smundak | 6609ba7 | 2021-07-22 18:32:56 -0700 | [diff] [blame] | 199 | $(call inherit-product, */font.mk) |
Cole Faust | 62e0511 | 2022-04-05 17:56:11 -0700 | [diff] [blame] | 200 | $(call inherit-product, $(sort $(wildcard */font.mk))) |
| 201 | $(call inherit-product, $(wildcard */font.mk)) |
| 202 | |
| 203 | include */font.mk |
| 204 | include $(sort $(wildcard */font.mk)) |
| 205 | include $(wildcard */font.mk) |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 206 | `, |
| 207 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
Cole Faust | 62e0511 | 2022-04-05 17:56:11 -0700 | [diff] [blame] | 208 | load("//bar:font.star", _font_init = "init") |
| 209 | load("//foo:font.star", _font1_init = "init") |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 210 | |
| 211 | def init(g, handle): |
| 212 | cfg = rblf.cfg(handle) |
Cole Faust | 62e0511 | 2022-04-05 17:56:11 -0700 | [diff] [blame] | 213 | rblf.inherit(handle, "bar/font", _font_init) |
| 214 | rblf.inherit(handle, "foo/font", _font1_init) |
| 215 | rblf.inherit(handle, "bar/font", _font_init) |
| 216 | rblf.inherit(handle, "foo/font", _font1_init) |
| 217 | rblf.inherit(handle, "bar/font", _font_init) |
| 218 | rblf.inherit(handle, "foo/font", _font1_init) |
| 219 | _font_init(g, handle) |
| 220 | _font1_init(g, handle) |
| 221 | _font_init(g, handle) |
| 222 | _font1_init(g, handle) |
| 223 | _font_init(g, handle) |
| 224 | _font1_init(g, handle) |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 225 | `, |
| 226 | }, |
| 227 | { |
| 228 | desc: "Directive define", |
| 229 | mkname: "product.mk", |
| 230 | in: ` |
| 231 | define some-macro |
| 232 | $(info foo) |
| 233 | endef |
| 234 | `, |
Sasha Smundak | 422b614 | 2021-11-11 18:31:59 -0800 | [diff] [blame] | 235 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 236 | |
| 237 | def init(g, handle): |
| 238 | cfg = rblf.cfg(handle) |
Sasha Smundak | 422b614 | 2021-11-11 18:31:59 -0800 | [diff] [blame] | 239 | rblf.mk2rbc_error("product.mk:2", "define is not supported: some-macro") |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 240 | `, |
| 241 | }, |
| 242 | { |
| 243 | desc: "Ifdef", |
| 244 | mkname: "product.mk", |
| 245 | in: ` |
| 246 | ifdef PRODUCT_NAME |
| 247 | PRODUCT_NAME = gizmo |
| 248 | else |
| 249 | endif |
Sasha Smundak | c4fa93e | 2021-11-05 14:38:46 -0700 | [diff] [blame] | 250 | local_var := |
| 251 | ifdef local_var |
| 252 | endif |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 253 | `, |
| 254 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 255 | |
| 256 | def init(g, handle): |
| 257 | cfg = rblf.cfg(handle) |
Cole Faust | 71514c0 | 2022-01-27 17:21:41 -0800 | [diff] [blame] | 258 | if cfg.get("PRODUCT_NAME", ""): |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 259 | cfg["PRODUCT_NAME"] = "gizmo" |
| 260 | else: |
| 261 | pass |
Sasha Smundak | c4fa93e | 2021-11-05 14:38:46 -0700 | [diff] [blame] | 262 | _local_var = "" |
| 263 | if _local_var: |
| 264 | pass |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 265 | `, |
| 266 | }, |
| 267 | { |
| 268 | desc: "Simple functions", |
| 269 | mkname: "product.mk", |
| 270 | in: ` |
| 271 | $(warning this is the warning) |
| 272 | $(warning) |
Cole Faust | e309a91 | 2022-03-16 13:42:34 -0700 | [diff] [blame] | 273 | $(warning # this warning starts with a pound) |
| 274 | $(warning this warning has a # in the middle) |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 275 | $(info this is the info) |
| 276 | $(error this is the error) |
| 277 | PRODUCT_NAME:=$(shell echo *) |
| 278 | `, |
| 279 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 280 | |
| 281 | def init(g, handle): |
| 282 | cfg = rblf.cfg(handle) |
| 283 | rblf.mkwarning("product.mk", "this is the warning") |
| 284 | rblf.mkwarning("product.mk", "") |
Cole Faust | e309a91 | 2022-03-16 13:42:34 -0700 | [diff] [blame] | 285 | rblf.mkwarning("product.mk", "# this warning starts with a pound") |
| 286 | rblf.mkwarning("product.mk", "this warning has a # in the middle") |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 287 | rblf.mkinfo("product.mk", "this is the info") |
| 288 | rblf.mkerror("product.mk", "this is the error") |
| 289 | cfg["PRODUCT_NAME"] = rblf.shell("echo *") |
| 290 | `, |
| 291 | }, |
| 292 | { |
| 293 | desc: "Empty if", |
| 294 | mkname: "product.mk", |
| 295 | in: ` |
| 296 | ifdef PRODUCT_NAME |
| 297 | # Comment |
Sasha Smundak | 6609ba7 | 2021-07-22 18:32:56 -0700 | [diff] [blame] | 298 | else |
Sasha Smundak | 02183cf | 2021-08-16 13:36:11 -0700 | [diff] [blame] | 299 | TARGET_COPY_OUT_RECOVERY := foo |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 300 | endif |
| 301 | `, |
| 302 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 303 | |
| 304 | def init(g, handle): |
| 305 | cfg = rblf.cfg(handle) |
Cole Faust | 71514c0 | 2022-01-27 17:21:41 -0800 | [diff] [blame] | 306 | if cfg.get("PRODUCT_NAME", ""): |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 307 | # Comment |
| 308 | pass |
Sasha Smundak | 6609ba7 | 2021-07-22 18:32:56 -0700 | [diff] [blame] | 309 | else: |
Sasha Smundak | 422b614 | 2021-11-11 18:31:59 -0800 | [diff] [blame] | 310 | rblf.mk2rbc_error("product.mk:5", "cannot set predefined variable TARGET_COPY_OUT_RECOVERY to \"foo\", its value should be \"recovery\"") |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 311 | `, |
| 312 | }, |
| 313 | { |
| 314 | desc: "if/else/endif", |
| 315 | mkname: "product.mk", |
| 316 | in: ` |
| 317 | ifndef PRODUCT_NAME |
| 318 | PRODUCT_NAME=gizmo1 |
| 319 | else |
| 320 | PRODUCT_NAME=gizmo2 |
| 321 | endif |
| 322 | `, |
| 323 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 324 | |
| 325 | def init(g, handle): |
| 326 | cfg = rblf.cfg(handle) |
Cole Faust | 71514c0 | 2022-01-27 17:21:41 -0800 | [diff] [blame] | 327 | if not cfg.get("PRODUCT_NAME", ""): |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 328 | cfg["PRODUCT_NAME"] = "gizmo1" |
| 329 | else: |
| 330 | cfg["PRODUCT_NAME"] = "gizmo2" |
| 331 | `, |
| 332 | }, |
| 333 | { |
| 334 | desc: "else if", |
| 335 | mkname: "product.mk", |
| 336 | in: ` |
| 337 | ifdef PRODUCT_NAME |
| 338 | PRODUCT_NAME = gizmo |
| 339 | else ifndef PRODUCT_PACKAGES # Comment |
| 340 | endif |
| 341 | `, |
| 342 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 343 | |
| 344 | def init(g, handle): |
| 345 | cfg = rblf.cfg(handle) |
Cole Faust | 71514c0 | 2022-01-27 17:21:41 -0800 | [diff] [blame] | 346 | if cfg.get("PRODUCT_NAME", ""): |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 347 | cfg["PRODUCT_NAME"] = "gizmo" |
Cole Faust | 71514c0 | 2022-01-27 17:21:41 -0800 | [diff] [blame] | 348 | elif not cfg.get("PRODUCT_PACKAGES", []): |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 349 | # Comment |
| 350 | pass |
| 351 | `, |
| 352 | }, |
| 353 | { |
| 354 | desc: "ifeq / ifneq", |
| 355 | mkname: "product.mk", |
| 356 | in: ` |
| 357 | ifeq (aosp_arm, $(TARGET_PRODUCT)) |
| 358 | PRODUCT_MODEL = pix2 |
| 359 | else |
| 360 | PRODUCT_MODEL = pix21 |
| 361 | endif |
| 362 | ifneq (aosp_x86, $(TARGET_PRODUCT)) |
| 363 | PRODUCT_MODEL = pix3 |
| 364 | endif |
| 365 | `, |
| 366 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 367 | |
| 368 | def init(g, handle): |
| 369 | cfg = rblf.cfg(handle) |
| 370 | if "aosp_arm" == g["TARGET_PRODUCT"]: |
| 371 | cfg["PRODUCT_MODEL"] = "pix2" |
| 372 | else: |
| 373 | cfg["PRODUCT_MODEL"] = "pix21" |
| 374 | if "aosp_x86" != g["TARGET_PRODUCT"]: |
| 375 | cfg["PRODUCT_MODEL"] = "pix3" |
| 376 | `, |
| 377 | }, |
| 378 | { |
Cole Faust | f832021 | 2021-11-10 15:05:07 -0800 | [diff] [blame] | 379 | desc: "ifeq with soong_config_get", |
| 380 | mkname: "product.mk", |
| 381 | in: ` |
| 382 | ifeq (true,$(call soong_config_get,art_module,source_build)) |
| 383 | endif |
| 384 | `, |
| 385 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 386 | |
| 387 | def init(g, handle): |
| 388 | cfg = rblf.cfg(handle) |
| 389 | if "true" == rblf.soong_config_get(g, "art_module", "source_build"): |
| 390 | pass |
| 391 | `, |
| 392 | }, |
| 393 | { |
Cole Faust | f1f44d3 | 2021-11-16 14:52:12 -0800 | [diff] [blame] | 394 | desc: "ifeq with $(NATIVE_COVERAGE)", |
| 395 | mkname: "product.mk", |
| 396 | in: ` |
| 397 | ifeq ($(NATIVE_COVERAGE),true) |
| 398 | endif |
| 399 | `, |
| 400 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 401 | |
| 402 | def init(g, handle): |
| 403 | cfg = rblf.cfg(handle) |
| 404 | if g.get("NATIVE_COVERAGE", False): |
| 405 | pass |
| 406 | `, |
| 407 | }, |
| 408 | { |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 409 | desc: "Check filter result", |
| 410 | mkname: "product.mk", |
| 411 | in: ` |
| 412 | ifeq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT))) |
| 413 | endif |
| 414 | ifneq (,$(filter userdebug,$(TARGET_BUILD_VARIANT)) |
| 415 | endif |
| 416 | ifneq (,$(filter plaf,$(PLATFORM_LIST))) |
| 417 | endif |
| 418 | ifeq ($(TARGET_BUILD_VARIANT), $(filter $(TARGET_BUILD_VARIANT), userdebug eng)) |
| 419 | endif |
Cole Faust | 9932f75 | 2022-02-08 11:56:25 -0800 | [diff] [blame] | 420 | ifneq (, $(filter $(TARGET_BUILD_VARIANT), userdebug eng)) |
| 421 | endif |
| 422 | ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT))) |
| 423 | endif |
Sasha Smundak | 0554d76 | 2021-07-08 18:26:12 -0700 | [diff] [blame] | 424 | ifneq (,$(filter true, $(v1)$(v2))) |
| 425 | endif |
Sasha Smundak | 5f463be | 2021-09-15 18:43:36 -0700 | [diff] [blame] | 426 | ifeq (,$(filter barbet coral%,$(TARGET_PRODUCT))) |
| 427 | else ifneq (,$(filter barbet%,$(TARGET_PRODUCT))) |
| 428 | endif |
Cole Faust | eec0d81 | 2021-12-06 16:23:51 -0800 | [diff] [blame] | 429 | ifeq (,$(filter-out sunfish_kasan, $(TARGET_PRODUCT))) |
| 430 | endif |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 431 | `, |
| 432 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 433 | |
| 434 | def init(g, handle): |
| 435 | cfg = rblf.cfg(handle) |
Sasha Smundak | 5f463be | 2021-09-15 18:43:36 -0700 | [diff] [blame] | 436 | if not rblf.filter("userdebug eng", g["TARGET_BUILD_VARIANT"]): |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 437 | pass |
Sasha Smundak | 5f463be | 2021-09-15 18:43:36 -0700 | [diff] [blame] | 438 | if rblf.filter("userdebug", g["TARGET_BUILD_VARIANT"]): |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 439 | pass |
| 440 | if "plaf" in g.get("PLATFORM_LIST", []): |
| 441 | pass |
Cole Faust | 9932f75 | 2022-02-08 11:56:25 -0800 | [diff] [blame] | 442 | if g["TARGET_BUILD_VARIANT"] == " ".join(rblf.filter(g["TARGET_BUILD_VARIANT"], "userdebug eng")): |
| 443 | pass |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 444 | if g["TARGET_BUILD_VARIANT"] in ["userdebug", "eng"]: |
| 445 | pass |
Cole Faust | 9932f75 | 2022-02-08 11:56:25 -0800 | [diff] [blame] | 446 | if rblf.filter("userdebug eng", g["TARGET_BUILD_VARIANT"]): |
| 447 | pass |
Sasha Smundak | 5f463be | 2021-09-15 18:43:36 -0700 | [diff] [blame] | 448 | if rblf.filter("true", "%s%s" % (_v1, _v2)): |
| 449 | pass |
| 450 | if not rblf.filter("barbet coral%", g["TARGET_PRODUCT"]): |
| 451 | pass |
| 452 | elif rblf.filter("barbet%", g["TARGET_PRODUCT"]): |
Sasha Smundak | 0554d76 | 2021-07-08 18:26:12 -0700 | [diff] [blame] | 453 | pass |
Cole Faust | eec0d81 | 2021-12-06 16:23:51 -0800 | [diff] [blame] | 454 | if not rblf.filter_out("sunfish_kasan", g["TARGET_PRODUCT"]): |
| 455 | pass |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 456 | `, |
| 457 | }, |
| 458 | { |
| 459 | desc: "Get filter result", |
| 460 | mkname: "product.mk", |
| 461 | in: ` |
| 462 | PRODUCT_LIST2=$(filter-out %/foo.ko,$(wildcard path/*.ko)) |
| 463 | `, |
| 464 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 465 | |
| 466 | def init(g, handle): |
| 467 | cfg = rblf.cfg(handle) |
| 468 | cfg["PRODUCT_LIST2"] = rblf.filter_out("%/foo.ko", rblf.expand_wildcard("path/*.ko")) |
| 469 | `, |
| 470 | }, |
| 471 | { |
| 472 | desc: "filter $(VAR), values", |
| 473 | mkname: "product.mk", |
| 474 | in: ` |
| 475 | ifeq (,$(filter $(TARGET_PRODUCT), yukawa_gms yukawa_sei510_gms) |
| 476 | ifneq (,$(filter $(TARGET_PRODUCT), yukawa_gms) |
| 477 | endif |
| 478 | endif |
| 479 | |
| 480 | `, |
| 481 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 482 | |
| 483 | def init(g, handle): |
| 484 | cfg = rblf.cfg(handle) |
| 485 | if g["TARGET_PRODUCT"] not in ["yukawa_gms", "yukawa_sei510_gms"]: |
Sasha Smundak | 0554d76 | 2021-07-08 18:26:12 -0700 | [diff] [blame] | 486 | if g["TARGET_PRODUCT"] == "yukawa_gms": |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 487 | pass |
| 488 | `, |
| 489 | }, |
| 490 | { |
Sasha Smundak | 0554d76 | 2021-07-08 18:26:12 -0700 | [diff] [blame] | 491 | desc: "filter $(V1), $(V2)", |
| 492 | mkname: "product.mk", |
| 493 | in: ` |
| 494 | ifneq (, $(filter $(PRODUCT_LIST), $(TARGET_PRODUCT))) |
| 495 | endif |
| 496 | `, |
| 497 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 498 | |
| 499 | def init(g, handle): |
| 500 | cfg = rblf.cfg(handle) |
Sasha Smundak | 468e11f | 2021-08-26 09:10:23 -0700 | [diff] [blame] | 501 | if rblf.filter(g.get("PRODUCT_LIST", []), g["TARGET_PRODUCT"]): |
Sasha Smundak | 0554d76 | 2021-07-08 18:26:12 -0700 | [diff] [blame] | 502 | pass |
| 503 | `, |
| 504 | }, |
| 505 | { |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 506 | desc: "ifeq", |
| 507 | mkname: "product.mk", |
| 508 | in: ` |
| 509 | ifeq (aosp, $(TARGET_PRODUCT)) # Comment |
| 510 | else ifneq (, $(TARGET_PRODUCT)) |
| 511 | endif |
| 512 | `, |
| 513 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 514 | |
| 515 | def init(g, handle): |
| 516 | cfg = rblf.cfg(handle) |
| 517 | if "aosp" == g["TARGET_PRODUCT"]: |
| 518 | # Comment |
| 519 | pass |
| 520 | elif g["TARGET_PRODUCT"]: |
| 521 | pass |
| 522 | `, |
| 523 | }, |
| 524 | { |
| 525 | desc: "Nested if", |
| 526 | mkname: "product.mk", |
| 527 | in: ` |
| 528 | ifdef PRODUCT_NAME |
| 529 | PRODUCT_PACKAGES = pack-if0 |
| 530 | ifdef PRODUCT_MODEL |
| 531 | PRODUCT_PACKAGES = pack-if-if |
| 532 | else ifdef PRODUCT_NAME |
| 533 | PRODUCT_PACKAGES = pack-if-elif |
| 534 | else |
| 535 | PRODUCT_PACKAGES = pack-if-else |
| 536 | endif |
| 537 | PRODUCT_PACKAGES = pack-if |
| 538 | else ifneq (,$(TARGET_PRODUCT)) |
| 539 | PRODUCT_PACKAGES = pack-elif |
| 540 | else |
| 541 | PRODUCT_PACKAGES = pack-else |
| 542 | endif |
| 543 | `, |
| 544 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 545 | |
| 546 | def init(g, handle): |
| 547 | cfg = rblf.cfg(handle) |
Cole Faust | 71514c0 | 2022-01-27 17:21:41 -0800 | [diff] [blame] | 548 | if cfg.get("PRODUCT_NAME", ""): |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 549 | cfg["PRODUCT_PACKAGES"] = ["pack-if0"] |
Cole Faust | 71514c0 | 2022-01-27 17:21:41 -0800 | [diff] [blame] | 550 | if cfg.get("PRODUCT_MODEL", ""): |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 551 | cfg["PRODUCT_PACKAGES"] = ["pack-if-if"] |
Cole Faust | 71514c0 | 2022-01-27 17:21:41 -0800 | [diff] [blame] | 552 | elif cfg.get("PRODUCT_NAME", ""): |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 553 | cfg["PRODUCT_PACKAGES"] = ["pack-if-elif"] |
| 554 | else: |
| 555 | cfg["PRODUCT_PACKAGES"] = ["pack-if-else"] |
| 556 | cfg["PRODUCT_PACKAGES"] = ["pack-if"] |
| 557 | elif g["TARGET_PRODUCT"]: |
| 558 | cfg["PRODUCT_PACKAGES"] = ["pack-elif"] |
| 559 | else: |
| 560 | cfg["PRODUCT_PACKAGES"] = ["pack-else"] |
| 561 | `, |
| 562 | }, |
| 563 | { |
| 564 | desc: "Wildcard", |
| 565 | mkname: "product.mk", |
| 566 | in: ` |
| 567 | ifeq (,$(wildcard foo.mk)) |
| 568 | endif |
| 569 | ifneq (,$(wildcard foo*.mk)) |
| 570 | endif |
Cole Faust | a99afdf | 2022-04-26 12:06:49 -0700 | [diff] [blame] | 571 | ifeq (foo1.mk foo2.mk barxyz.mk,$(wildcard foo*.mk bar*.mk)) |
| 572 | endif |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 573 | `, |
| 574 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 575 | |
| 576 | def init(g, handle): |
| 577 | cfg = rblf.cfg(handle) |
Cole Faust | a99afdf | 2022-04-26 12:06:49 -0700 | [diff] [blame] | 578 | if not rblf.expand_wildcard("foo.mk"): |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 579 | pass |
Cole Faust | a99afdf | 2022-04-26 12:06:49 -0700 | [diff] [blame] | 580 | if rblf.expand_wildcard("foo*.mk"): |
| 581 | pass |
Cole Faust | 72374fc | 2022-05-05 11:45:04 -0700 | [diff] [blame] | 582 | if rblf.expand_wildcard("foo*.mk bar*.mk") == ["foo1.mk", "foo2.mk", "barxyz.mk"]: |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 583 | pass |
| 584 | `, |
| 585 | }, |
| 586 | { |
Cole Faust | f832021 | 2021-11-10 15:05:07 -0800 | [diff] [blame] | 587 | desc: "if with interpolation", |
| 588 | mkname: "product.mk", |
| 589 | in: ` |
| 590 | ifeq ($(VARIABLE1)text$(VARIABLE2),true) |
| 591 | endif |
| 592 | `, |
| 593 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 594 | |
| 595 | def init(g, handle): |
| 596 | cfg = rblf.cfg(handle) |
| 597 | if "%stext%s" % (g.get("VARIABLE1", ""), g.get("VARIABLE2", "")) == "true": |
| 598 | pass |
| 599 | `, |
| 600 | }, |
| 601 | { |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 602 | desc: "ifneq $(X),true", |
| 603 | mkname: "product.mk", |
| 604 | in: ` |
| 605 | ifneq ($(VARIABLE),true) |
| 606 | endif |
| 607 | `, |
| 608 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 609 | |
| 610 | def init(g, handle): |
| 611 | cfg = rblf.cfg(handle) |
| 612 | if g.get("VARIABLE", "") != "true": |
| 613 | pass |
| 614 | `, |
| 615 | }, |
| 616 | { |
| 617 | desc: "Const neq", |
| 618 | mkname: "product.mk", |
| 619 | in: ` |
| 620 | ifneq (1,0) |
| 621 | endif |
| 622 | `, |
| 623 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 624 | |
| 625 | def init(g, handle): |
| 626 | cfg = rblf.cfg(handle) |
| 627 | if "1" != "0": |
| 628 | pass |
| 629 | `, |
| 630 | }, |
| 631 | { |
| 632 | desc: "is-board calls", |
| 633 | mkname: "product.mk", |
| 634 | in: ` |
| 635 | ifeq ($(call is-board-platform-in-list,msm8998), true) |
| 636 | else ifneq ($(call is-board-platform,copper),true) |
| 637 | else ifneq ($(call is-vendor-board-platform,QCOM),true) |
| 638 | else ifeq ($(call is-product-in-list, $(PLATFORM_LIST)), true) |
| 639 | endif |
| 640 | `, |
| 641 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 642 | |
| 643 | def init(g, handle): |
| 644 | cfg = rblf.cfg(handle) |
Cole Faust | b2e0b60 | 2022-01-07 15:46:58 -0800 | [diff] [blame] | 645 | if rblf.board_platform_in(g, "msm8998"): |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 646 | pass |
Cole Faust | b2e0b60 | 2022-01-07 15:46:58 -0800 | [diff] [blame] | 647 | elif not rblf.board_platform_is(g, "copper"): |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 648 | pass |
Cole Faust | f063266 | 2022-04-07 13:59:24 -0700 | [diff] [blame] | 649 | elif g.get("TARGET_BOARD_PLATFORM", "") not in g.get("QCOM_BOARD_PLATFORMS", ""): |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 650 | pass |
| 651 | elif g["TARGET_PRODUCT"] in g.get("PLATFORM_LIST", []): |
| 652 | pass |
| 653 | `, |
| 654 | }, |
| 655 | { |
Sasha Smundak | 3a9b8e8 | 2021-08-25 14:11:04 -0700 | [diff] [blame] | 656 | desc: "new is-board calls", |
| 657 | mkname: "product.mk", |
| 658 | in: ` |
| 659 | ifneq (,$(call is-board-platform-in-list2,msm8998 $(X)) |
| 660 | else ifeq (,$(call is-board-platform2,copper) |
| 661 | else ifneq (,$(call is-vendor-board-qcom)) |
| 662 | endif |
| 663 | `, |
| 664 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 665 | |
| 666 | def init(g, handle): |
| 667 | cfg = rblf.cfg(handle) |
| 668 | if rblf.board_platform_in(g, "msm8998 %s" % g.get("X", "")): |
| 669 | pass |
| 670 | elif not rblf.board_platform_is(g, "copper"): |
| 671 | pass |
Cole Faust | f063266 | 2022-04-07 13:59:24 -0700 | [diff] [blame] | 672 | elif g.get("TARGET_BOARD_PLATFORM", "") in g.get("QCOM_BOARD_PLATFORMS", ""): |
Sasha Smundak | 3a9b8e8 | 2021-08-25 14:11:04 -0700 | [diff] [blame] | 673 | pass |
| 674 | `, |
| 675 | }, |
| 676 | { |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 677 | desc: "findstring call", |
| 678 | mkname: "product.mk", |
| 679 | in: ` |
Cole Faust | 0e9418c | 2021-12-13 16:33:25 -0800 | [diff] [blame] | 680 | result := $(findstring a,a b c) |
| 681 | result := $(findstring b,x y z) |
| 682 | `, |
| 683 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 684 | |
| 685 | def init(g, handle): |
| 686 | cfg = rblf.cfg(handle) |
| 687 | _result = rblf.findstring("a", "a b c") |
| 688 | _result = rblf.findstring("b", "x y z") |
| 689 | `, |
| 690 | }, |
| 691 | { |
| 692 | desc: "findstring in if statement", |
| 693 | mkname: "product.mk", |
| 694 | in: ` |
| 695 | ifeq ($(findstring foo,$(PRODUCT_PACKAGES)),) |
| 696 | endif |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 697 | ifneq ($(findstring foo,$(PRODUCT_PACKAGES)),) |
| 698 | endif |
Cole Faust | 0e9418c | 2021-12-13 16:33:25 -0800 | [diff] [blame] | 699 | ifeq ($(findstring foo,$(PRODUCT_PACKAGES)),foo) |
| 700 | endif |
| 701 | ifneq ($(findstring foo,$(PRODUCT_PACKAGES)),foo) |
| 702 | endif |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 703 | `, |
| 704 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 705 | |
| 706 | def init(g, handle): |
| 707 | cfg = rblf.cfg(handle) |
Cole Faust | 0e9418c | 2021-12-13 16:33:25 -0800 | [diff] [blame] | 708 | if (cfg.get("PRODUCT_PACKAGES", [])).find("foo") == -1: |
| 709 | pass |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 710 | if (cfg.get("PRODUCT_PACKAGES", [])).find("foo") != -1: |
| 711 | pass |
Cole Faust | 0e9418c | 2021-12-13 16:33:25 -0800 | [diff] [blame] | 712 | if (cfg.get("PRODUCT_PACKAGES", [])).find("foo") != -1: |
| 713 | pass |
| 714 | if (cfg.get("PRODUCT_PACKAGES", [])).find("foo") == -1: |
| 715 | pass |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 716 | `, |
| 717 | }, |
| 718 | { |
| 719 | desc: "rhs call", |
| 720 | mkname: "product.mk", |
| 721 | in: ` |
| 722 | PRODUCT_COPY_FILES = $(call add-to-product-copy-files-if-exists, path:distpath) \ |
| 723 | $(call find-copy-subdir-files, *, fromdir, todir) $(wildcard foo.*) |
| 724 | `, |
| 725 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 726 | |
| 727 | def init(g, handle): |
| 728 | cfg = rblf.cfg(handle) |
| 729 | cfg["PRODUCT_COPY_FILES"] = (rblf.copy_if_exists("path:distpath") + |
| 730 | rblf.find_and_copy("*", "fromdir", "todir") + |
| 731 | rblf.expand_wildcard("foo.*")) |
| 732 | `, |
| 733 | }, |
| 734 | { |
| 735 | desc: "inferred type", |
| 736 | mkname: "product.mk", |
| 737 | in: ` |
| 738 | HIKEY_MODS := $(wildcard foo/*.ko) |
| 739 | BOARD_VENDOR_KERNEL_MODULES += $(HIKEY_MODS) |
| 740 | `, |
| 741 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 742 | |
| 743 | def init(g, handle): |
| 744 | cfg = rblf.cfg(handle) |
| 745 | g["HIKEY_MODS"] = rblf.expand_wildcard("foo/*.ko") |
| 746 | g.setdefault("BOARD_VENDOR_KERNEL_MODULES", []) |
| 747 | g["BOARD_VENDOR_KERNEL_MODULES"] += g["HIKEY_MODS"] |
| 748 | `, |
| 749 | }, |
| 750 | { |
| 751 | desc: "list with vars", |
| 752 | mkname: "product.mk", |
| 753 | in: ` |
| 754 | PRODUCT_COPY_FILES += path1:$(TARGET_PRODUCT)/path1 $(PRODUCT_MODEL)/path2:$(TARGET_PRODUCT)/path2 |
| 755 | `, |
| 756 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 757 | |
| 758 | def init(g, handle): |
| 759 | cfg = rblf.cfg(handle) |
| 760 | rblf.setdefault(handle, "PRODUCT_COPY_FILES") |
| 761 | cfg["PRODUCT_COPY_FILES"] += (("path1:%s/path1" % g["TARGET_PRODUCT"]).split() + |
| 762 | ("%s/path2:%s/path2" % (cfg.get("PRODUCT_MODEL", ""), g["TARGET_PRODUCT"])).split()) |
| 763 | `, |
| 764 | }, |
| 765 | { |
| 766 | desc: "misc calls", |
| 767 | mkname: "product.mk", |
| 768 | in: ` |
| 769 | $(call enforce-product-packages-exist,) |
| 770 | $(call enforce-product-packages-exist, foo) |
| 771 | $(call require-artifacts-in-path, foo, bar) |
| 772 | $(call require-artifacts-in-path-relaxed, foo, bar) |
Sasha Smundak | d679785 | 2021-11-15 13:01:53 -0800 | [diff] [blame] | 773 | $(call dist-for-goals, goal, from:to) |
Cole Faust | 1cc0885 | 2022-02-28 11:12:08 -0800 | [diff] [blame] | 774 | $(call add-product-dex-preopt-module-config,MyModule,disable) |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 775 | `, |
| 776 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 777 | |
| 778 | def init(g, handle): |
| 779 | cfg = rblf.cfg(handle) |
Cole Faust | 6c41b8a | 2022-04-13 13:53:48 -0700 | [diff] [blame] | 780 | rblf.enforce_product_packages_exist(handle, "") |
| 781 | rblf.enforce_product_packages_exist(handle, "foo") |
Cole Faust | ea9db58 | 2022-03-21 17:50:05 -0700 | [diff] [blame] | 782 | rblf.require_artifacts_in_path(handle, "foo", "bar") |
| 783 | rblf.require_artifacts_in_path_relaxed(handle, "foo", "bar") |
Sasha Smundak | d679785 | 2021-11-15 13:01:53 -0800 | [diff] [blame] | 784 | rblf.mkdist_for_goals(g, "goal", "from:to") |
Cole Faust | 1cc0885 | 2022-02-28 11:12:08 -0800 | [diff] [blame] | 785 | rblf.add_product_dex_preopt_module_config(handle, "MyModule", "disable") |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 786 | `, |
| 787 | }, |
| 788 | { |
| 789 | desc: "list with functions", |
| 790 | mkname: "product.mk", |
| 791 | in: ` |
| 792 | PRODUCT_COPY_FILES := $(call find-copy-subdir-files,*.kl,from1,to1) \ |
| 793 | $(call find-copy-subdir-files,*.kc,from2,to2) \ |
| 794 | foo bar |
| 795 | `, |
| 796 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 797 | |
| 798 | def init(g, handle): |
| 799 | cfg = rblf.cfg(handle) |
| 800 | cfg["PRODUCT_COPY_FILES"] = (rblf.find_and_copy("*.kl", "from1", "to1") + |
| 801 | rblf.find_and_copy("*.kc", "from2", "to2") + |
| 802 | [ |
| 803 | "foo", |
| 804 | "bar", |
| 805 | ]) |
| 806 | `, |
| 807 | }, |
| 808 | { |
| 809 | desc: "Text functions", |
| 810 | mkname: "product.mk", |
| 811 | in: ` |
| 812 | PRODUCT_COPY_FILES := $(addprefix pfx-,a b c) |
| 813 | PRODUCT_COPY_FILES := $(addsuffix .sff, a b c) |
| 814 | PRODUCT_NAME := $(word 1, $(subst ., ,$(TARGET_BOARD_PLATFORM))) |
Cole Faust | 94c4a9a | 2022-04-22 17:43:52 -0700 | [diff] [blame] | 815 | ifeq (1,$(words $(SOME_UNKNOWN_VARIABLE))) |
| 816 | endif |
| 817 | ifeq ($(words $(SOME_OTHER_VARIABLE)),$(SOME_INT_VARIABLE)) |
| 818 | endif |
Sasha Smundak | 35434ed | 2021-11-05 16:29:56 -0700 | [diff] [blame] | 819 | $(info $(patsubst %.pub,$(PRODUCT_NAME)%,$(PRODUCT_ADB_KEYS))) |
Cole Faust | 0e2b256 | 2022-04-01 11:46:50 -0700 | [diff] [blame] | 820 | $(info $$(dir foo/bar): $(dir foo/bar)) |
Sasha Smundak | 16e0773 | 2021-07-23 11:38:23 -0700 | [diff] [blame] | 821 | $(info $(firstword $(PRODUCT_COPY_FILES))) |
| 822 | $(info $(lastword $(PRODUCT_COPY_FILES))) |
| 823 | $(info $(dir $(lastword $(MAKEFILE_LIST)))) |
| 824 | $(info $(dir $(lastword $(PRODUCT_COPY_FILES)))) |
| 825 | $(info $(dir $(lastword $(foobar)))) |
| 826 | $(info $(abspath foo/bar)) |
| 827 | $(info $(notdir foo/bar)) |
Sasha Smundak | 3deb968 | 2021-07-26 18:42:25 -0700 | [diff] [blame] | 828 | $(call add_soong_config_namespace,snsconfig) |
| 829 | $(call add_soong_config_var_value,snsconfig,imagetype,odm_image) |
Sasha Smundak | 65b547e | 2021-09-17 15:35:41 -0700 | [diff] [blame] | 830 | $(call soong_config_set, snsconfig, foo, foo_value) |
| 831 | $(call soong_config_append, snsconfig, bar, bar_value) |
Sasha Smundak | 3deb968 | 2021-07-26 18:42:25 -0700 | [diff] [blame] | 832 | PRODUCT_COPY_FILES := $(call copy-files,$(wildcard foo*.mk),etc) |
Sasha Smundak | 0445308 | 2021-08-17 18:14:41 -0700 | [diff] [blame] | 833 | PRODUCT_COPY_FILES := $(call product-copy-files-by-pattern,from/%,to/%,a b c) |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 834 | `, |
| 835 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 836 | |
| 837 | def init(g, handle): |
| 838 | cfg = rblf.cfg(handle) |
| 839 | cfg["PRODUCT_COPY_FILES"] = rblf.addprefix("pfx-", "a b c") |
| 840 | cfg["PRODUCT_COPY_FILES"] = rblf.addsuffix(".sff", "a b c") |
Cole Faust | 94c4a9a | 2022-04-22 17:43:52 -0700 | [diff] [blame] | 841 | cfg["PRODUCT_NAME"] = rblf.words((g.get("TARGET_BOARD_PLATFORM", "")).replace(".", " "))[0] |
| 842 | if len(rblf.words(g.get("SOME_UNKNOWN_VARIABLE", ""))) == 1: |
| 843 | pass |
| 844 | if ("%d" % (len(rblf.words(g.get("SOME_OTHER_VARIABLE", ""))))) == g.get("SOME_INT_VARIABLE", ""): |
| 845 | pass |
Sasha Smundak | 35434ed | 2021-11-05 16:29:56 -0700 | [diff] [blame] | 846 | rblf.mkinfo("product.mk", rblf.mkpatsubst("%.pub", "%s%%" % cfg["PRODUCT_NAME"], g.get("PRODUCT_ADB_KEYS", ""))) |
Cole Faust | 0e2b256 | 2022-04-01 11:46:50 -0700 | [diff] [blame] | 847 | rblf.mkinfo("product.mk", "$(dir foo/bar): %s" % rblf.dir("foo/bar")) |
Cole Faust | 5a13aaf | 2022-04-27 17:49:35 -0700 | [diff] [blame] | 848 | rblf.mkinfo("product.mk", rblf.first_word(cfg["PRODUCT_COPY_FILES"])) |
| 849 | rblf.mkinfo("product.mk", rblf.last_word(cfg["PRODUCT_COPY_FILES"])) |
| 850 | rblf.mkinfo("product.mk", rblf.dir(rblf.last_word("product.mk"))) |
| 851 | rblf.mkinfo("product.mk", rblf.dir(rblf.last_word(cfg["PRODUCT_COPY_FILES"]))) |
| 852 | rblf.mkinfo("product.mk", rblf.dir(rblf.last_word(_foobar))) |
Sasha Smundak | 16e0773 | 2021-07-23 11:38:23 -0700 | [diff] [blame] | 853 | rblf.mkinfo("product.mk", rblf.abspath("foo/bar")) |
| 854 | rblf.mkinfo("product.mk", rblf.notdir("foo/bar")) |
Sasha Smundak | 65b547e | 2021-09-17 15:35:41 -0700 | [diff] [blame] | 855 | rblf.soong_config_namespace(g, "snsconfig") |
| 856 | rblf.soong_config_set(g, "snsconfig", "imagetype", "odm_image") |
| 857 | rblf.soong_config_set(g, "snsconfig", "foo", "foo_value") |
| 858 | rblf.soong_config_append(g, "snsconfig", "bar", "bar_value") |
Sasha Smundak | 3deb968 | 2021-07-26 18:42:25 -0700 | [diff] [blame] | 859 | cfg["PRODUCT_COPY_FILES"] = rblf.copy_files(rblf.expand_wildcard("foo*.mk"), "etc") |
Sasha Smundak | 0445308 | 2021-08-17 18:14:41 -0700 | [diff] [blame] | 860 | cfg["PRODUCT_COPY_FILES"] = rblf.product_copy_files_by_pattern("from/%", "to/%", "a b c") |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 861 | `, |
| 862 | }, |
| 863 | { |
Sasha Smundak | 9d011ab | 2021-07-09 16:00:57 -0700 | [diff] [blame] | 864 | desc: "subst in list", |
| 865 | mkname: "product.mk", |
| 866 | in: ` |
| 867 | files = $(call find-copy-subdir-files,*,from,to) |
| 868 | PRODUCT_COPY_FILES += $(subst foo,bar,$(files)) |
| 869 | `, |
| 870 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 871 | |
| 872 | def init(g, handle): |
| 873 | cfg = rblf.cfg(handle) |
| 874 | _files = rblf.find_and_copy("*", "from", "to") |
| 875 | rblf.setdefault(handle, "PRODUCT_COPY_FILES") |
| 876 | cfg["PRODUCT_COPY_FILES"] += rblf.mksubst("foo", "bar", _files) |
| 877 | `, |
| 878 | }, |
| 879 | { |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 880 | desc: "assignment flavors", |
| 881 | mkname: "product.mk", |
| 882 | in: ` |
| 883 | PRODUCT_LIST1 := a |
| 884 | PRODUCT_LIST2 += a |
| 885 | PRODUCT_LIST1 += b |
| 886 | PRODUCT_LIST2 += b |
| 887 | PRODUCT_LIST3 ?= a |
| 888 | PRODUCT_LIST1 = c |
| 889 | PLATFORM_LIST += x |
| 890 | PRODUCT_PACKAGES := $(PLATFORM_LIST) |
| 891 | `, |
| 892 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 893 | |
| 894 | def init(g, handle): |
| 895 | cfg = rblf.cfg(handle) |
| 896 | cfg["PRODUCT_LIST1"] = ["a"] |
| 897 | rblf.setdefault(handle, "PRODUCT_LIST2") |
| 898 | cfg["PRODUCT_LIST2"] += ["a"] |
| 899 | cfg["PRODUCT_LIST1"] += ["b"] |
| 900 | cfg["PRODUCT_LIST2"] += ["b"] |
| 901 | if cfg.get("PRODUCT_LIST3") == None: |
| 902 | cfg["PRODUCT_LIST3"] = ["a"] |
| 903 | cfg["PRODUCT_LIST1"] = ["c"] |
| 904 | g.setdefault("PLATFORM_LIST", []) |
| 905 | g["PLATFORM_LIST"] += ["x"] |
| 906 | cfg["PRODUCT_PACKAGES"] = g["PLATFORM_LIST"][:] |
| 907 | `, |
| 908 | }, |
| 909 | { |
| 910 | desc: "assigment flavors2", |
| 911 | mkname: "product.mk", |
| 912 | in: ` |
| 913 | PRODUCT_LIST1 = a |
| 914 | ifeq (0,1) |
| 915 | PRODUCT_LIST1 += b |
| 916 | PRODUCT_LIST2 += b |
| 917 | endif |
| 918 | PRODUCT_LIST1 += c |
| 919 | PRODUCT_LIST2 += c |
| 920 | `, |
| 921 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 922 | |
| 923 | def init(g, handle): |
| 924 | cfg = rblf.cfg(handle) |
| 925 | cfg["PRODUCT_LIST1"] = ["a"] |
| 926 | if "0" == "1": |
| 927 | cfg["PRODUCT_LIST1"] += ["b"] |
| 928 | rblf.setdefault(handle, "PRODUCT_LIST2") |
| 929 | cfg["PRODUCT_LIST2"] += ["b"] |
| 930 | cfg["PRODUCT_LIST1"] += ["c"] |
| 931 | rblf.setdefault(handle, "PRODUCT_LIST2") |
| 932 | cfg["PRODUCT_LIST2"] += ["c"] |
| 933 | `, |
| 934 | }, |
| 935 | { |
Cole Faust | e2a3798 | 2022-03-09 16:00:17 -0800 | [diff] [blame] | 936 | desc: "assigment setdefaults", |
| 937 | mkname: "product.mk", |
| 938 | in: ` |
| 939 | # All of these should have a setdefault because they're self-referential and not defined before |
| 940 | PRODUCT_LIST1 = a $(PRODUCT_LIST1) |
| 941 | PRODUCT_LIST2 ?= a $(PRODUCT_LIST2) |
| 942 | PRODUCT_LIST3 += a |
| 943 | |
| 944 | # Now doing them again should not have a setdefault because they've already been set |
| 945 | PRODUCT_LIST1 = a $(PRODUCT_LIST1) |
| 946 | PRODUCT_LIST2 ?= a $(PRODUCT_LIST2) |
| 947 | PRODUCT_LIST3 += a |
| 948 | `, |
| 949 | expected: `# All of these should have a setdefault because they're self-referential and not defined before |
| 950 | load("//build/make/core:product_config.rbc", "rblf") |
| 951 | |
| 952 | def init(g, handle): |
| 953 | cfg = rblf.cfg(handle) |
| 954 | rblf.setdefault(handle, "PRODUCT_LIST1") |
| 955 | cfg["PRODUCT_LIST1"] = (["a"] + |
| 956 | cfg.get("PRODUCT_LIST1", [])) |
| 957 | if cfg.get("PRODUCT_LIST2") == None: |
| 958 | rblf.setdefault(handle, "PRODUCT_LIST2") |
| 959 | cfg["PRODUCT_LIST2"] = (["a"] + |
| 960 | cfg.get("PRODUCT_LIST2", [])) |
| 961 | rblf.setdefault(handle, "PRODUCT_LIST3") |
| 962 | cfg["PRODUCT_LIST3"] += ["a"] |
| 963 | # Now doing them again should not have a setdefault because they've already been set |
| 964 | cfg["PRODUCT_LIST1"] = (["a"] + |
| 965 | cfg["PRODUCT_LIST1"]) |
| 966 | if cfg.get("PRODUCT_LIST2") == None: |
| 967 | cfg["PRODUCT_LIST2"] = (["a"] + |
| 968 | cfg["PRODUCT_LIST2"]) |
| 969 | cfg["PRODUCT_LIST3"] += ["a"] |
| 970 | `, |
| 971 | }, |
| 972 | { |
Sasha Smundak | 3deb968 | 2021-07-26 18:42:25 -0700 | [diff] [blame] | 973 | desc: "soong namespace assignments", |
| 974 | mkname: "product.mk", |
| 975 | in: ` |
| 976 | SOONG_CONFIG_NAMESPACES += cvd |
| 977 | SOONG_CONFIG_cvd += launch_configs |
Sasha Smundak | 65b547e | 2021-09-17 15:35:41 -0700 | [diff] [blame] | 978 | SOONG_CONFIG_cvd_launch_configs = cvd_config_auto.json |
Sasha Smundak | 3deb968 | 2021-07-26 18:42:25 -0700 | [diff] [blame] | 979 | SOONG_CONFIG_cvd += grub_config |
| 980 | SOONG_CONFIG_cvd_grub_config += grub.cfg |
Sasha Smundak | 65b547e | 2021-09-17 15:35:41 -0700 | [diff] [blame] | 981 | x := $(SOONG_CONFIG_cvd_grub_config) |
Sasha Smundak | 3deb968 | 2021-07-26 18:42:25 -0700 | [diff] [blame] | 982 | `, |
| 983 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 984 | |
| 985 | def init(g, handle): |
| 986 | cfg = rblf.cfg(handle) |
Sasha Smundak | 65b547e | 2021-09-17 15:35:41 -0700 | [diff] [blame] | 987 | rblf.soong_config_namespace(g, "cvd") |
| 988 | rblf.soong_config_set(g, "cvd", "launch_configs", "cvd_config_auto.json") |
| 989 | rblf.soong_config_append(g, "cvd", "grub_config", "grub.cfg") |
Cole Faust | 1e27586 | 2022-04-26 14:28:04 -0700 | [diff] [blame] | 990 | _x = rblf.mk2rbc_error("product.mk:7", "SOONG_CONFIG_ variables cannot be referenced, use soong_config_get instead: SOONG_CONFIG_cvd_grub_config") |
Sasha Smundak | 3deb968 | 2021-07-26 18:42:25 -0700 | [diff] [blame] | 991 | `, |
Cole Faust | c00184e | 2021-11-08 12:08:57 -0800 | [diff] [blame] | 992 | }, { |
| 993 | desc: "soong namespace accesses", |
| 994 | mkname: "product.mk", |
| 995 | in: ` |
| 996 | SOONG_CONFIG_NAMESPACES += cvd |
| 997 | SOONG_CONFIG_cvd += launch_configs |
| 998 | SOONG_CONFIG_cvd_launch_configs = cvd_config_auto.json |
| 999 | SOONG_CONFIG_cvd += grub_config |
| 1000 | SOONG_CONFIG_cvd_grub_config += grub.cfg |
| 1001 | x := $(call soong_config_get,cvd,grub_config) |
| 1002 | `, |
| 1003 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1004 | |
| 1005 | def init(g, handle): |
| 1006 | cfg = rblf.cfg(handle) |
| 1007 | rblf.soong_config_namespace(g, "cvd") |
| 1008 | rblf.soong_config_set(g, "cvd", "launch_configs", "cvd_config_auto.json") |
| 1009 | rblf.soong_config_append(g, "cvd", "grub_config", "grub.cfg") |
| 1010 | _x = rblf.soong_config_get(g, "cvd", "grub_config") |
| 1011 | `, |
Sasha Smundak | 3deb968 | 2021-07-26 18:42:25 -0700 | [diff] [blame] | 1012 | }, |
| 1013 | { |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 1014 | desc: "string split", |
| 1015 | mkname: "product.mk", |
| 1016 | in: ` |
| 1017 | PRODUCT_LIST1 = a |
| 1018 | local = b |
| 1019 | local += c |
| 1020 | FOO = d |
| 1021 | FOO += e |
| 1022 | PRODUCT_LIST1 += $(local) |
| 1023 | PRODUCT_LIST1 += $(FOO) |
| 1024 | `, |
| 1025 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1026 | |
| 1027 | def init(g, handle): |
| 1028 | cfg = rblf.cfg(handle) |
| 1029 | cfg["PRODUCT_LIST1"] = ["a"] |
| 1030 | _local = "b" |
| 1031 | _local += " " + "c" |
| 1032 | g["FOO"] = "d" |
| 1033 | g["FOO"] += " " + "e" |
| 1034 | cfg["PRODUCT_LIST1"] += (_local).split() |
| 1035 | cfg["PRODUCT_LIST1"] += (g["FOO"]).split() |
| 1036 | `, |
| 1037 | }, |
| 1038 | { |
| 1039 | desc: "apex_jars", |
| 1040 | mkname: "product.mk", |
| 1041 | in: ` |
| 1042 | PRODUCT_BOOT_JARS := $(ART_APEX_JARS) framework-minus-apex |
| 1043 | `, |
| 1044 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1045 | |
| 1046 | def init(g, handle): |
| 1047 | cfg = rblf.cfg(handle) |
| 1048 | cfg["PRODUCT_BOOT_JARS"] = (g.get("ART_APEX_JARS", []) + |
| 1049 | ["framework-minus-apex"]) |
| 1050 | `, |
| 1051 | }, |
| 1052 | { |
Cole Faust | 95b95cb | 2022-04-05 16:37:39 -0700 | [diff] [blame] | 1053 | desc: "strip/sort functions", |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 1054 | mkname: "product.mk", |
| 1055 | in: ` |
| 1056 | ifeq ($(filter hwaddress,$(PRODUCT_PACKAGES)),) |
| 1057 | PRODUCT_PACKAGES := $(strip $(PRODUCT_PACKAGES) hwaddress) |
| 1058 | endif |
Cole Faust | 95b95cb | 2022-04-05 16:37:39 -0700 | [diff] [blame] | 1059 | MY_VAR := $(sort b a c) |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 1060 | `, |
| 1061 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1062 | |
| 1063 | def init(g, handle): |
| 1064 | cfg = rblf.cfg(handle) |
| 1065 | if "hwaddress" not in cfg.get("PRODUCT_PACKAGES", []): |
Cole Faust | 816e080 | 2022-03-04 12:04:31 -0800 | [diff] [blame] | 1066 | rblf.setdefault(handle, "PRODUCT_PACKAGES") |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 1067 | cfg["PRODUCT_PACKAGES"] = (rblf.mkstrip("%s hwaddress" % " ".join(cfg.get("PRODUCT_PACKAGES", [])))).split() |
Cole Faust | 95b95cb | 2022-04-05 16:37:39 -0700 | [diff] [blame] | 1068 | g["MY_VAR"] = rblf.mksort("b a c") |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 1069 | `, |
| 1070 | }, |
| 1071 | { |
| 1072 | desc: "strip func in condition", |
| 1073 | mkname: "product.mk", |
| 1074 | in: ` |
| 1075 | ifneq ($(strip $(TARGET_VENDOR)),) |
| 1076 | endif |
| 1077 | `, |
| 1078 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1079 | |
| 1080 | def init(g, handle): |
| 1081 | cfg = rblf.cfg(handle) |
Sasha Smundak | 0554d76 | 2021-07-08 18:26:12 -0700 | [diff] [blame] | 1082 | if rblf.mkstrip(g.get("TARGET_VENDOR", "")): |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 1083 | pass |
| 1084 | `, |
| 1085 | }, |
| 1086 | { |
| 1087 | desc: "ref after set", |
| 1088 | mkname: "product.mk", |
| 1089 | in: ` |
| 1090 | PRODUCT_ADB_KEYS:=value |
| 1091 | FOO := $(PRODUCT_ADB_KEYS) |
| 1092 | ifneq (,$(PRODUCT_ADB_KEYS)) |
| 1093 | endif |
| 1094 | `, |
| 1095 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1096 | |
| 1097 | def init(g, handle): |
| 1098 | cfg = rblf.cfg(handle) |
| 1099 | g["PRODUCT_ADB_KEYS"] = "value" |
| 1100 | g["FOO"] = g["PRODUCT_ADB_KEYS"] |
| 1101 | if g["PRODUCT_ADB_KEYS"]: |
| 1102 | pass |
| 1103 | `, |
| 1104 | }, |
| 1105 | { |
| 1106 | desc: "ref before set", |
| 1107 | mkname: "product.mk", |
| 1108 | in: ` |
| 1109 | V1 := $(PRODUCT_ADB_KEYS) |
| 1110 | ifeq (,$(PRODUCT_ADB_KEYS)) |
| 1111 | V2 := $(PRODUCT_ADB_KEYS) |
| 1112 | PRODUCT_ADB_KEYS:=foo |
| 1113 | V3 := $(PRODUCT_ADB_KEYS) |
| 1114 | endif`, |
| 1115 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1116 | |
| 1117 | def init(g, handle): |
| 1118 | cfg = rblf.cfg(handle) |
| 1119 | g["V1"] = g.get("PRODUCT_ADB_KEYS", "") |
| 1120 | if not g.get("PRODUCT_ADB_KEYS", ""): |
| 1121 | g["V2"] = g.get("PRODUCT_ADB_KEYS", "") |
| 1122 | g["PRODUCT_ADB_KEYS"] = "foo" |
| 1123 | g["V3"] = g["PRODUCT_ADB_KEYS"] |
| 1124 | `, |
| 1125 | }, |
Sasha Smundak | 6609ba7 | 2021-07-22 18:32:56 -0700 | [diff] [blame] | 1126 | { |
| 1127 | desc: "Dynamic inherit path", |
| 1128 | mkname: "product.mk", |
| 1129 | in: ` |
Sasha Smundak | 6d852dd | 2021-09-27 20:34:39 -0700 | [diff] [blame] | 1130 | MY_PATH:=foo |
Sasha Smundak | 6609ba7 | 2021-07-22 18:32:56 -0700 | [diff] [blame] | 1131 | $(call inherit-product,vendor/$(MY_PATH)/cfg.mk) |
| 1132 | `, |
| 1133 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1134 | load("//vendor/foo1:cfg.star|init", _cfg_init = "init") |
| 1135 | load("//vendor/bar/baz:cfg.star|init", _cfg1_init = "init") |
| 1136 | |
| 1137 | def init(g, handle): |
| 1138 | cfg = rblf.cfg(handle) |
| 1139 | g["MY_PATH"] = "foo" |
| 1140 | _entry = { |
Sasha Smundak | 845cb29 | 2022-01-18 10:31:14 -0800 | [diff] [blame] | 1141 | "vendor/foo1/cfg.mk": ("vendor/foo1/cfg", _cfg_init), |
| 1142 | "vendor/bar/baz/cfg.mk": ("vendor/bar/baz/cfg", _cfg1_init), |
Sasha Smundak | 6609ba7 | 2021-07-22 18:32:56 -0700 | [diff] [blame] | 1143 | }.get("vendor/%s/cfg.mk" % g["MY_PATH"]) |
| 1144 | (_varmod, _varmod_init) = _entry if _entry else (None, None) |
| 1145 | if not _varmod_init: |
Cole Faust | 7321b09 | 2021-12-21 16:11:16 -0800 | [diff] [blame] | 1146 | rblf.mkerror("product.mk", "Cannot find %s" % ("vendor/%s/cfg.mk" % g["MY_PATH"])) |
Sasha Smundak | 6609ba7 | 2021-07-22 18:32:56 -0700 | [diff] [blame] | 1147 | rblf.inherit(handle, _varmod, _varmod_init) |
| 1148 | `, |
| 1149 | }, |
Sasha Smundak | 6d852dd | 2021-09-27 20:34:39 -0700 | [diff] [blame] | 1150 | { |
| 1151 | desc: "Dynamic inherit with hint", |
| 1152 | mkname: "product.mk", |
| 1153 | in: ` |
| 1154 | MY_PATH:=foo |
| 1155 | #RBC# include_top vendor/foo1 |
| 1156 | $(call inherit-product,$(MY_PATH)/cfg.mk) |
Cole Faust | 9df1d73 | 2022-04-26 16:27:22 -0700 | [diff] [blame] | 1157 | #RBC# include_top vendor/foo1 |
| 1158 | $(call inherit-product,$(MY_OTHER_PATH)) |
| 1159 | #RBC# include_top vendor/foo1 |
Cole Faust | 74ac027 | 2022-06-14 12:45:26 -0700 | [diff] [blame] | 1160 | $(call inherit-product,vendor/$(MY_OTHER_PATH)) |
| 1161 | #RBC# include_top vendor/foo1 |
Cole Faust | 9df1d73 | 2022-04-26 16:27:22 -0700 | [diff] [blame] | 1162 | $(foreach f,$(MY_MAKEFILES), \ |
| 1163 | $(call inherit-product,$(f))) |
Sasha Smundak | 6d852dd | 2021-09-27 20:34:39 -0700 | [diff] [blame] | 1164 | `, |
| 1165 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1166 | load("//vendor/foo1:cfg.star|init", _cfg_init = "init") |
| 1167 | |
| 1168 | def init(g, handle): |
| 1169 | cfg = rblf.cfg(handle) |
| 1170 | g["MY_PATH"] = "foo" |
Cole Faust | 93f8d39 | 2022-03-02 13:31:30 -0800 | [diff] [blame] | 1171 | _entry = { |
| 1172 | "vendor/foo1/cfg.mk": ("vendor/foo1/cfg", _cfg_init), |
| 1173 | }.get("%s/cfg.mk" % g["MY_PATH"]) |
| 1174 | (_varmod, _varmod_init) = _entry if _entry else (None, None) |
| 1175 | if not _varmod_init: |
| 1176 | rblf.mkerror("product.mk", "Cannot find %s" % ("%s/cfg.mk" % g["MY_PATH"])) |
| 1177 | rblf.inherit(handle, _varmod, _varmod_init) |
Cole Faust | 9df1d73 | 2022-04-26 16:27:22 -0700 | [diff] [blame] | 1178 | _entry = { |
| 1179 | "vendor/foo1/cfg.mk": ("vendor/foo1/cfg", _cfg_init), |
| 1180 | }.get(g.get("MY_OTHER_PATH", "")) |
| 1181 | (_varmod, _varmod_init) = _entry if _entry else (None, None) |
| 1182 | if not _varmod_init: |
| 1183 | rblf.mkerror("product.mk", "Cannot find %s" % (g.get("MY_OTHER_PATH", ""))) |
| 1184 | rblf.inherit(handle, _varmod, _varmod_init) |
Cole Faust | 74ac027 | 2022-06-14 12:45:26 -0700 | [diff] [blame] | 1185 | _entry = { |
| 1186 | "vendor/foo1/cfg.mk": ("vendor/foo1/cfg", _cfg_init), |
| 1187 | }.get("vendor/%s" % g.get("MY_OTHER_PATH", "")) |
| 1188 | (_varmod, _varmod_init) = _entry if _entry else (None, None) |
| 1189 | if not _varmod_init: |
| 1190 | rblf.mkerror("product.mk", "Cannot find %s" % ("vendor/%s" % g.get("MY_OTHER_PATH", ""))) |
| 1191 | rblf.inherit(handle, _varmod, _varmod_init) |
Cole Faust | 9df1d73 | 2022-04-26 16:27:22 -0700 | [diff] [blame] | 1192 | for f in rblf.words(g.get("MY_MAKEFILES", "")): |
| 1193 | _entry = { |
| 1194 | "vendor/foo1/cfg.mk": ("vendor/foo1/cfg", _cfg_init), |
| 1195 | }.get(f) |
| 1196 | (_varmod, _varmod_init) = _entry if _entry else (None, None) |
| 1197 | if not _varmod_init: |
| 1198 | rblf.mkerror("product.mk", "Cannot find %s" % (f)) |
| 1199 | rblf.inherit(handle, _varmod, _varmod_init) |
Sasha Smundak | 6d852dd | 2021-09-27 20:34:39 -0700 | [diff] [blame] | 1200 | `, |
| 1201 | }, |
Sasha Smundak | 2afb9d7 | 2021-10-24 15:16:59 -0700 | [diff] [blame] | 1202 | { |
Cole Faust | f7ed534 | 2021-12-21 14:15:12 -0800 | [diff] [blame] | 1203 | desc: "Dynamic inherit with duplicated hint", |
| 1204 | mkname: "product.mk", |
| 1205 | in: ` |
| 1206 | MY_PATH:=foo |
| 1207 | #RBC# include_top vendor/foo1 |
| 1208 | $(call inherit-product,$(MY_PATH)/cfg.mk) |
| 1209 | #RBC# include_top vendor/foo1 |
Cole Faust | 7940c6a | 2022-01-31 15:54:05 -0800 | [diff] [blame] | 1210 | #RBC# include_top vendor/foo1 |
Cole Faust | f7ed534 | 2021-12-21 14:15:12 -0800 | [diff] [blame] | 1211 | $(call inherit-product,$(MY_PATH)/cfg.mk) |
| 1212 | `, |
| 1213 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1214 | load("//vendor/foo1:cfg.star|init", _cfg_init = "init") |
| 1215 | |
| 1216 | def init(g, handle): |
| 1217 | cfg = rblf.cfg(handle) |
| 1218 | g["MY_PATH"] = "foo" |
Cole Faust | 93f8d39 | 2022-03-02 13:31:30 -0800 | [diff] [blame] | 1219 | _entry = { |
| 1220 | "vendor/foo1/cfg.mk": ("vendor/foo1/cfg", _cfg_init), |
| 1221 | }.get("%s/cfg.mk" % g["MY_PATH"]) |
| 1222 | (_varmod, _varmod_init) = _entry if _entry else (None, None) |
| 1223 | if not _varmod_init: |
| 1224 | rblf.mkerror("product.mk", "Cannot find %s" % ("%s/cfg.mk" % g["MY_PATH"])) |
| 1225 | rblf.inherit(handle, _varmod, _varmod_init) |
| 1226 | _entry = { |
| 1227 | "vendor/foo1/cfg.mk": ("vendor/foo1/cfg", _cfg_init), |
| 1228 | }.get("%s/cfg.mk" % g["MY_PATH"]) |
| 1229 | (_varmod, _varmod_init) = _entry if _entry else (None, None) |
| 1230 | if not _varmod_init: |
| 1231 | rblf.mkerror("product.mk", "Cannot find %s" % ("%s/cfg.mk" % g["MY_PATH"])) |
| 1232 | rblf.inherit(handle, _varmod, _varmod_init) |
Cole Faust | f7ed534 | 2021-12-21 14:15:12 -0800 | [diff] [blame] | 1233 | `, |
| 1234 | }, |
| 1235 | { |
Cole Faust | 069aba6 | 2022-01-26 17:47:33 -0800 | [diff] [blame] | 1236 | desc: "Dynamic inherit path that lacks hint", |
Cole Faust | 6c934f6 | 2022-01-06 15:51:12 -0800 | [diff] [blame] | 1237 | mkname: "product.mk", |
| 1238 | in: ` |
| 1239 | #RBC# include_top foo |
| 1240 | $(call inherit-product,$(MY_VAR)/font.mk) |
| 1241 | |
| 1242 | #RBC# include_top foo |
| 1243 | |
| 1244 | # There's some space and even this comment between the include_top and the inherit-product |
| 1245 | |
| 1246 | $(call inherit-product,$(MY_VAR)/font.mk) |
| 1247 | |
| 1248 | $(call inherit-product,$(MY_VAR)/font.mk) |
| 1249 | `, |
Cole Faust | 7940c6a | 2022-01-31 15:54:05 -0800 | [diff] [blame] | 1250 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
Cole Faust | 6c934f6 | 2022-01-06 15:51:12 -0800 | [diff] [blame] | 1251 | load("//foo:font.star|init", _font_init = "init") |
Cole Faust | 069aba6 | 2022-01-26 17:47:33 -0800 | [diff] [blame] | 1252 | load("//bar:font.star|init", _font1_init = "init") |
Cole Faust | 6c934f6 | 2022-01-06 15:51:12 -0800 | [diff] [blame] | 1253 | |
| 1254 | def init(g, handle): |
| 1255 | cfg = rblf.cfg(handle) |
Cole Faust | 93f8d39 | 2022-03-02 13:31:30 -0800 | [diff] [blame] | 1256 | _entry = { |
| 1257 | "foo/font.mk": ("foo/font", _font_init), |
| 1258 | }.get("%s/font.mk" % g.get("MY_VAR", "")) |
| 1259 | (_varmod, _varmod_init) = _entry if _entry else (None, None) |
| 1260 | if not _varmod_init: |
| 1261 | rblf.mkerror("product.mk", "Cannot find %s" % ("%s/font.mk" % g.get("MY_VAR", ""))) |
| 1262 | rblf.inherit(handle, _varmod, _varmod_init) |
Cole Faust | 6c934f6 | 2022-01-06 15:51:12 -0800 | [diff] [blame] | 1263 | # There's some space and even this comment between the include_top and the inherit-product |
Cole Faust | 93f8d39 | 2022-03-02 13:31:30 -0800 | [diff] [blame] | 1264 | _entry = { |
| 1265 | "foo/font.mk": ("foo/font", _font_init), |
| 1266 | }.get("%s/font.mk" % g.get("MY_VAR", "")) |
| 1267 | (_varmod, _varmod_init) = _entry if _entry else (None, None) |
| 1268 | if not _varmod_init: |
| 1269 | rblf.mkerror("product.mk", "Cannot find %s" % ("%s/font.mk" % g.get("MY_VAR", ""))) |
| 1270 | rblf.inherit(handle, _varmod, _varmod_init) |
Cole Faust | f4e72cf | 2022-02-08 12:49:37 -0800 | [diff] [blame] | 1271 | rblf.mkwarning("product.mk:11", "Please avoid starting an include path with a variable. See https://source.android.com/setup/build/bazel/product_config/issues/includes for details.") |
Cole Faust | 6c934f6 | 2022-01-06 15:51:12 -0800 | [diff] [blame] | 1272 | _entry = { |
Sasha Smundak | 845cb29 | 2022-01-18 10:31:14 -0800 | [diff] [blame] | 1273 | "foo/font.mk": ("foo/font", _font_init), |
Cole Faust | 069aba6 | 2022-01-26 17:47:33 -0800 | [diff] [blame] | 1274 | "bar/font.mk": ("bar/font", _font1_init), |
Cole Faust | 6c934f6 | 2022-01-06 15:51:12 -0800 | [diff] [blame] | 1275 | }.get("%s/font.mk" % g.get("MY_VAR", "")) |
| 1276 | (_varmod, _varmod_init) = _entry if _entry else (None, None) |
| 1277 | if not _varmod_init: |
| 1278 | rblf.mkerror("product.mk", "Cannot find %s" % ("%s/font.mk" % g.get("MY_VAR", ""))) |
| 1279 | rblf.inherit(handle, _varmod, _varmod_init) |
Cole Faust | 6c934f6 | 2022-01-06 15:51:12 -0800 | [diff] [blame] | 1280 | `, |
| 1281 | }, |
| 1282 | { |
Sasha Smundak | 2afb9d7 | 2021-10-24 15:16:59 -0700 | [diff] [blame] | 1283 | desc: "Ignore make rules", |
| 1284 | mkname: "product.mk", |
| 1285 | in: ` |
Cole Faust | 00afd4f | 2022-04-26 14:01:56 -0700 | [diff] [blame] | 1286 | foo: PRIVATE_VARIABLE = some_tool $< $@ |
Sasha Smundak | 2afb9d7 | 2021-10-24 15:16:59 -0700 | [diff] [blame] | 1287 | foo: foo.c |
| 1288 | gcc -o $@ $*`, |
Sasha Smundak | 422b614 | 2021-11-11 18:31:59 -0800 | [diff] [blame] | 1289 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
Sasha Smundak | 2afb9d7 | 2021-10-24 15:16:59 -0700 | [diff] [blame] | 1290 | |
| 1291 | def init(g, handle): |
| 1292 | cfg = rblf.cfg(handle) |
Cole Faust | 00afd4f | 2022-04-26 14:01:56 -0700 | [diff] [blame] | 1293 | rblf.mk2rbc_error("product.mk:2", "Only simple variables are handled") |
| 1294 | rblf.mk2rbc_error("product.mk:3", "unsupported line rule: foo: foo.c\n#gcc -o $@ $*") |
Sasha Smundak | 2afb9d7 | 2021-10-24 15:16:59 -0700 | [diff] [blame] | 1295 | `, |
| 1296 | }, |
Sasha Smundak | ea3bc3a | 2021-11-10 13:06:42 -0800 | [diff] [blame] | 1297 | { |
| 1298 | desc: "Flag override", |
| 1299 | mkname: "product.mk", |
| 1300 | in: ` |
| 1301 | override FOO:=`, |
Sasha Smundak | 422b614 | 2021-11-11 18:31:59 -0800 | [diff] [blame] | 1302 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
Sasha Smundak | ea3bc3a | 2021-11-10 13:06:42 -0800 | [diff] [blame] | 1303 | |
| 1304 | def init(g, handle): |
| 1305 | cfg = rblf.cfg(handle) |
Sasha Smundak | 422b614 | 2021-11-11 18:31:59 -0800 | [diff] [blame] | 1306 | rblf.mk2rbc_error("product.mk:2", "cannot handle override directive") |
Sasha Smundak | 422b614 | 2021-11-11 18:31:59 -0800 | [diff] [blame] | 1307 | `, |
| 1308 | }, |
| 1309 | { |
| 1310 | desc: "Bad expression", |
| 1311 | mkname: "build/product.mk", |
| 1312 | in: ` |
| 1313 | ifeq (,$(call foobar)) |
| 1314 | endif |
Cole Faust | 1e27586 | 2022-04-26 14:28:04 -0700 | [diff] [blame] | 1315 | my_sources := $(local-generated-sources-dir) |
Sasha Smundak | 422b614 | 2021-11-11 18:31:59 -0800 | [diff] [blame] | 1316 | `, |
| 1317 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1318 | |
| 1319 | def init(g, handle): |
| 1320 | cfg = rblf.cfg(handle) |
| 1321 | if rblf.mk2rbc_error("build/product.mk:2", "cannot handle invoking foobar"): |
| 1322 | pass |
Cole Faust | 1e27586 | 2022-04-26 14:28:04 -0700 | [diff] [blame] | 1323 | _my_sources = rblf.mk2rbc_error("build/product.mk:4", "local-generated-sources-dir is not supported") |
Sasha Smundak | ea3bc3a | 2021-11-10 13:06:42 -0800 | [diff] [blame] | 1324 | `, |
| 1325 | }, |
Cole Faust | 4eadba7 | 2021-12-07 11:54:52 -0800 | [diff] [blame] | 1326 | { |
| 1327 | desc: "if expression", |
| 1328 | mkname: "product.mk", |
| 1329 | in: ` |
| 1330 | TEST_VAR := foo |
| 1331 | TEST_VAR_LIST := foo |
| 1332 | TEST_VAR_LIST += bar |
| 1333 | TEST_VAR_2 := $(if $(TEST_VAR),bar) |
| 1334 | TEST_VAR_3 := $(if $(TEST_VAR),bar,baz) |
Cole Faust | 421a192 | 2022-03-16 14:35:45 -0700 | [diff] [blame] | 1335 | TEST_VAR_4 := $(if $(TEST_VAR),$(TEST_VAR_LIST)) |
Cole Faust | 4eadba7 | 2021-12-07 11:54:52 -0800 | [diff] [blame] | 1336 | `, |
| 1337 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1338 | |
| 1339 | def init(g, handle): |
| 1340 | cfg = rblf.cfg(handle) |
| 1341 | g["TEST_VAR"] = "foo" |
| 1342 | g["TEST_VAR_LIST"] = ["foo"] |
| 1343 | g["TEST_VAR_LIST"] += ["bar"] |
| 1344 | g["TEST_VAR_2"] = ("bar" if g["TEST_VAR"] else "") |
| 1345 | g["TEST_VAR_3"] = ("bar" if g["TEST_VAR"] else "baz") |
Cole Faust | 421a192 | 2022-03-16 14:35:45 -0700 | [diff] [blame] | 1346 | g["TEST_VAR_4"] = (g["TEST_VAR_LIST"] if g["TEST_VAR"] else []) |
Cole Faust | 4eadba7 | 2021-12-07 11:54:52 -0800 | [diff] [blame] | 1347 | `, |
| 1348 | }, |
Cole Faust | c36c962 | 2021-12-07 15:20:45 -0800 | [diff] [blame] | 1349 | { |
| 1350 | desc: "substitution references", |
| 1351 | mkname: "product.mk", |
| 1352 | in: ` |
| 1353 | SOURCES := foo.c bar.c |
| 1354 | OBJECTS := $(SOURCES:.c=.o) |
| 1355 | OBJECTS2 := $(SOURCES:%.c=%.o) |
| 1356 | `, |
| 1357 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1358 | |
| 1359 | def init(g, handle): |
| 1360 | cfg = rblf.cfg(handle) |
| 1361 | g["SOURCES"] = "foo.c bar.c" |
| 1362 | g["OBJECTS"] = rblf.mkpatsubst("%.c", "%.o", g["SOURCES"]) |
| 1363 | g["OBJECTS2"] = rblf.mkpatsubst("%.c", "%.o", g["SOURCES"]) |
| 1364 | `, |
| 1365 | }, |
Cole Faust | b0d32ab | 2021-12-09 14:00:59 -0800 | [diff] [blame] | 1366 | { |
| 1367 | desc: "foreach expressions", |
| 1368 | mkname: "product.mk", |
| 1369 | in: ` |
| 1370 | BOOT_KERNEL_MODULES := foo.ko bar.ko |
| 1371 | BOOT_KERNEL_MODULES_FILTER := $(foreach m,$(BOOT_KERNEL_MODULES),%/$(m)) |
| 1372 | BOOT_KERNEL_MODULES_LIST := foo.ko |
| 1373 | BOOT_KERNEL_MODULES_LIST += bar.ko |
| 1374 | BOOT_KERNEL_MODULES_FILTER_2 := $(foreach m,$(BOOT_KERNEL_MODULES_LIST),%/$(m)) |
Cole Faust | 72374fc | 2022-05-05 11:45:04 -0700 | [diff] [blame] | 1375 | NESTED_LISTS := $(foreach m,$(SOME_VAR),$(BOOT_KERNEL_MODULES_LIST)) |
| 1376 | NESTED_LISTS_2 := $(foreach x,$(SOME_VAR),$(foreach y,$(x),prefix$(y))) |
Cole Faust | b0d32ab | 2021-12-09 14:00:59 -0800 | [diff] [blame] | 1377 | |
Cole Faust | b67aa08 | 2022-02-28 16:39:59 -0800 | [diff] [blame] | 1378 | FOREACH_WITH_IF := $(foreach module,\ |
| 1379 | $(BOOT_KERNEL_MODULES_LIST),\ |
| 1380 | $(if $(filter $(module),foo.ko),,$(error module "$(module)" has an error!))) |
Cole Faust | f035d40 | 2022-03-28 14:02:50 -0700 | [diff] [blame] | 1381 | |
| 1382 | # Same as above, but not assigning it to a variable allows it to be converted to statements |
| 1383 | $(foreach module,\ |
| 1384 | $(BOOT_KERNEL_MODULES_LIST),\ |
| 1385 | $(if $(filter $(module),foo.ko),,$(error module "$(module)" has an error!))) |
Cole Faust | b0d32ab | 2021-12-09 14:00:59 -0800 | [diff] [blame] | 1386 | `, |
| 1387 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1388 | |
| 1389 | def init(g, handle): |
| 1390 | cfg = rblf.cfg(handle) |
| 1391 | g["BOOT_KERNEL_MODULES"] = "foo.ko bar.ko" |
| 1392 | g["BOOT_KERNEL_MODULES_FILTER"] = ["%%/%s" % m for m in rblf.words(g["BOOT_KERNEL_MODULES"])] |
| 1393 | g["BOOT_KERNEL_MODULES_LIST"] = ["foo.ko"] |
| 1394 | g["BOOT_KERNEL_MODULES_LIST"] += ["bar.ko"] |
| 1395 | g["BOOT_KERNEL_MODULES_FILTER_2"] = ["%%/%s" % m for m in g["BOOT_KERNEL_MODULES_LIST"]] |
Cole Faust | 72374fc | 2022-05-05 11:45:04 -0700 | [diff] [blame] | 1396 | g["NESTED_LISTS"] = rblf.flatten_2d_list([g["BOOT_KERNEL_MODULES_LIST"] for m in rblf.words(g.get("SOME_VAR", ""))]) |
| 1397 | g["NESTED_LISTS_2"] = rblf.flatten_2d_list([["prefix%s" % y for y in rblf.words(x)] for x in rblf.words(g.get("SOME_VAR", ""))]) |
Cole Faust | b67aa08 | 2022-02-28 16:39:59 -0800 | [diff] [blame] | 1398 | g["FOREACH_WITH_IF"] = [("" if rblf.filter(module, "foo.ko") else rblf.mkerror("product.mk", "module \"%s\" has an error!" % module)) for module in g["BOOT_KERNEL_MODULES_LIST"]] |
Cole Faust | f035d40 | 2022-03-28 14:02:50 -0700 | [diff] [blame] | 1399 | # Same as above, but not assigning it to a variable allows it to be converted to statements |
| 1400 | for module in g["BOOT_KERNEL_MODULES_LIST"]: |
| 1401 | if not rblf.filter(module, "foo.ko"): |
| 1402 | rblf.mkerror("product.mk", "module \"%s\" has an error!" % module) |
Cole Faust | b0d32ab | 2021-12-09 14:00:59 -0800 | [diff] [blame] | 1403 | `, |
| 1404 | }, |
Cole Faust | 0484c23 | 2021-12-22 14:08:08 -0800 | [diff] [blame] | 1405 | { |
| 1406 | desc: "List appended to string", |
| 1407 | mkname: "product.mk", |
| 1408 | in: ` |
| 1409 | NATIVE_BRIDGE_PRODUCT_PACKAGES := \ |
| 1410 | libnative_bridge_vdso.native_bridge \ |
| 1411 | native_bridge_guest_app_process.native_bridge \ |
| 1412 | native_bridge_guest_linker.native_bridge |
| 1413 | |
| 1414 | NATIVE_BRIDGE_MODIFIED_GUEST_LIBS := \ |
| 1415 | libaaudio \ |
| 1416 | libamidi \ |
| 1417 | libandroid \ |
| 1418 | libandroid_runtime |
| 1419 | |
| 1420 | NATIVE_BRIDGE_PRODUCT_PACKAGES += \ |
| 1421 | $(addsuffix .native_bridge,$(NATIVE_BRIDGE_ORIG_GUEST_LIBS)) |
| 1422 | `, |
| 1423 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1424 | |
| 1425 | def init(g, handle): |
| 1426 | cfg = rblf.cfg(handle) |
| 1427 | g["NATIVE_BRIDGE_PRODUCT_PACKAGES"] = "libnative_bridge_vdso.native_bridge native_bridge_guest_app_process.native_bridge native_bridge_guest_linker.native_bridge" |
| 1428 | g["NATIVE_BRIDGE_MODIFIED_GUEST_LIBS"] = "libaaudio libamidi libandroid libandroid_runtime" |
| 1429 | g["NATIVE_BRIDGE_PRODUCT_PACKAGES"] += " " + " ".join(rblf.addsuffix(".native_bridge", g.get("NATIVE_BRIDGE_ORIG_GUEST_LIBS", ""))) |
| 1430 | `, |
| 1431 | }, |
Cole Faust | b1103e2 | 2022-01-06 15:22:05 -0800 | [diff] [blame] | 1432 | { |
| 1433 | desc: "Math functions", |
| 1434 | mkname: "product.mk", |
| 1435 | in: ` |
| 1436 | # Test the math functions defined in build/make/common/math.mk |
| 1437 | ifeq ($(call math_max,2,5),5) |
| 1438 | endif |
| 1439 | ifeq ($(call math_min,2,5),2) |
| 1440 | endif |
| 1441 | ifeq ($(call math_gt_or_eq,2,5),true) |
| 1442 | endif |
| 1443 | ifeq ($(call math_gt,2,5),true) |
| 1444 | endif |
| 1445 | ifeq ($(call math_lt,2,5),true) |
| 1446 | endif |
| 1447 | ifeq ($(call math_gt_or_eq,2,5),) |
| 1448 | endif |
| 1449 | ifeq ($(call math_gt,2,5),) |
| 1450 | endif |
| 1451 | ifeq ($(call math_lt,2,5),) |
| 1452 | endif |
| 1453 | ifeq ($(call math_gt_or_eq,$(MY_VAR), 5),true) |
| 1454 | endif |
| 1455 | ifeq ($(call math_gt_or_eq,$(MY_VAR),$(MY_OTHER_VAR)),true) |
| 1456 | endif |
| 1457 | ifeq ($(call math_gt_or_eq,100$(MY_VAR),10),true) |
| 1458 | endif |
| 1459 | `, |
| 1460 | expected: `# Test the math functions defined in build/make/common/math.mk |
| 1461 | load("//build/make/core:product_config.rbc", "rblf") |
| 1462 | |
| 1463 | def init(g, handle): |
| 1464 | cfg = rblf.cfg(handle) |
| 1465 | if max(2, 5) == 5: |
| 1466 | pass |
| 1467 | if min(2, 5) == 2: |
| 1468 | pass |
| 1469 | if 2 >= 5: |
| 1470 | pass |
| 1471 | if 2 > 5: |
| 1472 | pass |
| 1473 | if 2 < 5: |
| 1474 | pass |
| 1475 | if 2 < 5: |
| 1476 | pass |
| 1477 | if 2 <= 5: |
| 1478 | pass |
| 1479 | if 2 >= 5: |
| 1480 | pass |
| 1481 | if int(g.get("MY_VAR", "")) >= 5: |
| 1482 | pass |
| 1483 | if int(g.get("MY_VAR", "")) >= int(g.get("MY_OTHER_VAR", "")): |
| 1484 | pass |
| 1485 | if int("100%s" % g.get("MY_VAR", "")) >= 10: |
| 1486 | pass |
| 1487 | `, |
| 1488 | }, |
Cole Faust | f92c9f2 | 2022-03-14 14:35:50 -0700 | [diff] [blame] | 1489 | { |
| 1490 | desc: "Type hints", |
| 1491 | mkname: "product.mk", |
| 1492 | in: ` |
| 1493 | # Test type hints |
| 1494 | #RBC# type_hint list MY_VAR MY_VAR_2 |
| 1495 | # Unsupported type |
| 1496 | #RBC# type_hint bool MY_VAR_3 |
| 1497 | # Invalid syntax |
| 1498 | #RBC# type_hint list |
| 1499 | # Duplicated variable |
| 1500 | #RBC# type_hint list MY_VAR_2 |
| 1501 | #RBC# type_hint list my-local-var-with-dashes |
Cole Faust | 421a192 | 2022-03-16 14:35:45 -0700 | [diff] [blame] | 1502 | #RBC# type_hint string MY_STRING_VAR |
Cole Faust | f92c9f2 | 2022-03-14 14:35:50 -0700 | [diff] [blame] | 1503 | |
| 1504 | MY_VAR := foo |
| 1505 | MY_VAR_UNHINTED := foo |
| 1506 | |
| 1507 | # Vars set after other statements still get the hint |
| 1508 | MY_VAR_2 := foo |
| 1509 | |
| 1510 | # You can't specify a type hint after the first statement |
| 1511 | #RBC# type_hint list MY_VAR_4 |
| 1512 | MY_VAR_4 := foo |
| 1513 | |
| 1514 | my-local-var-with-dashes := foo |
Cole Faust | 421a192 | 2022-03-16 14:35:45 -0700 | [diff] [blame] | 1515 | |
| 1516 | MY_STRING_VAR := $(wildcard foo/bar.mk) |
Cole Faust | f92c9f2 | 2022-03-14 14:35:50 -0700 | [diff] [blame] | 1517 | `, |
| 1518 | expected: `# Test type hints |
| 1519 | # Unsupported type |
| 1520 | load("//build/make/core:product_config.rbc", "rblf") |
| 1521 | |
| 1522 | def init(g, handle): |
| 1523 | cfg = rblf.cfg(handle) |
| 1524 | rblf.mk2rbc_error("product.mk:5", "Invalid type_hint annotation. Only list/string types are accepted, found bool") |
| 1525 | # Invalid syntax |
| 1526 | rblf.mk2rbc_error("product.mk:7", "Invalid type_hint annotation: list. Must be a variable type followed by a list of variables of that type") |
| 1527 | # Duplicated variable |
| 1528 | rblf.mk2rbc_error("product.mk:9", "Duplicate type hint for variable MY_VAR_2") |
| 1529 | g["MY_VAR"] = ["foo"] |
| 1530 | g["MY_VAR_UNHINTED"] = "foo" |
| 1531 | # Vars set after other statements still get the hint |
| 1532 | g["MY_VAR_2"] = ["foo"] |
| 1533 | # You can't specify a type hint after the first statement |
Cole Faust | 421a192 | 2022-03-16 14:35:45 -0700 | [diff] [blame] | 1534 | rblf.mk2rbc_error("product.mk:20", "type_hint annotations must come before the first Makefile statement") |
Cole Faust | f92c9f2 | 2022-03-14 14:35:50 -0700 | [diff] [blame] | 1535 | g["MY_VAR_4"] = "foo" |
| 1536 | _my_local_var_with_dashes = ["foo"] |
Cole Faust | 421a192 | 2022-03-16 14:35:45 -0700 | [diff] [blame] | 1537 | g["MY_STRING_VAR"] = " ".join(rblf.expand_wildcard("foo/bar.mk")) |
Cole Faust | f92c9f2 | 2022-03-14 14:35:50 -0700 | [diff] [blame] | 1538 | `, |
| 1539 | }, |
Cole Faust | f5adedc | 2022-03-18 14:05:06 -0700 | [diff] [blame] | 1540 | { |
| 1541 | desc: "Set LOCAL_PATH to my-dir", |
| 1542 | mkname: "product.mk", |
| 1543 | in: ` |
| 1544 | LOCAL_PATH := $(call my-dir) |
| 1545 | `, |
| 1546 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1547 | |
| 1548 | def init(g, handle): |
| 1549 | cfg = rblf.cfg(handle) |
| 1550 | |
| 1551 | `, |
| 1552 | }, |
Cole Faust | f035d40 | 2022-03-28 14:02:50 -0700 | [diff] [blame] | 1553 | { |
| 1554 | desc: "Evals", |
| 1555 | mkname: "product.mk", |
| 1556 | in: ` |
| 1557 | $(eval) |
| 1558 | $(eval MY_VAR := foo) |
| 1559 | $(eval # This is a test of eval functions) |
| 1560 | $(eval $(TOO_COMPLICATED) := bar) |
Cole Faust | 2005298 | 2022-04-22 14:43:55 -0700 | [diff] [blame] | 1561 | $(eval include foo/font.mk) |
| 1562 | $(eval $(call inherit-product,vendor/foo1/cfg.mk)) |
| 1563 | |
Cole Faust | f035d40 | 2022-03-28 14:02:50 -0700 | [diff] [blame] | 1564 | $(foreach x,$(MY_LIST_VAR), \ |
| 1565 | $(eval PRODUCT_COPY_FILES += foo/bar/$(x):$(TARGET_COPY_OUT_VENDOR)/etc/$(x)) \ |
Cole Faust | 2005298 | 2022-04-22 14:43:55 -0700 | [diff] [blame] | 1566 | $(if $(MY_OTHER_VAR),$(eval PRODUCT_COPY_FILES += $(MY_OTHER_VAR):foo/bar/$(x)))) |
Cole Faust | f035d40 | 2022-03-28 14:02:50 -0700 | [diff] [blame] | 1567 | |
Cole Faust | 2005298 | 2022-04-22 14:43:55 -0700 | [diff] [blame] | 1568 | $(foreach x,$(MY_LIST_VAR), \ |
| 1569 | $(eval include foo/$(x).mk)) |
Cole Faust | 7366042 | 2023-01-05 11:07:47 -0800 | [diff] [blame] | 1570 | |
| 1571 | # Check that we get as least close to correct line numbers for errors on statements inside evals |
| 1572 | $(eval $(call inherit-product,$(A_VAR))) |
Cole Faust | f035d40 | 2022-03-28 14:02:50 -0700 | [diff] [blame] | 1573 | `, |
| 1574 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
Cole Faust | 2005298 | 2022-04-22 14:43:55 -0700 | [diff] [blame] | 1575 | load("//foo:font.star", _font_init = "init") |
| 1576 | load("//vendor/foo1:cfg.star", _cfg_init = "init") |
Cole Faust | f035d40 | 2022-03-28 14:02:50 -0700 | [diff] [blame] | 1577 | |
| 1578 | def init(g, handle): |
| 1579 | cfg = rblf.cfg(handle) |
| 1580 | g["MY_VAR"] = "foo" |
| 1581 | # This is a test of eval functions |
Cole Faust | 2005298 | 2022-04-22 14:43:55 -0700 | [diff] [blame] | 1582 | rblf.mk2rbc_error("product.mk:5", "Eval expression too complex; only assignments, comments, includes, and inherit-products are supported") |
| 1583 | _font_init(g, handle) |
| 1584 | rblf.inherit(handle, "vendor/foo1/cfg", _cfg_init) |
Cole Faust | f035d40 | 2022-03-28 14:02:50 -0700 | [diff] [blame] | 1585 | for x in rblf.words(g.get("MY_LIST_VAR", "")): |
| 1586 | rblf.setdefault(handle, "PRODUCT_COPY_FILES") |
| 1587 | cfg["PRODUCT_COPY_FILES"] += ("foo/bar/%s:%s/etc/%s" % (x, g.get("TARGET_COPY_OUT_VENDOR", ""), x)).split() |
| 1588 | if g.get("MY_OTHER_VAR", ""): |
| 1589 | cfg["PRODUCT_COPY_FILES"] += ("%s:foo/bar/%s" % (g.get("MY_OTHER_VAR", ""), x)).split() |
Cole Faust | 2005298 | 2022-04-22 14:43:55 -0700 | [diff] [blame] | 1590 | for x in rblf.words(g.get("MY_LIST_VAR", "")): |
| 1591 | _entry = { |
| 1592 | "foo/font.mk": ("foo/font", _font_init), |
Cole Faust | 72374fc | 2022-05-05 11:45:04 -0700 | [diff] [blame] | 1593 | }.get("foo/%s.mk" % x) |
Cole Faust | 2005298 | 2022-04-22 14:43:55 -0700 | [diff] [blame] | 1594 | (_varmod, _varmod_init) = _entry if _entry else (None, None) |
| 1595 | if not _varmod_init: |
Cole Faust | 72374fc | 2022-05-05 11:45:04 -0700 | [diff] [blame] | 1596 | rblf.mkerror("product.mk", "Cannot find %s" % ("foo/%s.mk" % x)) |
Cole Faust | 2005298 | 2022-04-22 14:43:55 -0700 | [diff] [blame] | 1597 | _varmod_init(g, handle) |
Cole Faust | 7366042 | 2023-01-05 11:07:47 -0800 | [diff] [blame] | 1598 | # Check that we get as least close to correct line numbers for errors on statements inside evals |
| 1599 | rblf.mk2rbc_error("product.mk:17", "inherit-product/include argument is too complex") |
Cole Faust | f035d40 | 2022-03-28 14:02:50 -0700 | [diff] [blame] | 1600 | `, |
| 1601 | }, |
Cole Faust | 5d5fcc3 | 2022-04-26 18:02:05 -0700 | [diff] [blame] | 1602 | { |
| 1603 | desc: ".KATI_READONLY", |
| 1604 | mkname: "product.mk", |
| 1605 | in: ` |
| 1606 | MY_VAR := foo |
| 1607 | .KATI_READONLY := MY_VAR |
| 1608 | `, |
| 1609 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1610 | |
| 1611 | def init(g, handle): |
| 1612 | cfg = rblf.cfg(handle) |
| 1613 | g["MY_VAR"] = "foo" |
| 1614 | `, |
| 1615 | }, |
Cole Faust | 1323877 | 2022-04-28 14:29:57 -0700 | [diff] [blame] | 1616 | { |
| 1617 | desc: "Complicated variable references", |
| 1618 | mkname: "product.mk", |
| 1619 | in: ` |
| 1620 | MY_VAR := foo |
| 1621 | MY_VAR_2 := MY_VAR |
| 1622 | MY_VAR_3 := $($(MY_VAR_2)) |
| 1623 | MY_VAR_4 := $(foo bar) |
| 1624 | MY_VAR_5 := $($(MY_VAR_2) bar) |
| 1625 | `, |
| 1626 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1627 | |
| 1628 | def init(g, handle): |
| 1629 | cfg = rblf.cfg(handle) |
| 1630 | g["MY_VAR"] = "foo" |
| 1631 | g["MY_VAR_2"] = "MY_VAR" |
| 1632 | g["MY_VAR_3"] = (cfg).get(g["MY_VAR_2"], (g).get(g["MY_VAR_2"], "")) |
| 1633 | g["MY_VAR_4"] = rblf.mk2rbc_error("product.mk:5", "cannot handle invoking foo") |
| 1634 | g["MY_VAR_5"] = rblf.mk2rbc_error("product.mk:6", "reference is too complex: $(MY_VAR_2) bar") |
| 1635 | `, |
| 1636 | }, |
Cole Faust | d2daabf | 2022-12-12 17:38:01 -0800 | [diff] [blame] | 1637 | { |
| 1638 | desc: "Conditional functions", |
| 1639 | mkname: "product.mk", |
| 1640 | in: ` |
| 1641 | B := foo |
| 1642 | X := $(or $(A)) |
| 1643 | X := $(or $(A),$(B)) |
| 1644 | X := $(or $(A),$(B),$(C)) |
| 1645 | X := $(and $(A)) |
| 1646 | X := $(and $(A),$(B)) |
| 1647 | X := $(and $(A),$(B),$(C)) |
| 1648 | X := $(or $(A),$(B)) Y |
| 1649 | |
| 1650 | D := $(wildcard *.mk) |
| 1651 | X := $(or $(B),$(D)) |
| 1652 | `, |
| 1653 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1654 | |
| 1655 | def init(g, handle): |
| 1656 | cfg = rblf.cfg(handle) |
| 1657 | g["B"] = "foo" |
| 1658 | g["X"] = g.get("A", "") |
| 1659 | g["X"] = g.get("A", "") or g["B"] |
| 1660 | g["X"] = g.get("A", "") or g["B"] or g.get("C", "") |
| 1661 | g["X"] = g.get("A", "") |
| 1662 | g["X"] = g.get("A", "") and g["B"] |
| 1663 | g["X"] = g.get("A", "") and g["B"] and g.get("C", "") |
| 1664 | g["X"] = "%s Y" % g.get("A", "") or g["B"] |
| 1665 | g["D"] = rblf.expand_wildcard("*.mk") |
| 1666 | g["X"] = rblf.mk2rbc_error("product.mk:12", "Expected all arguments to $(or) or $(and) to have the same type, found \"string\" and \"list\"") |
| 1667 | `, |
| 1668 | }, |
Cole Faust | 2dee63d | 2022-12-12 18:11:00 -0800 | [diff] [blame] | 1669 | { |
| 1670 | |
| 1671 | desc: "is-lower/is-upper", |
| 1672 | mkname: "product.mk", |
| 1673 | in: ` |
| 1674 | X := $(call to-lower,aBc) |
| 1675 | X := $(call to-upper,aBc) |
| 1676 | X := $(call to-lower,$(VAR)) |
| 1677 | X := $(call to-upper,$(VAR)) |
| 1678 | `, |
| 1679 | expected: `load("//build/make/core:product_config.rbc", "rblf") |
| 1680 | |
| 1681 | def init(g, handle): |
| 1682 | cfg = rblf.cfg(handle) |
| 1683 | g["X"] = ("aBc").lower() |
| 1684 | g["X"] = ("aBc").upper() |
| 1685 | g["X"] = (g.get("VAR", "")).lower() |
| 1686 | g["X"] = (g.get("VAR", "")).upper() |
| 1687 | `, |
| 1688 | }, |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 1689 | } |
| 1690 | |
| 1691 | var known_variables = []struct { |
| 1692 | name string |
| 1693 | class varClass |
| 1694 | starlarkType |
| 1695 | }{ |
Cole Faust | f1f44d3 | 2021-11-16 14:52:12 -0800 | [diff] [blame] | 1696 | {"NATIVE_COVERAGE", VarClassSoong, starlarkTypeBool}, |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 1697 | {"PRODUCT_NAME", VarClassConfig, starlarkTypeString}, |
| 1698 | {"PRODUCT_MODEL", VarClassConfig, starlarkTypeString}, |
| 1699 | {"PRODUCT_PACKAGES", VarClassConfig, starlarkTypeList}, |
| 1700 | {"PRODUCT_BOOT_JARS", VarClassConfig, starlarkTypeList}, |
| 1701 | {"PRODUCT_COPY_FILES", VarClassConfig, starlarkTypeList}, |
| 1702 | {"PRODUCT_IS_64BIT", VarClassConfig, starlarkTypeString}, |
| 1703 | {"PRODUCT_LIST1", VarClassConfig, starlarkTypeList}, |
| 1704 | {"PRODUCT_LIST2", VarClassConfig, starlarkTypeList}, |
| 1705 | {"PRODUCT_LIST3", VarClassConfig, starlarkTypeList}, |
| 1706 | {"TARGET_PRODUCT", VarClassSoong, starlarkTypeString}, |
| 1707 | {"TARGET_BUILD_VARIANT", VarClassSoong, starlarkTypeString}, |
| 1708 | {"TARGET_BOARD_PLATFORM", VarClassSoong, starlarkTypeString}, |
| 1709 | {"QCOM_BOARD_PLATFORMS", VarClassSoong, starlarkTypeString}, |
| 1710 | {"PLATFORM_LIST", VarClassSoong, starlarkTypeList}, // TODO(asmundak): make it local instead of soong |
| 1711 | } |
| 1712 | |
Sasha Smundak | 6609ba7 | 2021-07-22 18:32:56 -0700 | [diff] [blame] | 1713 | type testMakefileFinder struct { |
| 1714 | fs fs.FS |
| 1715 | root string |
| 1716 | files []string |
| 1717 | } |
| 1718 | |
| 1719 | func (t *testMakefileFinder) Find(root string) []string { |
| 1720 | if t.files != nil || root == t.root { |
| 1721 | return t.files |
| 1722 | } |
| 1723 | t.files = make([]string, 0) |
| 1724 | fs.WalkDir(t.fs, root, func(path string, d fs.DirEntry, err error) error { |
| 1725 | if err != nil { |
| 1726 | return err |
| 1727 | } |
| 1728 | if d.IsDir() { |
| 1729 | base := filepath.Base(path) |
| 1730 | if base[0] == '.' && len(base) > 1 { |
| 1731 | return fs.SkipDir |
| 1732 | } |
| 1733 | return nil |
| 1734 | } |
| 1735 | if strings.HasSuffix(path, ".mk") { |
| 1736 | t.files = append(t.files, path) |
| 1737 | } |
| 1738 | return nil |
| 1739 | }) |
| 1740 | return t.files |
| 1741 | } |
| 1742 | |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 1743 | func TestGood(t *testing.T) { |
| 1744 | for _, v := range known_variables { |
| 1745 | KnownVariables.NewVariable(v.name, v.class, v.starlarkType) |
| 1746 | } |
Sasha Smundak | 6609ba7 | 2021-07-22 18:32:56 -0700 | [diff] [blame] | 1747 | fs := NewFindMockFS([]string{ |
| 1748 | "vendor/foo1/cfg.mk", |
| 1749 | "vendor/bar/baz/cfg.mk", |
| 1750 | "part.mk", |
| 1751 | "foo/font.mk", |
| 1752 | "bar/font.mk", |
| 1753 | }) |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 1754 | for _, test := range testCases { |
| 1755 | t.Run(test.desc, |
| 1756 | func(t *testing.T) { |
| 1757 | ss, err := Convert(Request{ |
Sasha Smundak | 422b614 | 2021-11-11 18:31:59 -0800 | [diff] [blame] | 1758 | MkFile: test.mkname, |
| 1759 | Reader: bytes.NewBufferString(test.in), |
Sasha Smundak | 422b614 | 2021-11-11 18:31:59 -0800 | [diff] [blame] | 1760 | OutputSuffix: ".star", |
| 1761 | SourceFS: fs, |
| 1762 | MakefileFinder: &testMakefileFinder{fs: fs}, |
Sasha Smundak | b051c4e | 2020-11-05 20:45:07 -0800 | [diff] [blame] | 1763 | }) |
| 1764 | if err != nil { |
| 1765 | t.Error(err) |
| 1766 | return |
| 1767 | } |
| 1768 | got := ss.String() |
| 1769 | if got != test.expected { |
| 1770 | t.Errorf("%q failed\nExpected:\n%s\nActual:\n%s\n", test.desc, |
| 1771 | strings.ReplaceAll(test.expected, "\n", "\n"), |
| 1772 | strings.ReplaceAll(got, "\n", "\n")) |
| 1773 | } |
| 1774 | }) |
| 1775 | } |
| 1776 | } |