forked from TeamWin/android_bootable_recovery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
libaosprecovery_defaults.go
74 lines (59 loc) · 1.49 KB
/
libaosprecovery_defaults.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package twrp
import (
"android/soong/android"
"android/soong/cc"
)
func globalFlags(ctx android.BaseContext) []string {
var cflags []string
if getMakeVars(ctx, "AB_OTA_UPDATER") == "true" {
cflags = append(cflags, "-DAB_OTA_UPDATER=1")
}
if getMakeVars(ctx, "TW_USE_FSCRYPT_POLICY") == "1" {
cflags = append(cflags, "-DUSE_FSCRYPT_POLICY_V1")
} else {
cflags = append(cflags, "-DUSE_FSCRYPT_POLICY_V2")
}
return cflags
}
func globalSrcs(ctx android.BaseContext) []string {
var srcs []string
if getMakeVars(ctx, "TWRP_CUSTOM_KEYBOARD") != "" {
srcs = append(srcs, getMakeVars(ctx, "TWRP_CUSTOM_KEYBOARD"))
}
return srcs
}
func globalIncludes(ctx android.BaseContext) []string {
var includes []string
if getMakeVars(ctx, "TW_INCLUDE_CRYPTO") != "" {
includes = append(includes, "bootable/recovery/crypto/fscrypt")
}
return includes
}
func libAospRecoveryDefaults(ctx android.LoadHookContext) {
type props struct {
Target struct {
Android struct {
Cflags []string
Enabled *bool
}
}
Cflags []string
Srcs []string
Include_dirs []string
}
p := &props{}
p.Cflags = globalFlags(ctx)
s := globalSrcs(ctx)
p.Srcs = s
i := globalIncludes(ctx)
p.Include_dirs = i
ctx.AppendProperties(p)
}
func init() {
android.RegisterModuleType("libaosprecovery_defaults", libAospRecoveryDefaultsFactory)
}
func libAospRecoveryDefaultsFactory() android.Module {
module := cc.DefaultsFactory()
android.AddLoadHook(module, libAospRecoveryDefaults)
return module
}