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 | } |
| 14 | |
| 15 | if getMakeVars(ctx, "TW_USE_FSCRYPT_POLICY") == "1" { |
| 16 | cflags = append(cflags, "-DUSE_FSCRYPT_POLICY_V1") |
| 17 | } else { |
| 18 | cflags = append(cflags, "-DUSE_FSCRYPT_POLICY_V2") |
| 19 | } |
| 20 | return cflags |
| 21 | } |
| 22 | |
| 23 | func globalSrcs(ctx android.BaseContext) []string { |
| 24 | var srcs []string |
| 25 | |
| 26 | if getMakeVars(ctx, "TWRP_CUSTOM_KEYBOARD") != "" { |
| 27 | srcs = append(srcs, getMakeVars(ctx, "TWRP_CUSTOM_KEYBOARD")) |
| 28 | } |
| 29 | |
| 30 | return srcs |
| 31 | } |
| 32 | |
bigbiff | a957f07 | 2021-03-07 18:20:29 -0500 | [diff] [blame] | 33 | func libAospRecoveryDefaults(ctx android.LoadHookContext) { |
| 34 | type props struct { |
| 35 | Target struct { |
| 36 | Android struct { |
| 37 | Cflags []string |
| 38 | Enabled *bool |
| 39 | } |
| 40 | } |
| 41 | Cflags []string |
| 42 | Srcs []string |
| 43 | Include_dirs []string |
| 44 | } |
| 45 | |
| 46 | p := &props{} |
| 47 | p.Cflags = globalFlags(ctx) |
| 48 | s := globalSrcs(ctx) |
| 49 | p.Srcs = s |
bigbiff | a957f07 | 2021-03-07 18:20:29 -0500 | [diff] [blame] | 50 | ctx.AppendProperties(p) |
| 51 | } |
| 52 | |
| 53 | func init() { |
| 54 | android.RegisterModuleType("libaosprecovery_defaults", libAospRecoveryDefaultsFactory) |
| 55 | } |
| 56 | |
| 57 | func libAospRecoveryDefaultsFactory() android.Module { |
| 58 | module := cc.DefaultsFactory() |
| 59 | android.AddLoadHook(module, libAospRecoveryDefaults) |
| 60 | |
| 61 | return module |
| 62 | } |