blob: e7c1410a5f4d76a53abcf4c66856dd8f7ef21d1b [file] [log] [blame]
bigbiff673c7ae2020-12-02 19:44:56 -05001package libtwrp_defaults
2
3import (
4 "android/soong/android"
5 "android/soong/cc"
6 "fmt"
7 "path/filepath"
8)
9
10func globalFlags(ctx android.BaseContext) []string {
11 var cflags []string
12
13 if ctx.AConfig().Getenv("ARCH_ARM_HAVE_NEON") == "true" {
14 cflags = append(cflags, "-D__ARM_HAVE_NEON")
15 }
16 return cflags
17}
18
19func globalSrcs(ctx android.BaseContext) []string {
20 var srcs []string
21
22 matches, err := filepath.Glob("system/core/libpixelflinger/codeflinger/tinyutils/VectorImpl.cpp")
23 _ = matches
24 if err != nil {
25 srcs = append(srcs, "codeflinger/tinyutils/SharedBuffer.cpp")
26 srcs = append(srcs, "codeflinger/tinyutils/VectorImpl.cpp")
27 }
28
29 var arch = ctx.DeviceConfig().DeviceArch()
30 fmt.Println("arch: " + arch)
31
32 if arch != "x86" {
33 srcs = append(srcs, "codeflinger/ARMAssemblerInterface.cpp")
34 srcs = append(srcs, "codeflinger/ARMAssemblerProxy.cpp")
35 srcs = append(srcs, "codeflinger/GGLAssembler.cpp")
36 srcs = append(srcs, "codeflinger/load_store.cpp")
37 srcs = append(srcs, "codeflinger/blending.cpp")
38 srcs = append(srcs, "codeflinger/texturing.cpp")
39 srcs = append(srcs, "fixed.cpp")
40 srcs = append(srcs, "picker.cpp")
41 srcs = append(srcs, "pixelflinger.cpp")
42 srcs = append(srcs, "trap.cpp")
43 srcs = append(srcs, "scanline.cpp")
44 } else {
45 srcs = append(srcs, "codeflinger/x86/X86Assembler.cpp")
46 srcs = append(srcs, "codeflinger/x86/GGLX86Assembler.cpp")
47 srcs = append(srcs, "codeflinger/x86/load_store.cpp")
48 srcs = append(srcs, "codeflinger/x86/blending.cpp")
49 srcs = append(srcs, "codeflinger/x86/texturing.cpp")
50 srcs = append(srcs, "fixed.cpp")
51 srcs = append(srcs, "picker.cpp")
52 srcs = append(srcs, "pixelflinger.cpp")
53 srcs = append(srcs, "trap.cpp")
54 srcs = append(srcs, "scanline.cpp")
55 }
56
57 switch arch {
58 case "arm":
59 if ctx.AConfig().Getenv("ARCH_ARM_HAVE_NEON") == "true" {
60 srcs = append(srcs, "col32cb16blend_neon.S")
61 }
62 srcs = append(srcs, "codeflinger/ARMAssembler.cpp")
63 srcs = append(srcs, "codeflinger/disassem.c")
64 srcs = append(srcs, "col32cb16blend.S")
65 srcs = append(srcs, "t32cb16blend.S")
66 break
67 case "arm64":
68 srcs = append(srcs, "codeflinger/Arm64Assembler.cpp")
69 srcs = append(srcs, "codeflinger/Arm64Disassembler.cpp")
70 srcs = append(srcs, "arch-arm64/col32cb16blend.S")
71 srcs = append(srcs, "arch-arm64/t32cb16blend.S")
72 }
73 return srcs
74}
75
76func globalIncludes(ctx android.BaseContext) []string {
77 var includes []string
78
79 if ctx.AConfig().Getenv("TARGET_ARCH") == "arm" {
80 includes = append(includes, "external/libenc")
81 }
82
83 return includes
84}
85
86func libPixelflingerTwrpDefaults(ctx android.LoadHookContext) {
87 type props struct {
88 Target struct {
89 Android struct {
90 Cflags []string
91 Enabled *bool
92 }
93 }
94 Cflags []string
95 Srcs []string
96 Include_dirs []string
97 }
98
99 p := &props{}
100 p.Cflags = globalFlags(ctx)
101 s := globalSrcs(ctx)
102 p.Srcs = s
103 i := globalIncludes(ctx)
104 p.Include_dirs = i
105 ctx.AppendProperties(p)
106}
107
108func init() {
109 android.RegisterModuleType("libpixelflingertwrp_defaults", libPixelflingerTwrpDefaultsFactory)
110}
111
112func libPixelflingerTwrpDefaultsFactory() android.Module {
113 module := cc.DefaultsFactory()
114 android.AddLoadHook(module, libPixelflingerTwrpDefaults)
115
116 return module
117}