blob: 442f1e488e83a5ff4e72c9367d375ae4ec0e78b0 [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
33func globalIncludes(ctx android.BaseContext) []string {
34 var includes []string
35
36 if getMakeVars(ctx, "TW_INCLUDE_CRYPTO") != "" {
37 includes = append(includes, "bootable/recovery/crypto/fscrypt")
38 }
39
40 return includes
41}
42
43func libAospRecoveryDefaults(ctx android.LoadHookContext) {
44 type props struct {
45 Target struct {
46 Android struct {
47 Cflags []string
48 Enabled *bool
49 }
50 }
51 Cflags []string
52 Srcs []string
53 Include_dirs []string
54 }
55
56 p := &props{}
57 p.Cflags = globalFlags(ctx)
58 s := globalSrcs(ctx)
59 p.Srcs = s
60 i := globalIncludes(ctx)
61 p.Include_dirs = i
62 ctx.AppendProperties(p)
63}
64
65func init() {
66 android.RegisterModuleType("libaosprecovery_defaults", libAospRecoveryDefaultsFactory)
67}
68
69func libAospRecoveryDefaultsFactory() android.Module {
70 module := cc.DefaultsFactory()
71 android.AddLoadHook(module, libAospRecoveryDefaults)
72
73 return module
74}