blob: 1289ffaca94a818ed857f0ccb5075be49474c31c [file] [log] [blame]
bigbiffa957f072021-03-07 18:20:29 -05001package twrp
2
3import (
4 "android/soong/android"
5 "android/soong/cc"
6)
7
8func 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
23func 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
bigbiffa957f072021-03-07 18:20:29 -050033func 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
bigbiffa957f072021-03-07 18:20:29 -050050 ctx.AppendProperties(p)
51}
52
53func init() {
54 android.RegisterModuleType("libaosprecovery_defaults", libAospRecoveryDefaultsFactory)
55}
56
57func libAospRecoveryDefaultsFactory() android.Module {
58 module := cc.DefaultsFactory()
59 android.AddLoadHook(module, libAospRecoveryDefaults)
60
61 return module
62}