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