bigbiff | a957f07 | 2021-03-07 18:20:29 -0500 | [diff] [blame] | 1 | package twrp |
| 2 | |
| 3 | import ( |
| 4 | "android/soong/android" |
| 5 | "android/soong/cc" |
| 6 | ) |
| 7 | |
| 8 | func globalFlags(ctx android.BaseContext) []string { |
| 9 | var cflags []string |
| 10 | |
| 11 | if getMakeVars(ctx, "AB_OTA_UPDATER") == "true" { |
| 12 | cflags = append(cflags, "-DAB_OTA_UPDATER=1") |
| 13 | } |
bigbiff | a957f07 | 2021-03-07 18:20:29 -0500 | [diff] [blame] | 14 | return cflags |
| 15 | } |
| 16 | |
| 17 | func globalSrcs(ctx android.BaseContext) []string { |
| 18 | var srcs []string |
| 19 | |
| 20 | if getMakeVars(ctx, "TWRP_CUSTOM_KEYBOARD") != "" { |
| 21 | srcs = append(srcs, getMakeVars(ctx, "TWRP_CUSTOM_KEYBOARD")) |
| 22 | } |
| 23 | |
| 24 | return srcs |
| 25 | } |
| 26 | |
bigbiff | a957f07 | 2021-03-07 18:20:29 -0500 | [diff] [blame] | 27 | func libAospRecoveryDefaults(ctx android.LoadHookContext) { |
| 28 | type props struct { |
| 29 | Target struct { |
| 30 | Android struct { |
| 31 | Cflags []string |
| 32 | Enabled *bool |
| 33 | } |
| 34 | } |
| 35 | Cflags []string |
| 36 | Srcs []string |
| 37 | Include_dirs []string |
| 38 | } |
| 39 | |
| 40 | p := &props{} |
| 41 | p.Cflags = globalFlags(ctx) |
| 42 | s := globalSrcs(ctx) |
| 43 | p.Srcs = s |
bigbiff | a957f07 | 2021-03-07 18:20:29 -0500 | [diff] [blame] | 44 | ctx.AppendProperties(p) |
| 45 | } |
| 46 | |
| 47 | func init() { |
| 48 | android.RegisterModuleType("libaosprecovery_defaults", libAospRecoveryDefaultsFactory) |
| 49 | } |
| 50 | |
| 51 | func libAospRecoveryDefaultsFactory() android.Module { |
| 52 | module := cc.DefaultsFactory() |
| 53 | android.AddLoadHook(module, libAospRecoveryDefaults) |
| 54 | |
| 55 | return module |
| 56 | } |