blob: be13420990a5ef1ddea15808e7136c92dbe48814 [file] [log] [blame]
Yabin Cuie1deac52018-01-23 15:04:44 -08001//
2// Copyright (C) 2018 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17cc_defaults {
18 name: "simpleperf_defaults",
19
20 cflags: [
21 "-Wall",
22 "-Wextra",
23 "-Werror",
George Burgess IVda078442018-08-13 22:41:12 -070024 "-Wimplicit-fallthrough",
Yabin Cuie1deac52018-01-23 15:04:44 -080025
26 // Try some more extreme warnings.
27 "-Wpedantic",
28 "-Wunreachable-code-aggressive",
29 // And disable some dumb things.
30 "-Wno-zero-length-array",
31 "-Wno-c99-extensions",
32 "-Wno-language-extension-token",
33 "-Wno-gnu-zero-variadic-macro-arguments",
34 "-Wno-nested-anon-types",
35 "-Wno-gnu-statement-expression",
36 "-Wno-vla-extension",
Yabin Cuie1deac52018-01-23 15:04:44 -080037 ],
38 cppflags: [
39 "-Wno-sign-compare",
40 "-Wno-unused-parameter",
41 ],
42}
43
Andreas Gampeb0172702018-09-17 13:33:02 -070044cc_defaults {
45 name: "libsimpleperf_elf_read_static_reqs_defaults",
46 static_libs: [
47 "libLLVMObject",
48 "libLLVMBitReader",
49 "libLLVMMC",
50 "libLLVMMCParser",
51 "libLLVMCore",
52 "libLLVMSupport",
53 "liblzma",
54 "libz",
55 "libziparchive",
56 ],
Yabin Cuif6e5e0a2019-01-22 10:54:13 -080057 target: {
58 // Required for LLVM.
Yabin Cui17eff8d2019-01-31 11:52:19 -080059 darwin: {
60 host_ldlibs: [
61 "-lncurses",
62 ],
63 },
Yabin Cuif6e5e0a2019-01-22 10:54:13 -080064 linux_glibc: {
65 host_ldlibs: [
66 "-lncurses",
67 ],
68 },
69 },
Andreas Gampeb0172702018-09-17 13:33:02 -070070}
71
Yabin Cuie1deac52018-01-23 15:04:44 -080072cc_library_static {
73 name: "libsimpleperf_elf_read",
74 defaults: [
75 "simpleperf_defaults",
Andreas Gampeb0172702018-09-17 13:33:02 -070076 "libsimpleperf_elf_read_static_reqs_defaults",
Yabin Cuie1deac52018-01-23 15:04:44 -080077 ],
Andreas Gampe98d04ad2018-03-08 13:49:27 -080078 host_supported: true,
Yabin Cuie1deac52018-01-23 15:04:44 -080079
80 export_include_dirs: [
81 ".",
82 ],
83
Yabin Cuie1deac52018-01-23 15:04:44 -080084 static_libs: [
85 "libbase",
86 ],
Yabin Cuie1deac52018-01-23 15:04:44 -080087
Yabin Cuie1deac52018-01-23 15:04:44 -080088 srcs: [
89 "read_apk.cpp",
90 "read_elf.cpp",
91 "utils.cpp",
92 ],
93
94 group_static_libs: true,
Yabin Cuif6e5e0a2019-01-22 10:54:13 -080095 use_version_lib: true,
Andreas Gampe98d04ad2018-03-08 13:49:27 -080096}
Andreas Gampea3b752c2018-09-18 19:25:24 -070097
98cc_defaults {
99 name: "libsimpleperf_dex_read_static_reqs_defaults",
100 defaults: ["libdexfile_static_defaults"],
Martin Stjernholm7c27cc22018-11-28 00:46:00 +0000101 static_libs: [
Martin Stjernholm401e6d92019-02-20 16:58:42 +0000102 "libdexfile_support_static",
Martin Stjernholm7c27cc22018-11-28 00:46:00 +0000103 ],
104 header_libs: ["libdexfile_external_headers"],
105 export_header_lib_headers: ["libdexfile_external_headers"],
Andreas Gampea3b752c2018-09-18 19:25:24 -0700106}
107
108cc_library_static {
109 name: "libsimpleperf_dex_read",
110 defaults: [
111 "simpleperf_defaults",
112 "libsimpleperf_dex_read_static_reqs_defaults",
113 ],
114 host_supported: true,
115
116 export_include_dirs: [
117 ".",
118 ],
119
Andreas Gampea3b752c2018-09-18 19:25:24 -0700120 static_libs: ["libbase"],
121
122 srcs: [
123 "read_dex_file.cpp",
124 ],
125
126 group_static_libs: true,
127}
Yabin Cui4192f462019-01-17 15:10:51 -0800128
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800129cc_defaults {
130 name: "simpleperf_cflags",
131 target: {
132 host: {
133 cflags: [
134 "-DUSE_BIONIC_UAPI_HEADERS",
135 "-fvisibility=hidden"
136 ],
137 include_dirs: ["bionic/libc/kernel"],
138 },
139 darwin: {
140 cflags: ["-DNO_LIBDEXFILE_SUPPORT"],
141 local_include_dirs: ["nonlinux_support/include"],
142 },
143 windows: {
144 cflags: ["-DNO_LIBDEXFILE_SUPPORT"],
145 local_include_dirs: ["nonlinux_support/include"],
146 }
147 },
148}
149
150cc_defaults {
151 name: "simpleperf_static_libs",
152 defaults: [
153 "libsimpleperf_elf_read_static_reqs_defaults",
154 "simpleperf_cflags",
155 ],
156 host_supported: true,
157 static_libs: [
158 "libbase",
159 "liblog",
160 "libutils",
161 "libprotobuf-cpp-lite",
162 ],
163 target: {
164 linux: {
165 static_libs: [
166 "libunwindstack",
Martin Stjernholm401e6d92019-02-20 16:58:42 +0000167 "libdexfile_support_static",
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800168 "libcutils",
169 "libprocinfo",
170 "libevent",
171 ],
172 },
173 android: {
174 static_libs: [
175 "libc",
176 ],
177 },
178 host: {
179 stl: "libc++_static",
180 },
181 windows: {
182 enabled: true,
183 },
184 },
185 use_version_lib: true,
186}
187
188cc_defaults {
189 name: "simpleperf_shared_libs",
190 defaults: [
191 "simpleperf_cflags",
192 ],
193 host_supported: true,
194 shared_libs: [
195 "libbase",
196 "liblzma",
197 "libprotobuf-cpp-lite",
198 "libziparchive",
199 ],
200 target: {
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800201 linux: {
202 shared_libs: [
203 "libcutils",
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800204 "libdexfile_support",
205 "libevent",
206 "libprocinfo",
207 "libunwindstack",
208 ],
209 },
Yabin Cui17eff8d2019-01-31 11:52:19 -0800210 darwin: {
211 host_ldlibs: [
212 "-lncurses",
213 ],
214 },
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800215 linux_glibc: {
216 host_ldlibs: [
217 "-lncurses",
218 ],
219 },
220 host: {
221 static_libs: [
222 "libLLVMObject",
223 "libLLVMBitReader",
224 "libLLVMMC",
225 "libLLVMMCParser",
226 "libLLVMCore",
227 "libLLVMSupport",
228 ],
229 },
230 windows: {
231 enabled: true,
232 },
233 },
234 use_version_lib: true,
235}
236
237cc_defaults {
Yabin Cuibcbffab2019-02-27 10:53:16 -0800238 name: "simpleperf_libs_for_tests",
239 defaults: ["simpleperf_shared_libs"],
240 target: {
241 android: {
242 // 32-bit libLLVM_android isn't shipped on device. So use static llvm libs in tests.
243 static_libs: [
244 "libLLVMObject",
245 "libLLVMBitReader",
246 "libLLVMMC",
247 "libLLVMMCParser",
248 "libLLVMCore",
249 "libLLVMSupport",
250 ],
251 },
252 },
253}
254
255cc_defaults {
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800256 name: "libsimpleperf_srcs",
257 srcs: [
Yabin Cui4192f462019-01-17 15:10:51 -0800258 "cmd_dumprecord.cpp",
259 "cmd_help.cpp",
Yabin Cui4192f462019-01-17 15:10:51 -0800260 "cmd_kmem.cpp",
Yabin Cui4192f462019-01-17 15:10:51 -0800261 "cmd_report.cpp",
262 "cmd_report_sample.cpp",
Yabin Cui4192f462019-01-17 15:10:51 -0800263 "command.cpp",
264 "dso.cpp",
Yabin Cui4192f462019-01-17 15:10:51 -0800265 "event_attr.cpp",
Yabin Cui4192f462019-01-17 15:10:51 -0800266 "event_type.cpp",
Yabin Cui4192f462019-01-17 15:10:51 -0800267 "perf_regs.cpp",
268 "read_apk.cpp",
Yabin Cui4192f462019-01-17 15:10:51 -0800269 "read_elf.cpp",
270 "record.cpp",
271 "record_file_reader.cpp",
Yabin Cui4192f462019-01-17 15:10:51 -0800272 "report_sample.proto",
273 "thread_tree.cpp",
274 "tracing.cpp",
Yabin Cui4192f462019-01-17 15:10:51 -0800275 "utils.cpp",
Yabin Cui4192f462019-01-17 15:10:51 -0800276 ],
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800277 target: {
278 linux: {
279 srcs: [
280 "CallChainJoiner.cpp",
Yabin Cui1befe4f2019-02-25 15:22:43 -0800281 "cmd_api.cpp",
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800282 "cmd_debug_unwind.cpp",
283 "cmd_list.cpp",
284 "cmd_record.cpp",
285 "cmd_stat.cpp",
286 "cmd_trace_sched.cpp",
287 "environment.cpp",
288 "event_fd.cpp",
289 "event_selection_set.cpp",
290 "InplaceSamplerClient.cpp",
291 "IOEventLoop.cpp",
292 "JITDebugReader.cpp",
293 "OfflineUnwinder.cpp",
294 "read_dex_file.cpp",
295 "record_file_writer.cpp",
296 "RecordReadThread.cpp",
297 "UnixSocket.cpp",
298 "workload.cpp",
299 ],
300 },
301 darwin: {
302 srcs: ["nonlinux_support/nonlinux_support.cpp"],
303 },
304 windows: {
305 srcs: ["nonlinux_support/nonlinux_support.cpp"],
306 },
307 },
308}
309
310cc_library_static {
311 name: "libsimpleperf",
312 defaults: [
313 "libsimpleperf_srcs",
314 "simpleperf_static_libs",
Yabin Cui4192f462019-01-17 15:10:51 -0800315 ],
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800316 compile_multilib: "both",
317 proto: {
318 type: "lite",
319 },
320 static_libs: [
321 "libbuildversion",
322 ],
323 use_version_lib: false,
324}
325
326// simpleperf shipped in system image
327cc_binary {
328 name: "simpleperf",
329 defaults: [
330 "simpleperf_shared_libs",
331 ],
332 host_supported: false,
333 srcs: [
334 "main.cpp",
335 ],
336 static_libs: ["libsimpleperf"],
Yabin Cuibcbffab2019-02-27 10:53:16 -0800337 target: {
338 android: {
339 shared_libs: [
340 "libLLVM_android",
341 ],
342 },
343 },
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800344}
345
346// simpleperf released in ndk
347cc_binary {
348 name: "simpleperf_ndk",
349 defaults: [
350 "simpleperf_static_libs",
351 ],
352 dist: {
Elliott Hughesd435d362019-04-02 13:00:55 -0700353 targets: ["sdk", "win_sdk", "simpleperf"],
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800354 },
355 srcs: [
356 "main.cpp",
357 ],
358 static_libs: [
359 "libsimpleperf",
360 ],
361
362 compile_multilib: "both",
363 multilib: {
364 lib64: {
365 suffix: "64",
366 },
367 },
368
369 target: {
370 android: {
371 static_executable: true,
372 },
373 android_arm: {
374 dist: {
375 dir: "simpleperf/android/arm",
376 },
377 },
378 android_arm64: {
379 dist: {
380 dir: "simpleperf/android/arm64",
381 },
382 },
383 android_x86: {
384 dist: {
385 dir: "simpleperf/android/x86",
386 },
387 },
388 android_x86_64: {
389 dist: {
390 dir: "simpleperf/android/x86_64",
391 },
392 },
393 darwin: {
394 dist: {
395 dir: "simpleperf/darwin/x86",
396 },
397 },
398 darwin_x86_64: {
399 dist: {
400 dir: "simpleperf/darwin/x86_64",
401 },
402 },
403 linux_glibc_x86: {
404 dist: {
405 dir: "simpleperf/linux/x86",
406 },
407 },
408 linux_glibc_x86_64: {
409 dist: {
410 dir: "simpleperf/linux/x86_64",
411 },
412 },
413 windows_x86: {
414 dist: {
415 dir: "simpleperf/windows/x86",
416 },
417 },
418 windows_x86_64: {
419 dist: {
420 dir: "simpleperf/windows/x86_64",
421 },
422 },
423 },
424}
425
426// It's linked to user's program, to get profile counters and samples for specific code ranges.
427cc_library {
428 name: "libsimpleperf_record",
429 defaults: [
430 "simpleperf_static_libs",
431 ],
432 export_include_dirs: ["include"],
433 ldflags: ["-Wl,--exclude-libs,ALL"],
434 srcs: [
435 "record_lib_interface.cpp",
436 ],
437 static_libs: [
438 "libsimpleperf"
439 ],
440 target: {
441 darwin: {
442 enabled: false,
443 },
444 windows: {
445 enabled: false,
446 },
447 },
448}
449
450// It's the shared library used on host by python scripts to report samples in different ways.
451cc_library_shared {
452 name: "libsimpleperf_report",
453 defaults: [
454 "simpleperf_static_libs",
455 ],
456 dist: {
Elliott Hughesd435d362019-04-02 13:00:55 -0700457 targets: ["sdk", "win_sdk", "simpleperf"],
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800458 },
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800459 srcs: [
460 "report_lib_interface.cpp",
461 ],
462 static_libs: ["libsimpleperf"],
463
464 target: {
465 android: {
466 enabled: false,
467 },
Yabin Cui15fc25d2019-01-30 11:03:40 -0800468 linux: {
469 ldflags: ["-Wl,--exclude-libs,ALL"],
470 },
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800471 darwin: {
472 dist: {
473 dir: "simpleperf/darwin/x86",
474 },
475 },
476 darwin_x86_64: {
477 dist: {
478 dir: "simpleperf/darwin/x86_64",
479 },
480 },
481 linux_glibc_x86: {
482 dist: {
483 dir: "simpleperf/linux/x86",
484 },
485 },
486 linux_glibc_x86_64: {
487 dist: {
488 dir: "simpleperf/linux/x86_64",
489 },
490 },
491 windows_x86: {
492 dist: {
493 dir: "simpleperf/windows/x86",
494 },
495 },
496 windows_x86_64: {
497 dist: {
498 dir: "simpleperf/windows/x86_64",
499 },
500 },
501 },
502}
503
504// It's the shared library linked with user's app and get samples from signal handlers in each
505// thread. Doesn't work yet.
506cc_library_shared {
507 name: "libsimpleperf_inplace_sampler",
508 defaults: [
509 "simpleperf_static_libs",
510 ],
511 export_include_dirs: ["include"],
512 ldflags: ["-Wl,--exclude-libs,ALL"],
513 srcs: [
514 "inplace_sampler_lib.cpp",
515 ],
516 static_libs: ["libsimpleperf"],
517 target: {
518 darwin: {
519 enabled: false,
520 },
521 windows: {
522 enabled: false,
523 },
524 },
525}
526
527cc_defaults {
528 name: "simpleperf_test_srcs",
529 srcs: [
530 "cmd_kmem_test.cpp",
531 "cmd_report_test.cpp",
532 "cmd_report_sample_test.cpp",
533 "command_test.cpp",
534 "dso_test.cpp",
535 "gtest_main.cpp",
536 "read_apk_test.cpp",
537 "read_elf_test.cpp",
538 "record_test.cpp",
539 "sample_tree_test.cpp",
540 "thread_tree_test.cpp",
541 "utils_test.cpp",
542 ],
543 target: {
544 linux: {
545 srcs: [
546 "CallChainJoiner_test.cpp",
547 "cmd_debug_unwind_test.cpp",
548 "cmd_dumprecord_test.cpp",
549 "cmd_list_test.cpp",
550 "cmd_record_test.cpp",
551 "cmd_stat_test.cpp",
552 "cmd_trace_sched_test.cpp",
553 "environment_test.cpp",
554 "IOEventLoop_test.cpp",
555 "read_dex_file_test.cpp",
556 "record_file_test.cpp",
557 "RecordReadThread_test.cpp",
558 "UnixSocket_test.cpp",
559 "workload_test.cpp",
560 ],
561 },
562 },
563}
564
565cc_test {
566 name: "simpleperf_unit_test",
567 defaults: [
568 "simpleperf_test_srcs",
Yabin Cuibcbffab2019-02-27 10:53:16 -0800569 "simpleperf_libs_for_tests",
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800570 ],
571 static_libs: [
572 "libgmock",
573 "libsimpleperf"
574 ],
575 target: {
576 android: {
577 test_suites: ["device-tests"],
578 },
579 },
580 data: [
581 "testdata/**/*",
582 ],
583}
584
585cc_test {
586 name: "simpleperf_cpu_hotplug_test",
587 defaults: [
Yabin Cuibcbffab2019-02-27 10:53:16 -0800588 "simpleperf_libs_for_tests",
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800589 ],
590 srcs: [
591 "cpu_hotplug_test.cpp",
592 ],
593 static_libs: ["libsimpleperf"],
594 target: {
595 android: {
596 test_suites: ["device-tests"],
597 },
598 darwin: {
599 enabled: false,
600 },
601 windows: {
602 enabled: false,
603 },
604 },
605}
606
607cc_library_static {
608 name: "libsimpleperf_cts_test",
609 defaults: [
610 "simpleperf_test_srcs",
Yabin Cuibcbffab2019-02-27 10:53:16 -0800611 "simpleperf_libs_for_tests",
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800612 ],
613 host_supported: false,
614 cflags: [
Yabin Cuia24cf962019-01-29 17:06:42 -0800615 "-DIN_CTS_TEST",
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800616 ],
617 static_libs: [
618 "libgtest",
619 ],
620 whole_static_libs: [
621 "libgmock",
622 "libsimpleperf",
623 ],
624}
625
626cc_test {
627 name: "simpleperf_record_test",
628 defaults: [
Yabin Cuibcbffab2019-02-27 10:53:16 -0800629 "simpleperf_libs_for_tests",
Yabin Cuif6e5e0a2019-01-22 10:54:13 -0800630 ],
631 srcs: [
632 "record_lib_test.cpp",
633 ],
634 shared_libs: ["libsimpleperf_record"],
635 target: {
636 android: {
637 test_suites: ["device-tests"],
638 },
639 darwin: {
640 enabled: false,
641 },
642 windows: {
643 enabled: false,
644 },
645 },
Martin Stjernholm31eb7a02019-01-24 15:38:49 +0000646}