Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Android builds arm arm64 and x86 #777

Merged
merged 30 commits into from
Jun 28, 2018

Conversation

faisal00813
Copy link
Contributor

@faisal00813 faisal00813 commented May 21, 2018

Signed-off-by: Mohammad Abdul Sami faisal00813@gmail.com

Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
(cherry picked from commit 2d681f6)

Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>

Updated READMEs
Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
@lodo1995
Copy link
Contributor

@faisal00813 the path /sdcard/Documents/.indy_client is not portable to all devices. For example, my phone, which is a Samsung running KitKat with no sd card, does not have it. On my phone, the documents folder is /storage/emulated/0.

faisal00813 and others added 8 commits May 21, 2018 18:22
Signed-off-by: Mohammad Abdul Sami faisal00813@gmail.com
Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>

Fixed credentials filtering bug

Signed-off-by: artem.ivanov <artem.ivanov@dsr-company.com>

fixed libsqlcipher-sys version in cargo.lock

Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
# Conflicts:
#	libindy/Cargo.lock
#	libindy/Cargo.toml
#	libindy/build.rs
Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
@faisal00813
Copy link
Contributor Author

@jovfer @vimmerru Can you please review this.


## Prerequisites

- Docker
Copy link

Choose a reason for hiding this comment

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

Can i build it on windows and MacOS?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only Linux is supported as of now.

Choose a reason for hiding this comment

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

Can you add this info to per-requirements? It is better to provide info about platform that we tested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That info is present in Known Issues segment at the bottom of the document.

Choose a reason for hiding this comment

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

ok

@@ -38,17 +38,17 @@ sodium_static = []
indy-crypto = { version = "=0.4.1", optional = true }
int_traits = { version = "0.1.1", optional = true }
digest = "0.6.2"
env_logger = "0.4.2"
env_logger = "0.5.10"
Copy link

Choose a reason for hiding this comment

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

Is it updated intentionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. We require 0.4.2 for android_logger

Choose a reason for hiding this comment

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

ok, make sense

errno = "0.2.3"
etcommon-rlp = "0.2.3"
generic-array = "0.8.3"
hex = "0.2.0"
libc = "0.2.21"
log = "0.3.7"
log = "0.4.1"
Copy link

Choose a reason for hiding this comment

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

Is it updated intentionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

Choose a reason for hiding this comment

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

ok, make sense

openssl = { version = "=0.9.24", optional = true }
owning_ref = "0.3.3"
rand = "0.3"
rusqlite = "0.13.0"
rusqlite = { version = "0.13.0", features=["bundled"] }
Copy link

Choose a reason for hiding this comment

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

As i understand now we start static linking with sqlite on all platforms.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On Android, we don't have SQLite binaries which we provide while building. Also, I can't recall any flag which suggests that we are doing static linking with SQLite.

Choose a reason for hiding this comment

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

The problem is that we don't want to force static linking on all platforms. Only for android and iOS

- Modified to plugged/mod.rs to support arm64

Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
libindy/build.rs Outdated
@@ -32,4 +32,40 @@ fn main() {
}
}
}
match &target {
x if x.contains("aarch64-linux-android") || x.contains("armv7-linux-androideabi") ||

Choose a reason for hiding this comment

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

Can we just replace this complex if with just "linux-android" as it seems present in all arch strings?

Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
@@ -0,0 +1,49 @@
FROM ubuntu:16.04

Choose a reason for hiding this comment

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

I believe we need to rename it to something more obvious like android-build-env.dockerfile


## How to build.
- Goto `indy-sdk/libindy/build_scripts/android` folder
- Run `build.dependencies.locally.sh`

Choose a reason for hiding this comment

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

Run build.dependencies.locally.sh

Will it build dependencies for all supported architectures?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. The script will build for x86, arm and arm64 architectures.

mkdir -p $ARMV7_DIR
mkdir -p $ARMx86_DIR

git clone /~https://github.com/nsivraj/openssl_for_ios_and_android.git

Choose a reason for hiding this comment

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

Build must be repeatable. Se we can't use just master branch for dependencies. Use tag/release/commit


if [ ! -f "libsodium-1.0.12.tar.gz" ] ; then
echo "Downloading libsodium-1.0.12.tar.gz"
wget -q wget /~https://github.com/jedisct1/libsodium/releases/download/1.0.12/libsodium-1.0.12.tar.gz

Choose a reason for hiding this comment

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

Master uses libsodium 1.0.14


pub struct EnvironmentUtils {}

impl EnvironmentUtils {
pub fn indy_home_path() -> PathBuf {
// TODO: FIXME: Provide better handling for the unknown home path case!!!

Choose a reason for hiding this comment

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

This code doesn't look correct for me.

  • I see 2 unwraps. Will we crash if there is no EXTERNAL_STORAGE variable?
  • Why we create directories here? It isn't responsibility of this function
  • Flow also looks very non-obvious? Can you just use on match or if/if else/if else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Libindy will now panic! if it cannot find the EXTERNAL_STORAGE .

Copy link
Contributor

@jovfer jovfer Jun 27, 2018

Choose a reason for hiding this comment

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

Agree with @vimmerru. Please fix all 3 points
#777 (comment)

@AxelNennker
Copy link
Contributor

AxelNennker commented Jun 13, 2018

I suggest not to use cd ../../../.. to get to the root of indy-sdk from the build scripts but to use
e.g. for arm64

#!/usr/bin/env bash

BASEDIR=$(dirname "$0")

DEPS_FOLDER=$BASEDIR/dependencies
LIBZMQ=${DEPS_FOLDER}/zmq/libzmq_arm64
OPENSSL=${DEPS_FOLDER}/openssl/openssl_arm64
LIBSODIUM=${DEPS_FOLDER}/sodium/libsodium_arm64
$BASEDIR/build.sh -f arm64 21 aarch64-linux-android android_support ${OPENSSL} ${LIBSODIUM} ${LIBZMQ}

I have send the changed script via email to @faisal00813

Another thing: Why delete the android ndk? I copied it here so that it does not get downloaded everytime.

@vimmerru
Copy link

It would be nice to have a script in libindy root folder that will build artifacts for all platforms.

@vimmerru
Copy link

You use /~https://github.com/nsivraj/openssl_for_ios_and_android to build openssl, This script isn't performed in isolated environment. Does it require any pre-requirements? Can we just use pre-built binary from the same site?

@vimmerru
Copy link

Build looks a bit over-complicated now. You use dockerfiles that just perform builds of one thing. It can be much faster (and easy to understand) to have one dockerfile that setups all necessary environment and set of scripts to execute inside of this dockerfile.

@vimmerru
Copy link

Is there a way to execute tests?

Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
[WIP] updated build scripts to download and use prebuilt dependencies

Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
@AxelNennker
Copy link
Contributor

Android NDK 17 is out. Update this?

…l the architecture.

Removed dependencies building scripts and instructions.
Libnullpay uses same mechanism for building as libindy
Build scripts downloads prebuilt binaries while building.

Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
@faisal00813
Copy link
Contributor Author

@AxelNennker I don't see any immediate need for updating to NDK17. The changelog suggests deprecation of GCC and we use CLANG in our scripts.

@faisal00813
Copy link
Contributor Author

@vimmerru I have simplified the build scripts. Now a single script in root folder of each module (libindy and libnullpay) builds for all the architectures.

@AxelNennker
Copy link
Contributor

I switched out r16 and moved to r17 and rebuild using my scripts and had no problems doing that.
/~https://github.com/AxelNennker/indy-sdk/blob/android_builds/doc/android-build.md
I think if you try to change the 16 to 17 and they still work then switch otherwise don't.

@faisal00813
Copy link
Contributor Author

faisal00813 commented Jun 26, 2018

Also addressed the concern regarding /~https://github.com/nsivraj/openssl_for_ios_and_android . Now we use a fork /~https://github.com/evernym/indy-android-dependencies with a tag.

faisal00813 and others added 4 commits June 26, 2018 18:23
…nother function

Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
…ble on android.

Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
Copy link
Contributor

@jovfer jovfer left a comment

Choose a reason for hiding this comment

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

Please fix active review comments above. Right now it's only about codestyle, if required I can review build scripts structure as next round of review.

libindy/build.rs Outdated
@@ -32,4 +32,38 @@ fn main() {
}
}
}
match &target {
Copy link
Contributor

Choose a reason for hiding this comment

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

please clean-up code here. Seems like this section should be in else if for previous one (windows)


pub struct EnvironmentUtils {}

impl EnvironmentUtils {
pub fn indy_home_path() -> PathBuf {
// TODO: FIXME: Provide better handling for the unknown home path case!!!

Copy link
Contributor

@jovfer jovfer Jun 27, 2018

Choose a reason for hiding this comment

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

Agree with @vimmerru. Please fix all 3 points
#777 (comment)

@@ -6,7 +6,7 @@ build = "build.rs"

[lib]
name = "nullpay"
crate-type = ["cdylib", "rlib"]
crate-type = ["staticlib","cdylib", "rlib"]
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like staticlib should be android-specific target

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if rust supports the conditional crate-type declaration. Does it?
There are two issues related to it though, rust-lang/cargo#5367 and rust-lang/cargo#4900 .

@@ -4,19 +4,29 @@ use std::path::Path;
fn main() {
let target = env::var("TARGET").unwrap();
println!("target={}", target);
match &target {
Copy link
Contributor

Choose a reason for hiding this comment

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

match construction is ugly here. please clean-up and use if else

android_logger = "0.5"
[target.'cfg(any(target_os = "android", target_os = "ios"))'.dependencies]
rusqlite = { version = "0.13.0", features=["bundled"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

please specify common and android rusqlite dependence as neighbors to avoid partial update in the future

@jovfer
Copy link
Contributor

jovfer commented Jun 27, 2018

@faisal00813 After auto-merge test compilation is failed, please fix it also
https://ci.evernym.com/job/Indy%20SDK%20CI/view/change-requests/job/PR-777/8/execution/node/97/log/

updated android-build.doc

Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
…cargo.toml for better visibility

Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
Signed-off-by: Mohammad Abdul Sami <faisal00813@gmail.com>
@vimmerru vimmerru merged commit 0518ecf into hyperledger-archives:master Jun 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants