blob: 8abec95e58c2a5d93b9e2cb45db3aef1312c639a [file] [log] [blame]
bigbiff673c7ae2020-12-02 19:44:56 -05001package libgui_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("TW_DELAY_TOUCH_INIT_MS") != "" {
12 cflags = append(cflags, "-DTW_DELAY_TOUCH_INIT_MS="+ctx.AConfig().Getenv("TW_DELAY_TOUCH_INIT_MS"))
13 }
14
15 if ctx.AConfig().Getenv("TW_EVENT_LOGGING") == "true" {
16 cflags = append(cflags, "-D_EVENT_LOGGING")
17 }
18
19 if ctx.AConfig().Getenv("TW_USE_KEY_CODE_TOUCH_SYNC") != "" {
20 cflags = append(cflags, "DTW_USE_KEY_CODE_TOUCH_SYNC="+ctx.AConfig().Getenv("TW_USE_KEY_CODE_TOUCH_SYNC"))
21 }
22
23 if ctx.AConfig().Getenv("TW_OZIP_DECRYPT_KEY") != "" {
24 cflags = append(cflags, "-DTW_OZIP_DECRYPT_KEY=\""+ctx.AConfig().Getenv("TW_OZIP_DECRYPT_KEY")+"\"")
25 } else {
26 cflags = append(cflags, "-DTW_OZIP_DECRYPT_KEY=0")
27 }
28
29 if ctx.AConfig().Getenv("TW_NO_SCREEN_BLANK") != "" {
30 cflags = append(cflags, "-DTW_NO_SCREEN_BLANK")
31 }
32
33 if ctx.AConfig().Getenv("TW_NO_SCREEN_TIMEOUT") != "" {
34 cflags = append(cflags, "-DTW_NO_SCREEN_TIMEOUT")
35 }
36
37 if ctx.AConfig().Getenv("TW_OEM_BUILD") != "" {
38 cflags = append(cflags, "-DTW_OEM_BUILD")
39 }
40
41 if ctx.AConfig().Getenv("TW_X_OFFSET") != "" {
42 cflags = append(cflags, "-DTW_X_OFFSET="+ctx.AConfig().Getenv("TW_X_OFFSET"))
43 }
44
45 if ctx.AConfig().Getenv("TW_Y_OFFSET") != "" {
46 cflags = append(cflags, "-DTW_Y_OFFSET="+ctx.AConfig().Getenv("TW_Y_OFFSET"))
47 }
48
49 if ctx.AConfig().Getenv("TW_W_OFFSET") != "" {
50 cflags = append(cflags, "-DTW_W_OFFSET="+ctx.AConfig().Getenv("TW_W_OFFSET"))
51 }
52
53 if ctx.AConfig().Getenv("TW_H_OFFSET") != "" {
54 cflags = append(cflags, "-DTW_H_OFFSET="+ctx.AConfig().Getenv("TW_H_OFFSET"))
55 }
56
57 if ctx.AConfig().Getenv("TW_ROUND_SCREEN") == "true" {
58 cflags = append(cflags, "-DTW_ROUND_SCREEN")
59 }
60
61 cflags = append(cflags, "-DTWRES=\""+ctx.AConfig().Getenv("TWRES_PATH")+"\"")
62
63 return cflags
64}
65
66func globalSrcs(ctx android.BaseContext) []string {
67 var srcs []string
68
69 if ctx.AConfig().Getenv("TWRP_CUSTOM_KEYBOARD") != "" {
70 srcs = append(srcs, ctx.AConfig().Getenv("TWRP_CUSTOM_KEYBOARD"))
71 } else {
72 srcs = append(srcs, "hardwarekeyboard.cpp")
73 }
74 return srcs
75}
76
77func globalIncludes(ctx android.BaseContext) []string {
78 var includes []string
79
80 if ctx.AConfig().Getenv("TW_INCLUDE_CRYPTO") != "" {
81 includes = append(includes, "bootable/recovery/crypto/fscrypt")
82 }
83
84 return includes
85}
86
87func libGuiDefaults(ctx android.LoadHookContext) {
88 type props struct {
89 Target struct {
90 Android struct {
91 Cflags []string
92 Enabled *bool
93 }
94 }
95 Cflags []string
96 Srcs []string
97 Include_dirs []string
98 }
99
100 p := &props{}
101 p.Cflags = globalFlags(ctx)
102 s := globalSrcs(ctx)
103 p.Srcs = s
104 i := globalIncludes(ctx)
105 p.Include_dirs = i
106 ctx.AppendProperties(p)
107}
108
109func init() {
110 android.RegisterModuleType("libguitwrp_defaults", libGuiDefaultsFactory)
111}
112
113func libGuiDefaultsFactory() android.Module {
114 module := cc.DefaultsFactory()
115 android.AddLoadHook(module, libGuiDefaults)
116
117 return module
118}