olvaffe / percetto

Apache License 2.0
19 stars 10 forks source link

CMake-based build and build-to-AAR support #26

Open rpavlik opened 2 years ago

rpavlik commented 2 years ago

For ease of integration with Gradle, etc. I had put together this CMake-based build. This builds on #17 (which turned out to still be necessary - it looks like it varies by platform for ndk builds). Thanks to @utzcoz I was able to drop the other patches from this PR.

This also gives you the ability to build AAR files with "prefab" metadata so they can be consumed by Gradle-based Android projects, with just ./build-aar.sh .

rpavlik commented 2 years ago

OK, this is all ready to go. Let me know if you need the copyright/license statements adjusted, I just went with my default which is CC0-1.0 for "meaningless"/"basically config" files, and BSL-1.0 (more or less maximally permissive) for the other added files, all with SPDX tags. If it simplifies the process of getting this mainlined, though, I can modify the license statements to the more restrictive apache-2.0 for integration's sake.

BTW - This also provides the ability to create a "prefab" AAR file for use with Gradle-built NDK apps. You could push these (in CI or otherwise) to the GitHub packages repo, or maven central, or elsewhere at your option.

rpavlik commented 2 years ago

One minor question: Since 0.1.6, should the percetto lib be build as a shared library rather than static, always?

rpavlik commented 2 years ago

OK, now it's a shared library and it can also be used from another CMake project easily, regardless of whether that cmake project is being run by Gradle in an android build, or a desktop linux build.

utzcoz commented 2 years ago

@rpavlik your work is so awesome. Really hope this PR can be merged, and we can get percetto aar with prefab support for complicated native Android project.

utzcoz commented 2 years ago

Friendly ping @olvaffe @batesj . The AAR for percetto is very important for Android's native app to trace important steps with tracked timestamp. The tracing APIs I found at NDK are limited to me. Could you help take look at @rpavlik 's PR. I really want to this feature too. Thanks.

batesj commented 2 years ago

Hi @rpavlik, a couple questions below. Also we want to keep in mind that an official perfetto C API is in the works, so perCetto is more of an interim library.

Generally I am not a fan of maintaining multiple build systems for projects as one or the other build files tend to regress. No way to build the aar with meson?

For NDK usage, why not use the C++ perfetto SDK directly?

rpavlik commented 2 years ago

Oh interesting, glad to hear there's an official C API coming.

I have not looked into building an AAR with Meson - it's not a supported build system for Android so it would be a lot of work. (The AAR with CMake even was a lot of work, since the aar-authoring things in android gradle plugin don't work quite right so the scripts are basically hand-assembling the AAR. Fortunately I had recently done an AAR for another CMake based project so I already had some open source code for it, that is known and tested good.)

In NDK usage: We're building a cross-platform app that has a strong C-first bias (particularly in inter-module APIs), which is why we went with perCetto.

Is there any known timeline for the official C api? (Should we just be vendoring this project for now?)