Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Support: Exporting to Android Archive (AAR) #10271

Merged
merged 15 commits into from
Apr 6, 2020

Conversation

atkawa7
Copy link
Contributor

@atkawa7 atkawa7 commented Mar 1, 2020

This pr add functionality to support android archives in vcpkg through exporting libs and includes to aar archives. This works similar to ndkports currently in the works by @DanAlbert . Once the archive is created then it can imported in the android as a native dependent.

Checkout the article "Native Dependencies in Android Studio 4.0" about prefab and native dependencies on https://android-developers.googleblog.com/2020/02/native-dependencies-in-android-studio-40.html

Checkout the prefab project on https://github.com/google/prefab

See NDK ports for more https://android.googlesource.com/platform/tools/ndkports

Todos

  • ability to auto build all android ports to support the 4 android Abis for i.e arm64-v8a, armeabi-v7a, x86_64, x86
  • prevent requiring port triple
  • Failing if port is not android specific
  • Testing on other platforms (tested on OS X)

Example exporting [jsoncpp]

Requires

  • maven
  • ndk
  • 7zip or zip
The following packages are already built and will be exported:
    jsoncpp:x86-android
Exporting package jsoncpp...
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
[INFO] Installing<root>/prefab/jsoncpp/jsoncpp-1.9.2.aar to /.m2/repository/com/vcpkg/ndk/support/jsoncpp/1.9.2/jsoncpp-1.9.2.aar
[INFO] Installing <vcpkg_root>/prefab/jsoncpp/pom.xml to /.m2/repository/com/vcpkg/ndk/support/jsoncpp/1.9.2/jsoncpp-1.9.2.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.301 s
[INFO] Finished at: 2020-03-01T10:18:15Z
[INFO] ------------------------------------------------------------------------
Successfuly installed jsoncpp. Checkout <vcpkg_root>/prefab/jsoncpp/aar

Export

prefab
└── jsoncpp
    ├── aar
    │   ├── AndroidManifest.xml
    │   ├── META-INF
    │   │   └── LICENCE
    │   └── prefab
    │       ├── modules
    │       │   └── jsoncpp
    │       │       ├── include
    │       │       │   └── json
    │       │       │       ├── allocator.h
    │       │       │       ├── assertions.h
    │       │       │       ├── autolink.h
    │       │       │       ├── config.h
    │       │       │       ├── forwards.h
    │       │       │       ├── json.h
    │       │       │       ├── json_features.h
    │       │       │       ├── reader.h
    │       │       │       ├── value.h
    │       │       │       ├── version.h
    │       │       │       └── writer.h
    │       │       ├── libs
    │       │       │   ├── android.arm64-v8a
    │       │       │   │   ├── abi.json
    │       │       │   │   └── libjsoncpp.so
    │       │       │   ├── android.armeabi-v7a
    │       │       │   │   ├── abi.json
    │       │       │   │   └── libjsoncpp.so
    │       │       │   ├── android.x86
    │       │       │   │   ├── abi.json
    │       │       │   │   └── libjsoncpp.so
    │       │       │   └── android.x86_64
    │       │       │       ├── abi.json
    │       │       │       └── libjsoncpp.so
    │       │       └── module.json
    │       └── prefab.json
    ├── jsoncpp-1.9.2.aar
    └── pom.xml

13 directories, 25 files

@atkawa7 atkawa7 mentioned this pull request Mar 1, 2020
@MVoz
Copy link
Contributor

MVoz commented Mar 2, 2020

Requires JAVA and Gradle ?

@DanAlbert
Copy link

Requires JAVA and Gradle ?

Gradle is required on the consumption end of this, but not on the production end.

The Java requirement comes from maven, which could be avoided if needed (it could also potentially be made an optional requirement).

@MVoz
Copy link
Contributor

MVoz commented Mar 2, 2020

@DanAlbert
and if you look at the future\in advance, and not just in these edits

p/s/ in this version, everything is also fine if the working version

@Zingam
Copy link

Zingam commented Mar 3, 2020

@atkawa7 @DanAlbert android/ndk#916 (comment)
Can this be made to be used to build the prefabs you'll deliver?

Or maybe also integrated into AS UI (SDK Manager) to search, get/build and include packages manually/automatically with as little dependencies as possible and use what's available in the AS installation.

Requires JAVA and Gradle ?

Gradle is required on the consumption end of this, but not on the production end.

The Java requirement comes from maven, which could be avoided if needed (it could also potentially be made an optional requirement).

@Zingam
Copy link

Zingam commented Mar 3, 2020

@atkawa7 If at some point prefabs support: google/prefab#65 (comment) Can this feature be extended to produce debuggable prefabs? Or does this feature already do that?

@atkawa7
Copy link
Contributor Author

atkawa7 commented Mar 3, 2020

@Zingam that is doable. VCPKG supports debug libs but I didn't include them since prefabs doesn't support them yet. Once i google/prefab#65 is supported I am sure we can add the debugs.

@Zingam
Copy link

Zingam commented Mar 3, 2020

Thanx! I just wonder how all this stuff would fit into my current build system as I have custom Find*.cmake modules to build and configure the libraries I need. I use vcpkg for my Windows and Linux builds.

Copy link

@DanAlbert DanAlbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with vcpkg, so please forgive any obviously incorrect review comments :)

toolsrc/include/vcpkg/export.prefab.h Show resolved Hide resolved
toolsrc/src/vcpkg/export.cpp Show resolved Hide resolved
toolsrc/src/vcpkg/export.prefab.cpp Show resolved Hide resolved
toolsrc/src/vcpkg/export.prefab.cpp Outdated Show resolved Hide resolved
toolsrc/src/vcpkg/export.cpp Outdated Show resolved Hide resolved
toolsrc/src/vcpkg/export.prefab.cpp Outdated Show resolved Hide resolved
toolsrc/src/vcpkg/export.prefab.cpp Outdated Show resolved Hide resolved
toolsrc/src/vcpkg/export.prefab.cpp Outdated Show resolved Hide resolved
toolsrc/src/vcpkg/export.prefab.cpp Outdated Show resolved Hide resolved
toolsrc/src/vcpkg/export.prefab.cpp Outdated Show resolved Hide resolved
@DanAlbert
Copy link

@atkawa7 @DanAlbert android/ndk#916 (comment)
Can this be made to be used to build the prefabs you'll deliver?

Not sure what the benefit would be. Getting this merged here makes it available to users. Us using it wouldn't make a difference.

Or maybe also integrated into AS UI (SDK Manager) to search, get/build and include packages manually/automatically with as little dependencies as possible and use what's available in the AS installation.

I don't think that's the right approach. Users should be fetching prebuilts, not building the libraries themselves. This patch makes it easy for someone to build the vcpkg corpus for Android and push them to maven as AARs. The better solution would be for someone to do that instead.

@JackBoosY
Copy link
Contributor

/azp run

@JackBoosY
Copy link
Contributor

It looks like we cannot use these changes to build vcpkg in Windows anymore.

@atkawa7
Copy link
Contributor Author

atkawa7 commented Mar 5, 2020

@DanAlbert Thank you for your good reviews. @JackBoosY @ras0219-msft See the news changes. Now its buildable on Visual Studio

@atkawa7
Copy link
Contributor Author

atkawa7 commented Mar 24, 2020

@JackBoosY @strega-nil @ras0219-msft Checkout the new changes

@JackBoosY
Copy link
Contributor

CI test success.
@dan-shaw

This was referenced Mar 27, 2020
@dan-shaw dan-shaw added info:reviewed Pull Request changes follow basic guidelines and removed needs-feature-review labels Mar 28, 2020
@dan-shaw
Copy link
Contributor

dan-shaw commented Apr 6, 2020

Passing CI now, and it looks like all review comments are fixed. Thanks @atkawa7 and everyone for the PR and reviews!

@dan-shaw dan-shaw merged commit 52b5dfd into microsoft:master Apr 6, 2020
@atkawa7 atkawa7 deleted the allen/feature/android-support branch April 7, 2020 07:08
@linquize
Copy link

Should add the new files export.prefab.cpp, export.prefab.h to vcpkglib.vcxproj.filters

@pthom
Copy link
Contributor

pthom commented May 8, 2020

I hope the vcpkg doc will be updated soon in order to reflect this, since for the moment this feature is mostly hidden for users : the official doc about triplets only mentions info about outdated android standalone toolchains.

@strega-nil
Copy link
Contributor

@pthom This isn't really a feature the vcpkg team knows much about; if you'd like to write up the docs, we'd absolutely appreciate it :) (or if @atkawa7 would like to come back and write docs!)

@atkawa7
Copy link
Contributor Author

atkawa7 commented May 9, 2020

@pthom @strega-nil there is currently documentation on how to integrate android archives
See this document https://github.com/microsoft/vcpkg/blob/master/docs/specifications/prefab.md

See #11052 for configuration issues that might pop up.

You need to create the four android triplets yourself. Initially I had added triplets but then removed them since android users need custom triplets.

@pthom
Copy link
Contributor

pthom commented May 9, 2020

@pthom This isn't really a feature the vcpkg team knows much about; if you'd like to write up the docs, we'd absolutely appreciate it :) (or if @atkawa7 would like to come back and write docs!)

My proposition, where I made some changes in the doc that would have helped me a lot:
#11264

@Zingam
Copy link

Zingam commented May 9, 2020

I am not a native English speaker but I think that there are some grammatical errors in the document. Also prefab.md isn't very descriptive unless you already know what you look for? Perhaps Android-prefab.md or something like that would be better?

@atkawa7
Copy link
Contributor Author

atkawa7 commented May 9, 2020

@Zingam I think just android is even better

strega-nil pushed a commit to strega-nil/vcpkg that referenced this pull request May 5, 2021
* added android triplets

* added android support to vcpkg

* added export directories to git ignore

* fix libraries naming

* added vckpg sources to visual studio project files

* rename file location

* issue with std::string fs:path copy initialization

* format path on VStudio

* fix checks format cannot work on fs::path

* support header only libraries

* support using architecture instead of triplets

* added prefab support

* added debug logs and prefab debug flag

* added support for empty packages i.e openssl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info:reviewed Pull Request changes follow basic guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants