Page MenuHomePhabricator

CMakeLists.txt changes to compile native rust library on android
ClosedPublic

Authored by varun on Sep 20 2022, 2:43 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jan 2, 8:48 PM
Unknown Object (File)
Mon, Dec 30, 10:14 AM
Unknown Object (File)
Sun, Dec 29, 1:11 AM
Unknown Object (File)
Sun, Dec 29, 1:11 AM
Unknown Object (File)
Sun, Dec 29, 1:11 AM
Unknown Object (File)
Sun, Dec 29, 1:11 AM
Unknown Object (File)
Sun, Dec 29, 1:11 AM
Unknown Object (File)
Sun, Dec 29, 1:11 AM

Details

Summary

This differential introduces changes necessary to compile native rust library on Android

Test Plan

Build android app

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Update message, remove blob client from include directories

Harbormaster returned this revision to the author for changes because remote builds failed.Sep 20 2022, 2:57 AM
Harbormaster failed remote builds in B12301: Diff 16888!

Install rust target platforms

Harbormaster returned this revision to the author for changes because remote builds failed.Sep 20 2022, 6:19 AM
Harbormaster failed remote builds in B12315: Diff 16903!
Harbormaster returned this revision to the author for changes because remote builds failed.Sep 20 2022, 6:46 AM
Harbormaster failed remote builds in B12317: Diff 16908!
Harbormaster returned this revision to the author for changes because remote builds failed.Sep 20 2022, 6:58 AM
Harbormaster failed remote builds in B12318: Diff 16909!
varun edited reviewers, added: marcin; removed: varun.

add env var to CMakeLists.txt to help cargo locate the correct archiver

built the android app successfully in nix and normal environment

Harbormaster returned this revision to the author for changes because remote builds failed.Oct 13 2022, 11:24 AM
Harbormaster failed remote builds in B12777: Diff 17549!

the prebuilt NDK binaries are in a different location on linux machines. this change should resolve the CI issues.

Harbormaster returned this revision to the author for changes because remote builds failed.Oct 13 2022, 2:05 PM
Harbormaster failed remote builds in B12784: Diff 17557!
Harbormaster returned this revision to the author for changes because remote builds failed.Oct 13 2022, 3:09 PM
Harbormaster failed remote builds in B12788: Diff 17562!
Harbormaster returned this revision to the author for changes because remote builds failed.Oct 18 2022, 2:05 PM
Harbormaster failed remote builds in B12857: Diff 17647!

fix case sensitivity issue on CI machine

Harbormaster returned this revision to the author for changes because remote builds failed.Oct 18 2022, 2:31 PM
Harbormaster failed remote builds in B12859: Diff 17649!
varun requested review of this revision.Oct 18 2022, 6:21 PM

clean up a little now that everything works

native/android/app/CMakeLists.txt
43–51 ↗(On Diff #17653)

Rust_CARGO_TARGET is used by Corrosion

53 ↗(On Diff #17653)

the path to the archiver is case sensitive, so we convert the system name to lowercase (e.g. Darwin -> darwin)

54 ↗(On Diff #17653)

This is a path so it's difficult to split across multiple lines. There are a bunch of lines in this file that exceed 80 characters so I'm assuming we're not applying that rule as strictly here

native/android/app/build.gradle
503 ↗(On Diff #17653)

Make the NDK Version available in CMake

marcin requested changes to this revision.Oct 19 2022, 3:09 AM

Changes look good to me. Just a quick question - when I was compiling android locally I had to include "native_rust_library/src/lib.rs.h" instead of "lib.rs.h" in C++. this would cause discrepancy between iOS and android. @varun did you try to include lib.rs.h in c++ file with changes from this diff? In the meantime I will try to compile android with this diff locally to see which header needs to be included.

This revision now requires changes to proceed.Oct 19 2022, 3:09 AM
tomek removed a reviewer: tomek. tomek added 1 blocking reviewer(s): jon.Oct 19 2022, 3:43 AM

Looks ok, but I'm not really sure how to review it. @marcin and @jon should do a better review.

native/android/app/CMakeLists.txt
43–51 ↗(On Diff #17653)

Are we sure this contains all the possible targets?

native/android/app/CMakeLists.txt
43–51 ↗(On Diff #17653)

According to docs yes: https://cmake.org/cmake/help/latest/variable/CMAKE_ANDROID_ARCH_ABI.html. I did a quick check and mips architecture devices are not used as mobile phones.

include the native_rust_library directory in CMakeLists.txt

Changes look good to me. Just a quick question - when I was compiling android locally I had to include "native_rust_library/src/lib.rs.h" instead of "lib.rs.h" in C++. this would cause discrepancy between iOS and android. @varun did you try to include lib.rs.h in c++ file with changes from this diff? In the meantime I will try to compile android with this diff locally to see which header needs to be included.

good point, @marcin . the latest update on this diff fixes the discrepancy between iOS and Android

jon requested changes to this revision.Oct 19 2022, 5:25 PM
jon added inline comments.
native/android/app/CMakeLists.txt
54 ↗(On Diff #17666)

we should only "fallback" to using the explicitly passed NDK_VERSION if CMAKE_ANDROID_NDK_VERSION is not available. This seems to be available in the google supplied cmake versions, and in cmake 3.20+

54 ↗(On Diff #17666)

We should check to see if ANDROID_HOME is set, reading blindly from ENV makes me nervous.

76 ↗(On Diff #17666)

generally the namespace is for the project or organization

This revision now requires changes to proceed.Oct 19 2022, 5:25 PM
varun requested review of this revision.Oct 20 2022, 7:15 AM
varun added inline comments.
native/android/app/CMakeLists.txt
54 ↗(On Diff #17666)

CMAKE_ANDROID_NDK_VERSION is not available. I checked that first

54 ↗(On Diff #17666)

ANDROID_HOME is set as part of our dev environment setup. It's also available on the CI machine

76 ↗(On Diff #17666)

@marcin is there a reason why we chose android for the namespace here or can i change it to comm?

marcin added inline comments.
native/android/app/CMakeLists.txt
76 ↗(On Diff #17666)

Changing to comm is absolutely fine. "Some" namespace name was required and android was my first thought , but any will work.

address jon's feedback about namespaces

Looks fine to me.

Not a big fan of the triple logic, but I'm not sure of a better way to do it

This revision is now accepted and ready to land.Oct 20 2022, 12:53 PM