1# Interface library
2cc_library(
3    name = "aemu-base-headers",
4    hdrs = glob([
5        "include/**/*.h",
6        "include/**/*.hpp",
7    ]),
8    defines = select({
9        "@platforms//os:windows": [
10            "WIN32_LEAN_AND_MEAN",
11        ],
12        "//conditions:default": [],
13    }),
14    includes = ["include"],
15    visibility = ["//visibility:public"],
16    deps = [
17        "//hardware/google/aemu/host-common:aemu-host-common-headers",
18        "@com_google_absl//absl/strings:str_format",
19    ],
20)
21
22cc_library(
23    name = "aemu-base-metrics",
24    srcs = ["Metrics.cpp"],
25    visibility = ["//visibility:public"],
26    deps = [":aemu-base-headers"],
27)
28
29cc_library(
30    name = "aemu-base-allocator",
31    srcs = ["SubAllocator.cpp"],
32    visibility = ["//visibility:public"],
33    deps = [":aemu-base-headers"],
34)
35
36objc_library(
37    name = "aemu-base-darwin",
38    srcs = [
39        "system-native-mac.mm",
40    ],
41    sdk_frameworks = [
42        "IOkit",
43        "AppKit",
44    ],
45    deps = [":aemu-base-headers"],
46    alwayslink = True,
47)
48
49cc_library(
50    name = "aemu-base",
51    srcs = [
52        "AlignedBuf.cpp",
53        "CLog.cpp",
54        "CompressingStream.cpp",
55        "CpuTime.cpp",
56        "DecompressingStream.cpp",
57        "FileUtils.cpp",
58        "FunctorThread.cpp",
59        "GLObjectCounter.cpp",
60        "HealthMonitor.cpp",
61        "LayoutResolver.cpp",
62        "MemStream.cpp",
63        "MemoryTracker.cpp",
64        "MessageChannel.cpp",
65        "PathUtils.cpp",
66        "SharedLibrary.cpp",
67        "StdioStream.cpp",
68        "Stream.cpp",
69        "StreamSerializing.cpp",
70        "StringFormat.cpp",
71        "SubAllocator.cpp",
72        "System.cpp",
73        "Tracing.cpp",
74        "ring_buffer.cpp",
75    ] + select({
76        "@platforms//os:windows": [
77            "SharedMemory_win32.cpp",
78            "Thread_win32.cpp",
79            "Win32UnicodeString.cpp",
80            "msvc.cpp",
81        ],
82        "@platforms//os:macos": [
83            "SharedMemory_posix.cpp",
84            "Thread_pthread.cpp",
85        ],
86        "@platforms//os:linux": [
87            "SharedMemory_posix.cpp",
88            "Thread_pthread.cpp",
89        ],
90    }),
91    defines = [
92        "BUILDING_EMUGL_COMMON_SHARED",
93        "LOGGING_API_SHARED",
94    ] + select({
95        "@platforms//os:windows": [
96            "WIN32_LEAN_AND_MEAN",
97        ],
98        "//conditions:default": [],
99    }),
100    linkopts = select({
101        "@platforms//os:linux": [
102            "-ldl",
103            "-lrt",
104        ],
105        "@platforms//os:windows": [
106            "-DEFAULTLIB:Shlwapi.lib",
107        ],
108        "@platforms//os:macos": [
109            "-framework Foundation",
110            "-framework AppKit",
111            "-framework IOKit",
112        ],
113        "//conditions:default": [],
114    }),
115    visibility = ["//visibility:public"],
116    deps = [
117        ":aemu-base-headers",
118        ":aemu-base-metrics",
119        "//external/lz4",
120        "//hardware/google/aemu/host-common:logging",
121    ] + select({
122        "@platforms//os:macos": [
123            ":aemu-base-darwin",
124        ],
125        "//conditions:default": [],
126    }),
127)
128
129cc_test(
130    name = "aemu-base_unittests",
131    srcs = [
132        "AlignedBuf_unittest.cpp",
133        "ArraySize_unittest.cpp",
134        "HealthMonitor_unittest.cpp",
135        "HybridEntityManager_unittest.cpp",
136        "LayoutResolver_unittest.cpp",
137        "LruCache_unittest.cpp",
138        "ManagedDescriptor_unittest.cpp",
139        "NoDestructor_unittest.cpp",
140        "Optional_unittest.cpp",
141        "StringFormat_unittest.cpp",
142        "SubAllocator_unittest.cpp",
143        "TypeTraits_unittest.cpp",
144        "WorkerThread_unittest.cpp",
145        "ring_buffer_unittest.cpp",
146        "testing/file_io.cpp",
147    ] + select({
148        "@platforms//os:windows": ["Win32UnicodeString_unittest.cpp"],
149        "//conditions:default": [],
150    }),
151    deps = [
152        ":aemu-base",
153        ":aemu-base-headers",
154        "//hardware/google/aemu/base:aemu-base-darwin",
155        "//hardware/google/aemu/base:aemu-base-metrics",
156        "//hardware/google/aemu/host-common:logging",
157        "@com_google_absl//absl/log",
158        "@com_google_absl//absl/strings",
159        "@com_google_absl//absl/strings:str_format",
160        "@com_google_googletest//:gtest_main",
161    ],
162)
163