Page MenuHomePhabricator

[native] add corrosion to android cmake project
ClosedPublic

Authored by varun on Aug 11 2022, 10:14 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Jul 2, 12:19 AM
Unknown Object (File)
Sun, Jun 30, 10:23 PM
Unknown Object (File)
Sun, Jun 30, 4:53 AM
Unknown Object (File)
Sat, Jun 29, 7:34 PM
Unknown Object (File)
Sat, Jun 29, 2:35 PM
Unknown Object (File)
Wed, Jun 26, 2:30 AM
Unknown Object (File)
Wed, Jun 26, 2:30 AM
Unknown Object (File)
Wed, Jun 26, 2:30 AM

Details

Summary

add corrosion to the CMakeLists.txt file with find_package

Depends on D4820

Test Plan

successfully built the android app

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

varun held this revision as a draft.

yarn react-native run-android fails with the following error:

> java.io.IOException: Cannot run program "/Users/varun/Library/Android/sdk/cmake/3.10.2.4988404/bin/cmake": error=2, No such file or directory

I'm not sure what exactly is still expecting the older version of Cmake. I changed my Cmake to 3.18 using the SDK manager and modified the minimum version in the CMakeLists.txt file. Clearly missing something

reduce diff scope. successfully added corrosion to the Android Cmake project

varun published this revision for review.Aug 15 2022, 8:26 AM
varun retitled this revision from [native] add grpc client library to android to [native] add corrosion to android cmake project.
varun edited the summary of this revision. (Show Details)
varun edited the test plan for this revision. (Show Details)

also made some formatting changes based off my IDE's suggestions

jon requested changes to this revision.Aug 15 2022, 8:33 AM

otherwise LGTM

native/android/app/CMakeLists.txt
204 ↗(On Diff #15615)

these new lines are a bit odd

This revision now requires changes to proceed.Aug 15 2022, 8:33 AM

adding ashoat since I'm making a docs change

Awesome, we were able to bump CMake for the Android build? I thought @jon had indicated that there was some issue there, but I don't have context. Tracked in ENG-1548, so we should make sure to close that out after we land this.

I thought @jon had indicated that there was some issue there, but I don't have context.

When I went to do the android installation, it only gave me the default choice of 3.10. But looks like they have added more (or somehow there was more when varun attempted to change it). Specifying a version allows you to opt-in to a more recent version.

This revision is now accepted and ready to land.Aug 15 2022, 1:05 PM
CMake Error at CMakeLists.txt:41 (find_package):
Could not find a package configuration file provided by "Corrosion" with
any of the following names:

You will likely need to modify the android docker image to install corrosion, or somehow install it.

There's already a services/tunnelbroker/docker/install_corrosion.sh which does this, but there's not a corresponding android Dockerfile for us to modify.

Looks like the android CI inherits from reactnativecommunity/react-native-android:latest, so not sure if we want to build our own, or just add another command to install it before calling the underlying gradle build. cc @atul @max

jon requested changes to this revision.Aug 15 2022, 1:15 PM

Another option would be to remove the find_package(corrosion) for now, since nothing else in the diff requires it, and moving it to a new diff.

Just going to request changes, as this will break CI as-is; although there's nothing inherently wrong with the CMake changes but rather the environment which uses it.

This revision now requires changes to proceed.Aug 15 2022, 1:15 PM

Can we continue to use the same approach as native/android/app/build.gradle to install dependencies?

use FetchContent instead of find_package

In D4821#139850, @atul wrote:

Can we continue to use the same approach as native/android/app/build.gradle to install dependencies?

This doesn't work because Corrosion does not support the same installation method as those other dependencies

This doesn't work because Corrosion does not support the same installation method as those other dependencies

Could you specify what exactly is not supported? As far as I understand, these deps just require downloading them and preparing the sources for building (should work with corrosion but have not tried it).

Main concern was android CI, and it's passing.

This revision is now accepted and ready to land.Aug 18 2022, 7:44 AM
In D4821#141009, @karol wrote:

This doesn't work because Corrosion does not support the same installation method as those other dependencies

Could you specify what exactly is not supported? As far as I understand, these deps just require downloading them and preparing the sources for building (should work with corrosion but have not tried it).

"This doesn't work" wasn't exactly accurate on my part... we can add some new groovy dependencies and turn these steps into a gradle task, but it seemed unnecessarily complicated when FetchContent just works. I'm going to land this as is, but if there's a strong argument for the gradle approach I can create a backlog task.

but it seemed unnecessarily complicated when FetchContent just works

Personally would strongly argue for using FetchContent throughout the Android build (now that we're on CMake > 3.14) and avoid the Gradle approach altogether.

Personally would strongly argue for using FetchContent throughout the Android build (now that we're on CMake > 3.14) and avoid the Gradle approach altogether.

I second this as well. Less implicit knowledge having to be shared between two tools.

native/android/app/CMakeLists.txt
46

Can we put up a quick diff to use the commit hash here instead?

Where contents are being fetched from a remote location and you do not control that server, it is advisable to use a hash for GIT_TAG rather than a branch or tag name. A commit hash is more secure and helps to confirm that the downloaded contents are what you expected.
(https://cmake.org/cmake/help/latest/module/FetchContent.html#command:fetchcontent_declare)