<div dir="ltr"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr"><div style="font-size:12.8px"><div style="color:rgb(136,136,136);font-size:12.8px"><div style="font-size:small"><div style="color:rgb(34,34,34)"><font face="arial, helvetica, sans-serif" color="#000000">Hello all,</font></div><div style="color:rgb(34,34,34)"><font face="arial, helvetica, sans-serif" color="#000000"><br></font></div><div style="color:rgb(34,34,34)"><font face="arial, helvetica, sans-serif" color="#000000">TL;DR: I would propose adding a top-level Android.bp Bazel-based build and tests to support building libcamera inline with AOSP to expose the libcamera HAL.</font></div><div style="color:rgb(34,34,34)"><font face="arial, helvetica, sans-serif" color="#000000"><br></font></div><div style="color:rgb(34,34,34)"><font face="arial, helvetica, sans-serif" color="#000000"><b>Short intro because I'm new</b> (feel free to skip):</font></div><div style="color:rgb(34,34,34)"><font face="arial, helvetica, sans-serif" color="#000000">I'm Nicholas, a long-time amateur programmer with ~10 years of industry experience now, although it doesn't seem like it's been that long. I've published work in distributed scale-out systems and for the last ~6 years, I've worked in AI. More relevant to you all, I have free time and a phone with an RK3399 SoC that I'd like to get supported in Waydroid.</font></div><div style="color:rgb(34,34,34)"><font face="arial, helvetica, sans-serif" color="#000000"><br></font></div><div style="color:rgb(34,34,34)"><font face="arial, helvetica, sans-serif" color="#000000"><b>Background</b>:</font></div><div style="color:rgb(34,34,34)"><font face="arial, helvetica, sans-serif" color="#000000">There's been back-and-forth discussion on Kieran's personal GitHub account (link: </font><span style="font-size:12.8px"><font color="#000000"><a href="https://mailtrack.io/trace/link/9c70a621d6594480c04ab3722218fff2dec55196?notrack=1&url=https%3A%2F%2Fgithub.com%2Fkbingham%2Flibcamera%2Fpull%2F26&userId=4192442&signature=13231078163330ff" target="_blank">https://github.com/kbingham/libcamera/pull/26</a>) about how to potentially build libcamera inline with AOSP. If I understand correctly, the original contributor proposed some minor changes and also a major change that would add ~349 lines of Makefiles, including a deprecated Android.mk. The original contributor ran out of bandwidth recently and decided not to pursue their changes further, and I volunteered to carry this forward.</font></span></div><div style="color:rgb(34,34,34)"><span style="font-size:12.8px"><font color="#000000"><br></font></span></div><div style="color:rgb(34,34,34)"><span style="font-size:12.8px"><font color="#000000"><b>My Prior Work</b></font></span></div><div style="color:rgb(34,34,34)"><span style="font-size:12.8px"><font color="#000000">I have tried building libcamera with these proposed changes inline with AOSP using sdk 30 under "/external/libcamera" (full procedure link: </font></span><span style="font-size:12.8px"><a href="https://mailtrack.io/trace/link/e6ac3150dcbfa009e3880aa030d8176036dc2199?notrack=1&url=https%3A%2F%2Fdocs.google.com%2Fdocument%2Fd%2F1Sly_VH3w6wFIdE72WXijQegoHZh8IxEnJ9m0hH7GodU%2Fedit&userId=4192442&signature=abdf0877da91078c" target="_blank">https://docs.google.com/document/d/1Sly_VH3w6wFIdE72WXijQegoHZh8IxEnJ9m0hH7GodU/edit</a>) and it does not work as intended as far as I can tell. Specifically, /vendor/lib/hw/<a href="https://mailtrack.io/trace/link/f38ddeb643e9e502355e6d6c7078c4f678867495?url=http%3A%2F%2Fcamera.libcamera.so%2F&userId=4192442&signature=f3a416f93f49123b" target="_blank">camera.libcamera.so</a> does not get bundled into the Android images. This may be user error on my part, however.</span></div><div style="color:rgb(34,34,34)"><span style="font-size:12.8px"><br></span></div><div style="color:rgb(34,34,34)"><span style="font-size:12.8px"><b>Options for AOSP Inline Build</b></span></div><div style="color:rgb(34,34,34)"><span style="font-size:12.8px">The way I can see, we have at least these options for building libcamera inline with AOSP. Personally, parallel build systems (see below) seems like the best option to me. Please feel free to jump in if I'm wrong about any of this or if you have options to add:</span></div><div style="color:rgb(34,34,34)"><ul><li style="margin-left:15px"><span style="font-size:12.8px">Transition libcamera to Soong and build intuitively<br>Tradeoffs: Simplest and most consistent option, but potentially very disruptive</span></li><li style="margin-left:15px"><span style="font-size:12.8px">Invoke Meson from Soong with a genrule, akin to what <a href="https://mailtrack.io/trace/link/8b8bf21362b7febf0a481b5bf274ad86d982180e?url=http%3A%2F%2Fmeson_cross.mk%2F&userId=4192442&signature=c34c1a84f1c76a29" target="_blank">meson_cross.mk</a> does<br>Tradeoffs: </span>complex-- I would be happy to do this but I'll need help understanding how <a href="https://mailtrack.io/trace/link/35387558b6d890dee771bdbfb1f7bf8f6132b75f?url=http%3A%2F%2Fmeson_cross.mk%2F&userId=4192442&signature=dfc9af2da8b37fa2" target="_blank">meson_cross.mk</a> works; probably harder than writing <a href="https://mailtrack.io/trace/link/fecb2bde4cbf9c1d4e4afb58415434f6bf142167?url=http%3A%2F%2Fmeson_cross.mk%2F&userId=4192442&signature=3458951a34f69bc0" target="_blank">meson_cross.mk</a> was; possibly infeasible since Soong is quite opinionated</li><li style="margin-left:15px"><span style="font-size:12.8px"><b>Parallel build systems</b>-- Create an Android.bp file that would live at the top-level of the libcamer repo in addition to the existing Meson files. We would use Soong for Android, and Meson for other use-cases.<br>Tradeoffs: Less complex and less error-prone than invoking Meson from Soong, and less disruptive than moving to Soong exclusively, but would incur an increased maintenance burden compared to doing nothing or using a single build system.<br></span></li><li style="margin-left:15px"><span style="font-size:12.8px">Android.mk-- Use a legacy (link: <a href="https://mailtrack.io/trace/link/a590ddf9d4e0fc2459ff68e2943bcb5feb034056?notrack=1&url=https%3A%2F%2Fsource.android.com%2Fdocs%2Fsetup%2Fbuild&userId=4192442&signature=124f558360d74d95" target="_blank">https://source.android.com/docs/setup/build</a>) Android.mk file and figure out how to get the proposed Android.mk and <a href="https://mailtrack.io/trace/link/b47795745b452c00239c6966c5fabd90e9ff7a07?url=http%3A%2F%2Fmeson_cross.mk%2F&userId=4192442&signature=1528cb5f2f1cd6c7" target="_blank">meson_cross.mk</a> files working and tested.<br>Tradeoffs: New code would depend on a legacy tool and Makefiles can be error-prone and hard to read (not great), but the maintenance burden <i>might</i> be lower than creating a parallel Android.bp build file.<br></span></li></ul><div><span style="font-size:12.8px"><b>Test Plan</b></span></div><div><span style="font-size:12.8px">I'm not exactly sure how the libcamera community approaches testing. That said, I would write a sanity check based on </span><a href="https://mailtrack.io/trace/link/566af31c86d4ae27635d28c2f28a21e50ddd700b?notrack=1&url=https%3A%2F%2Fsource.android.com%2Fdocs%2Fcore%2Ftests%2Fdevelopment%2Fblueprints&userId=4192442&signature=76612081ac230acc" target="_blank">https://source.android.com/docs/core/tests/development/blueprints</a>. Ideally, we would agree to run this before submitting new code. This is probably the weakest part of my proposal, and I'd love any resources on libcamera's testing philosophy and thoughts on how to make this stronger.</div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><b>Next Steps</b></span></div><div><span style="font-size:12.8px">If this looks good to the community (parallel build systems option), I'll figure out how to make Android.bp work. Most likely though, we have more to discuss. I'm ready to hear your thoughts!</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thanks,</span></div><div><span style="font-size:12.8px">-Nicholas</span></div></div></div></div></div></div></div></div></div><img width="0" height="0" class="mailtrack-img" alt="" style="display:flex" src="https://mailtrack.io/trace/mail/323388653becc9f26e042b5326e2272a3151a2a6.png?u=4192442"></div>