ronnie
2022-10-23 cb8ede114f8c3e5ead5b294f66344b8a42004745
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
package sanitizer_status
 
import (
   "android/soong/android"
   "android/soong/cc"
)
 
func init() {
   android.RegisterModuleType("sanitizer_status_library_shared",
       libraryFactory)
}
 
func libraryFactory() android.Module {
   module := cc.LibrarySharedFactory()
   android.AddLoadHook(module, loadHook)
   return module
}
 
func loadHook(ctx android.LoadHookContext) {
   type props struct {
       Cflags []string
   }
 
   p := &props{}
 
   sanitizers := ctx.Config().SanitizeDevice()
 
   if android.InList("address", sanitizers) {
       p.Cflags = append(p.Cflags, "-DANDROID_SANITIZE_ADDRESS=1")
   }
   if android.InList("hwaddress", sanitizers) {
       p.Cflags = append(p.Cflags, "-DANDROID_SANITIZE_HWADDRESS=1")
   }
   if android.InList("coverage", sanitizers) {
       p.Cflags = append(p.Cflags, "-DANDROID_SANITIZE_COVERAGE=1")
   }
 
   ctx.AppendProperties(p)
}