bigbiff | 673c7ae | 2020-12-02 19:44:56 -0500 | [diff] [blame] | 1 | package liba_defaults
|
| 2 |
|
| 3 | import (
|
| 4 | "android/soong/android"
|
| 5 | "android/soong/cc"
|
| 6 | )
|
| 7 |
|
| 8 | func 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 |
|
| 17 | func 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 |
|
| 27 | func 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 |
|
| 37 | func 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 |
|
| 59 | func init() {
|
| 60 | android.RegisterModuleType("libaosprecovery_defaults", libAospRecoveryDefaultsFactory)
|
| 61 | }
|
| 62 |
|
| 63 | func libAospRecoveryDefaultsFactory() android.Module {
|
| 64 | module := cc.DefaultsFactory()
|
| 65 | android.AddLoadHook(module, libAospRecoveryDefaults)
|
| 66 |
|
| 67 | return module
|
| 68 | }
|