blob: 209a65d8065cfb948c5ea5d8c5bee255597275fd [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 }
bigbiffa957f072021-03-07 18:20:29 -050014 return cflags
15}
16
17func globalSrcs(ctx android.BaseContext) []string {
18 var srcs []string
19
20 if getMakeVars(ctx, "TWRP_CUSTOM_KEYBOARD") != "" {
21 srcs = append(srcs, getMakeVars(ctx, "TWRP_CUSTOM_KEYBOARD"))
22 }
23
24 return srcs
25}
26
bigbiffa957f072021-03-07 18:20:29 -050027func libAospRecoveryDefaults(ctx android.LoadHookContext) {
28 type props struct {
29 Target struct {
30 Android struct {
31 Cflags []string
32 Enabled *bool
33 }
34 }
35 Cflags []string
36 Srcs []string
37 Include_dirs []string
38 }
39
40 p := &props{}
41 p.Cflags = globalFlags(ctx)
42 s := globalSrcs(ctx)
43 p.Srcs = s
bigbiffa957f072021-03-07 18:20:29 -050044 ctx.AppendProperties(p)
45}
46
47func init() {
48 android.RegisterModuleType("libaosprecovery_defaults", libAospRecoveryDefaultsFactory)
49}
50
51func libAospRecoveryDefaultsFactory() android.Module {
52 module := cc.DefaultsFactory()
53 android.AddLoadHook(module, libAospRecoveryDefaults)
54
55 return module
56}