blob: e8ac4960a060c821c26eaf917c01993abb827aa1 [file] [log] [blame]
Sam Mortimerb45bdc62019-09-08 15:54:55 +02001package generator
2
3import (
4 "fmt"
5
6 "android/soong/android"
7)
8
9func 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}