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

Commit

Permalink
Merge pull request #6 from hyperledger/master
Browse files Browse the repository at this point in the history
Merging master from hyperledger
  • Loading branch information
anastasia-tarasova authored Jun 28, 2017
2 parents 69e85b5 + e033495 commit 3961872
Show file tree
Hide file tree
Showing 7 changed files with 273 additions and 168 deletions.
104 changes: 7 additions & 97 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,99 +1,9 @@
# sovrin-client-rust
# Indy SDK

# Linux (Ubuntu 16.04) build
## Building of Indy SDK

- Install Rust (https://www.rust-lang.org/install.html)
- Install prerequisites:
- build-essential
- cmake
- pkg-config
- libsodium-dev
- libssl-dev
- libsqlite3-dev
- libzmq3-dev
```
# apt-get update && apt-get install -y pkg-config libzmq3-dev libssl-dev build-essential libsqlite3-dev libsodium-dev cmake
```
- Build library `cargo build`
- To run integration tests
- start local nodes pool on `10.0.0.2:9701-9708`, see `ci/sovrin-pool.dockerfile`
- run `RUST_TEST_THREADS=1 cargo test`

# Windows build

## Get/build dependencies

All prebuilt can be downloaded from
https://repo.evernym.com/deb/windows-bins/indy-sdk-deps/

### Binary deps

- https://www.npcglib.org/~stathis/downloads/openssl-1.0.2k-vs2017.7z
- https://download.libsodium.org/libsodium/releases/libsodium-1.0.12-msvc.zip

### Source deps

- http://www.sqlite.org/2017/sqlite-amalgamation-3180000.zip
- https://github.com/miracl/milagro-crypto-c/
- https://github.com/evernym/libzmq-pw

### Build sqlite

Download http://www.sqlite.org/2017/sqlite-amalgamation-3180000.zip

Create empty static library project and add sqlite.c file and 2 headers from exctraced
archive. Then just build it.

### Build milagro-crypto-c

Checkout https://github.com/miracl/milagro-crypto-c/ repository.
- cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -G "Visual Studio 15 2017 Win64" .
- open AMCL.sln
- disable custom build steps
- build it

### Build libzmq-pw

Checkout https://github.com/evernym/libzmq-pw repository.
- open builds/msvc/vs2017/libzmq.sln
- switch "draft API" and "libsodium" options on
- change "output file name" to $(TargetName)-pw
- build (it may print errors while
building tests which can be ignored)

## Build

- Get binary dependencies (libamcl*, openssl, libsodium, libzmq, sqlite3).
- Put all *.{lib,dll} into one directory and headers into include/ subdirectory.
- open MSVS development console
- execute "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
- Point path to this directory using environment variables:
- set SOVRIN_PREBUILT_DEPS_DIR=C:\BIN\x64
- set SODIUM_LIB_DIR=C:\BIN\x64
- set OPENSSL_INCLUDE_DIR=C:\BIN\x64\include
- set OPENSSL_LIB_DIR=C:\BIN\x64
- set LIBZMQ_LIB_DIR=C:\BIN\x64
- set LIBZMQ_INCLUDE_DIR=C:\BIN\x64\include
- set static flag for libsodium build
- set SODIUM_STATIC=y
- set PATH to find .dlls:
- set PATH=C:\BIN\x64;%PATH%
- change dir to sovrin-client and run cargo (you may want to add --release --target x86_64-pc-windows-msvc keys to cargo)

## openssl-sys workaround

When your windows build fails complaining on gdi32.lib you should edit

```
~/.cargo/registry/src/github.com-*/openssl-sys-*/build.rs
```

and add

```
println!("cargo:rustc-link-lib=dylib=gdi32");
```

to the end of main() function.

Then try to rebuild whole project.
* [Ubuntu based distro (Ubuntu 16.04)](doc/ubuntu-build.md)
* [RHEL based distro (Amazon Linux 2017.03)](doc/rhel-build.md)
* [Windows](doc/windows-build.md)
* [iOS](doc/ios-build.md)
* [MacOS](doc/mac-build.md)
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {
println!("cargo:rustc-flags=-L {}/lib", prebuilt_dir);
println!("cargo:include={}/include", prebuilt_dir);

let files = vec![ "libeay32md.dll", "libsodium.dll", "libzmq.dll", "ssleay32md.dll" ];
let files = vec![ "libeay32md.dll", "libsodium.dll", "libzmq-pw.dll", "ssleay32md.dll" ];
for f in files.iter() {
if let Ok(_) = fs::copy(&prebuilt.join(f), &dst.join(f)) {
println!("copy {} -> {}", &prebuilt.join(f).display(), &dst.join(f).display());
Expand Down
98 changes: 52 additions & 46 deletions doc/ios-build.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,55 @@
# Setup of IOS build environment.

1. Install [rustup](https://www.rustup.rs) toolchain manager.

2. Install toolchains using command
> rustup target add aarch64-apple-ios armv7-apple-ios armv7s-apple-ios i386-apple-ios x86_64-apple-ios
3. Install cargo-lipo
> cargo install cargo-lipo
4. Install required native libraries and utilities
> brew install libsodium
> brew install zeromq
> brew install cmake
5. Setup environment variables:

> export PKG_CONFIG_ALLOW_CROSS=1
> export CARGO_INCREMENTAL=1
6. Edit script build-libsovrin-core-ios.sh: set the following variables to fit your environment:
> export OPENSSL_DIR=/usr/local/Cellar/openssl/1.0.2k
> export EVERNYM_REPO_KEY=~/Documents/EvernymRepo
> export LIBSOVRIN_POD_VERSION=0.0.1
# Setup of IOS build environment

1. Install Rust and rustup (https://www.rust-lang.org/install.html).
1. Install toolchains using command:

```
rustup target add aarch64-apple-ios armv7-apple-ios armv7s-apple-ios i386-apple-ios x86_64-apple-ios
```
1. Install cargo-lipo:

```
cargo install cargo-lipo
```
1. Install required native libraries and utilities:

```
brew install libsodium
brew install zeromq
brew install cmake
```
1. Setup environment variables:

```
export PKG_CONFIG_ALLOW_CROSS=1
export CARGO_INCREMENTAL=1
```
1. Edit script build-libsovrin-core-ios.sh: set the following variables to fit your environment:

```
export OPENSSL_DIR=/usr/local/Cellar/openssl/1.0.2k
export EVERNYM_REPO_KEY=~/Documents/EvernymRepo
export LIBSOVRIN_POD_VERSION=0.0.1
```
OPENSSL_DIR - path to installed openssl library

EVERNYM_REPO_KEY - path to file with private key to be authorized on deb server

LIBSOVRIN_POD_VERSION - version of livsovrin-core pod to be built

7. Run the script. Validate the output that all goes well.

8. cd Podspec

9. Create directory with name defined in LIBSOVRIN_POD_VERSION
mkdir LIBSOVRIN_POD_VERSION

10. copy libsovrin-core.podspec.json to that new directory from some previous version

11. edit this json -> change version field to LIBSOVRIN_POD_VERSION

12. add new directory and file inside to git repository.

13. commit to master branch

14. for all projects which using libsovrin-core do not forget to make
> pod repo update
> pod install

1. Run the script. Validate the output that all goes well.
1. Go to `Podspec` dir.
1. Create directory with name defined in LIBSOVRIN_POD_VERSION:

```
mkdir LIBSOVRIN_POD_VERSION
```
1. Copy libsovrin-core.podspec.json to that new directory from some previous version.
1. Edit this json -> change version field to LIBSOVRIN_POD_VERSION.
1. Add new directory and file inside to git repository.
1. Commit to master branch.
1. for all projects which using libsovrin-core do not forget to make:

```
pod repo update
pod install
```
50 changes: 26 additions & 24 deletions doc/mac-build.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
# Setup of MAC build environment.

1. Install [rustup](https://www.rustup.rs) toolchain manager.

2. Install required native libraries and utilities
> brew install libsodium
> brew install zeromq
> brew install cmake
> brew install openssl
3. Setup environment variables:

> export PKG_CONFIG_ALLOW_CROSS=1
> export CARGO_INCREMENTAL=1
> export RUST_LOG=sovrin=trace
> export RUST_TEST_THREADS=1
4. Setup OPENSSL_DIR variable: path to installed openssl library

>export OPENSSL_DIR=/usr/local/Cellar/openssl/1.0.2k
5. Build the library:

>cargo build
# Setup Indy SDK build environment for MacOS

1. Install Rust and rustup (https://www.rust-lang.org/install.html).
1. Install required native libraries and utilities

```
brew install libsodium
brew install zeromq
brew install cmake
brew install openssl
```
1. Setup environment variables:
```
export PKG_CONFIG_ALLOW_CROSS=1
export CARGO_INCREMENTAL=1
export RUST_LOG=sovrin=trace
export RUST_TEST_THREADS=1
```
1. Setup OPENSSL_DIR variable: path to installed openssl library
```
export OPENSSL_DIR=/usr/local/Cellar/openssl/1.0.2k
```
1. Checkout and build the library:
```
git checkout https://github.com/hyperledger/indy-sdk.git
cd ./indy-sdk
cargo build
```
64 changes: 64 additions & 0 deletions doc/rhel-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Setup Indy SDK build environment for RHEL based distro (Amazon Linux 2017.03)

1. Install Rust and rustup (https://www.rust-lang.org/install.html).
1. Install required native libraries and utilities available in repos:

```
yum clean all
yum upgrade -y
yum groupinstall -y "Development Tools"
yum install -y \
wget \
cmake \
pkgconfig \
openssl-devel \
sqlite-devel
```
1. Build and install modern version of libsodium from sources:

```
cd /tmp
curl https://download.libsodium.org/libsodium/releases/libsodium-1.0.12.tar.gz | tar -xz
cd /tmp/libsodium-1.0.12
./configure
make
make install
rm -rf /tmp/libsodium-1.0.12
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
```
1. Build and install modern version of libzmq from sources:

```
cd /tmp
wget https://github.com/zeromq/libzmq/releases/download/v4.2.2/zeromq-4.2.2.tar.gz
tar xfz zeromq-4.2.2.tar.gz && rm zeromq-4.2.2.tar.gz
cd /tmp/zeromq-4.2.2
./configure
make
make install
rm -rf /tmp/zeromq-4.2.2
```
1. Checkout and build the library:

```
git checkout https://github.com/hyperledger/indy-sdk.git
cd ./indy-sdk
cargo build
```
1. Run integration tests:
* Start local nodes pool on `10.0.0.2:9701-9708` with Docker:

```
docker network create --subnet 10.0.0.0/8 pool_network
docker build -f ci/sovrin-pool.dockerfile -t sovrin_pool .
docker run -d --ip="10.0.0.2" --net=pool_network sovrin_pool
```
* Run tests
```
RUST_TEST_THREADS=1 cargo test
```
See [ci/amazon.dockerfile](https://github.com/hyperledger/indy-sdk/tree/master/ci/amazon.dockerfile) for example of Amazon Linux based environment creation in Docker.
38 changes: 38 additions & 0 deletions doc/ubuntu-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Setup Indy SDK build environment for Ubuntu based distro (Ubuntu 16.04)

1. Install Rust and rustup (https://www.rust-lang.org/install.html).
2. Install required native libraries and utilities:

```
apt-get update && \
apt-get install -y \
build-essential \
pkg-config \
cmake \
libzmq3-dev \
libssl-dev \
libsqlite3-dev \
libsodium-dev
```
3. Checkout and build the library:

```
git checkout https://github.com/hyperledger/indy-sdk.git
cd ./indy-sdk
cargo build
```
4. Run integration tests:
* Start local nodes pool on `10.0.0.2:9701-9708` with Docker:

```
docker network create --subnet 10.0.0.0/8 pool_network
docker build -f ci/sovrin-pool.dockerfile -t sovrin_pool .
docker run -d --ip="10.0.0.2" --net=pool_network sovrin_pool
```
* Run tests
```
RUST_TEST_THREADS=1 cargo test
```
See [ci/ubuntu.dockerfile](https://github.com/hyperledger/indy-sdk/tree/master/ci/ubuntu.dockerfile) for example of Ubuntu based environment creation in Docker.
Loading

0 comments on commit 3961872

Please sign in to comment.