Sam Mortimer | b45bdc6 | 2019-09-08 15:54:55 +0200 | [diff] [blame] | 1 | package generator |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | |
| 6 | "android/soong/android" |
| 7 | ) |
| 8 | |
| 9 | func omniromExpandVariables(ctx android.ModuleContext, in string) string { |
| 10 | omniromVars := ctx.Config().VendorConfig("omniromVarsPlugin") |
| 11 | |
| 12 | out, err := android.Expand(in, func(name string) (string, error) { |
| 13 | if omniromVars.IsSet(name) { |
| 14 | return omniromVars.String(name), nil |
| 15 | } |
| 16 | // This variable is not for us, restore what the original |
| 17 | // variable string will have looked like for an Expand |
| 18 | // that comes later. |
| 19 | return fmt.Sprintf("$(%s)", name), nil |
| 20 | }) |
| 21 | |
| 22 | if err != nil { |
| 23 | ctx.PropertyErrorf("%s: %s", in, err.Error()) |
| 24 | return "" |
| 25 | } |
| 26 | |
| 27 | return out |
| 28 | } |