blob: 608942bdbac251ce592fa0060c202238207a7938 [file] [log] [blame]
bigbiff673c7ae2020-12-02 19:44:56 -05001package liba_defaults
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 ctx.AConfig().Getenv("AB_OTA_UPDATER") == "true" {
12 cflags = append(cflags, "-DAB_OTA_UPDATER=1")
13 }
14 return cflags
15}
16
17func globalSrcs(ctx android.BaseContext) []string {
18 var srcs []string
19
20 if ctx.AConfig().Getenv("TWRP_CUSTOM_KEYBOARD") != "" {
21 srcs = append(srcs, ctx.AConfig().Getenv("TWRP_CUSTOM_KEYBOARD"))
22 }
23
24 return srcs
25}
26
27func globalIncludes(ctx android.BaseContext) []string {
28 var includes []string
29
30 if ctx.AConfig().Getenv("TW_INCLUDE_CRYPTO") != "" {
31 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}