package libtwrp_defaults | |
import ( | |
"android/soong/android" | |
"android/soong/cc" | |
"fmt" | |
"path/filepath" | |
) | |
func globalFlags(ctx android.BaseContext) []string { | |
var cflags []string | |
if ctx.AConfig().Getenv("ARCH_ARM_HAVE_NEON") == "true" { | |
cflags = append(cflags, "-D__ARM_HAVE_NEON") | |
} | |
return cflags | |
} | |
func globalSrcs(ctx android.BaseContext) []string { | |
var srcs []string | |
matches, err := filepath.Glob("system/core/libpixelflinger/codeflinger/tinyutils/VectorImpl.cpp") | |
_ = matches | |
if err != nil { | |
srcs = append(srcs, "codeflinger/tinyutils/SharedBuffer.cpp") | |
srcs = append(srcs, "codeflinger/tinyutils/VectorImpl.cpp") | |
} | |
var arch = ctx.DeviceConfig().DeviceArch() | |
fmt.Println("arch: " + arch) | |
if arch != "x86" { | |
srcs = append(srcs, "codeflinger/ARMAssemblerInterface.cpp") | |
srcs = append(srcs, "codeflinger/ARMAssemblerProxy.cpp") | |
srcs = append(srcs, "codeflinger/GGLAssembler.cpp") | |
srcs = append(srcs, "codeflinger/load_store.cpp") | |
srcs = append(srcs, "codeflinger/blending.cpp") | |
srcs = append(srcs, "codeflinger/texturing.cpp") | |
srcs = append(srcs, "fixed.cpp") | |
srcs = append(srcs, "picker.cpp") | |
srcs = append(srcs, "pixelflinger.cpp") | |
srcs = append(srcs, "trap.cpp") | |
srcs = append(srcs, "scanline.cpp") | |
} else { | |
srcs = append(srcs, "codeflinger/x86/X86Assembler.cpp") | |
srcs = append(srcs, "codeflinger/x86/GGLX86Assembler.cpp") | |
srcs = append(srcs, "codeflinger/x86/load_store.cpp") | |
srcs = append(srcs, "codeflinger/x86/blending.cpp") | |
srcs = append(srcs, "codeflinger/x86/texturing.cpp") | |
srcs = append(srcs, "fixed.cpp") | |
srcs = append(srcs, "picker.cpp") | |
srcs = append(srcs, "pixelflinger.cpp") | |
srcs = append(srcs, "trap.cpp") | |
srcs = append(srcs, "scanline.cpp") | |
} | |
switch arch { | |
case "arm": | |
if ctx.AConfig().Getenv("ARCH_ARM_HAVE_NEON") == "true" { | |
srcs = append(srcs, "col32cb16blend_neon.S") | |
} | |
srcs = append(srcs, "codeflinger/ARMAssembler.cpp") | |
srcs = append(srcs, "codeflinger/disassem.c") | |
srcs = append(srcs, "col32cb16blend.S") | |
srcs = append(srcs, "t32cb16blend.S") | |
break | |
case "arm64": | |
srcs = append(srcs, "codeflinger/Arm64Assembler.cpp") | |
srcs = append(srcs, "codeflinger/Arm64Disassembler.cpp") | |
srcs = append(srcs, "arch-arm64/col32cb16blend.S") | |
srcs = append(srcs, "arch-arm64/t32cb16blend.S") | |
} | |
return srcs | |
} | |
func globalIncludes(ctx android.BaseContext) []string { | |
var includes []string | |
if ctx.AConfig().Getenv("TARGET_ARCH") == "arm" { | |
includes = append(includes, "external/libenc") | |
} | |
return includes | |
} | |
func libPixelflingerTwrpDefaults(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("libpixelflingertwrp_defaults", libPixelflingerTwrpDefaultsFactory) | |
} | |
func libPixelflingerTwrpDefaultsFactory() android.Module { | |
module := cc.DefaultsFactory() | |
android.AddLoadHook(module, libPixelflingerTwrpDefaults) | |
return module | |
} |