blob: 765814e37106054213596a05a9389e7fcda80f34 [file] [log] [blame]
bigbiff6e0ca7d2021-02-06 19:15:16 -05001package twrp
bigbiff673c7ae2020-12-02 19:44:56 -05002
3import (
4 "android/soong/android"
5 "android/soong/cc"
6)
7
8func globalFlags(ctx android.BaseContext) []string {
9 var cflags []string
10
bigbiff6e0ca7d2021-02-06 19:15:16 -050011 if getMakeVars(ctx, "AB_OTA_UPDATER") == "true" {
bigbiff673c7ae2020-12-02 19:44:56 -050012 cflags = append(cflags, "-DAB_OTA_UPDATER=1")
13 }
14 return cflags
15}
16
17func globalSrcs(ctx android.BaseContext) []string {
18 var srcs []string
19
bigbiff6e0ca7d2021-02-06 19:15:16 -050020 if getMakeVars(ctx, "TWRP_CUSTOM_KEYBOARD") != "" {
21 srcs = append(srcs, getMakeVars(ctx, "TWRP_CUSTOM_KEYBOARD"))
bigbiff673c7ae2020-12-02 19:44:56 -050022 }
23
24 return srcs
25}
26
27func globalIncludes(ctx android.BaseContext) []string {
28 var includes []string
29
bigbiff6e0ca7d2021-02-06 19:15:16 -050030 if getMakeVars(ctx, "TW_INCLUDE_CRYPTO") != "" {
bigbiff673c7ae2020-12-02 19:44:56 -050031 includes = append(includes, "bootable/recovery/crypto/fscrypt")
32 }
33
34 return includes
35}
36
37func libAospRecoveryDefaults(ctx android.LoadHookContext) {
38 type props struct {
39 Target struct {
40 Android struct {
41 Cflags []string
42 Enabled *bool
43 }
44 }
45 Cflags []string
46 Srcs []string
47 Include_dirs []string
48 }
49
50 p := &props{}
51 p.Cflags = globalFlags(ctx)
52 s := globalSrcs(ctx)
53 p.Srcs = s
54 i := globalIncludes(ctx)
55 p.Include_dirs = i
56 ctx.AppendProperties(p)
57}
58
59func init() {
60 android.RegisterModuleType("libaosprecovery_defaults", libAospRecoveryDefaultsFactory)
61}
62
63func libAospRecoveryDefaultsFactory() android.Module {
64 module := cc.DefaultsFactory()
65 android.AddLoadHook(module, libAospRecoveryDefaults)
66
67 return module
68}