hc
2024-08-12 233ab1bd4c5697f5cdec94e60206e8c6ac609b4c
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
package rkaiqdefaults
 
import (
   "android/soong/android"
   "android/soong/cc"
    "fmt"   // required if we want to print usefull messages on the console
    "os"
)
 
func rkaiqFlags(ctx android.BaseContext) []string {
    var cflags []string
    //fmt.Fprintf(os.Stderr, "%s\n", "deviceFlags called") //example prints
    //fmt.Fprintf(os.Stderr, "%s\n", ctx.AConfig())
    board := ctx.Config().Getenv("TARGET_BOARD_PLATFORM") //currently using this for reference but you can refer to README for other variables.
    fmt.Fprintf(os.Stderr, ">>>>>>>>>>>>>>>>>>>>> %s\n", board)
    if board == "rv1126" {
       cflags = append(cflags, "-DISP_HW_V20")
    }
    if board == "rk356x" {
       cflags = append(cflags, "-DISP_HW_V21")
    }
    if board == "rk3588" {
       cflags = append(cflags, "-DISP_HW_V30")
    }
    return cflags
}
 
func rkaiqDefaults(ctx android.LoadHookContext) {
    type props struct {
        Target struct {
            Android struct {
                Cflags  []string
                Enabled *bool
            }
            Host struct {
                Enabled *bool
            }
            Not_windows struct {
                Cflags []string
            }
        }
        Cflags []string
    }
    p := &props{}
 
    //p.Cflags = deviceFlags(ctx)
    p.Target.Android.Cflags = rkaiqFlags(ctx)
    ctx.AppendProperties(p)
}
 
/* This is called from the boot strap process
 * We register a module here
*/
func init() {
    android.RegisterModuleType("rkaiq_defaults", rkaiqDefaultFactory)
}
 
func rkaiqDefaultFactory() android.Module {
    module := cc.DefaultsFactory()
    android.AddLoadHook(module, rkaiqDefaults)
    return module
}