Skip to content

Commit

Permalink
Merge pull request hyperledger-archives#1521 from theoturner/master
Browse files Browse the repository at this point in the history
MacOS installer
  • Loading branch information
jovfer authored Mar 14, 2019
2 parents e7359ac + a2f020f commit eb52f53
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 17 deletions.
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,11 @@ See section "Release channels" for more details.

### MacOS

Pre-built libraries are not provided for MacOS. Please look [here](docs/build-guides/mac-build.md)
for details on building from source for MacOS.

**Note:** After building `libindy`, add the path containing the library the `LD_LIBRARY_PATH` and
`DYLD_LIBRARY_PATH` environment variables. This is necessary for dynamically linking
your application with `libindy`. The dynamic linker will first check for the library in
`LD_LIBRARY_PATH` if the library in your application doesn't include directory names.
If the library in your application does include any directory name, then dynamic
linker will search for the library in `DYLD_LIBRARY_PATH` (not `LD_LIBRARY_PATH`)
so we recommend you set both variables to be safe.
Pre-built libraries are not provided for MacOS.

Clone the repo and run `mac.build.sh` in the `libindy` folder.

Please see [here](docs/build-guides/mac-build.md) for manual build steps.

### RHEL-based distributions (Amazon Linux 2017.03)
Pre-built libraries are not provided for RHEL-based distributions. Please look [here](docs/build-guides/rhel-build.md)
Expand Down
19 changes: 12 additions & 7 deletions docs/build-guides/mac-build.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Setup Indy SDK build environment for MacOS
# MacOS build guide

Automated build: clone the repo and run `mac.build.sh` in the `libindy` folder.

## Manual steps

1. Install Rust and rustup (https://www.rust-lang.org/install.html).
2. Install required native libraries and utilities (libsodium is added with URL to homebrew since version<1.0.15 is required)

```
brew install pkg-config
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/65effd2b617bade68a8a2c5b39e1c3089cc0e945/Formula/libsodium.rb
Expand All @@ -13,8 +16,6 @@
brew install zeromq
brew install zmq
```


3. Setup environment variables:
```
export PKG_CONFIG_ALLOW_CROSS=1
Expand All @@ -24,7 +25,10 @@
```
4. Setup OPENSSL_DIR variable: path to installed openssl library
```
export OPENSSL_DIR=/usr/local/Cellar/openssl/1.0.2n # path changes with version number
for version in `ls -t /usr/local/Cellar/openssl/`; do
export OPENSSL_DIR=/usr/local/Cellar/openssl/$version
break
done
```
5. Checkout and build the library:
```
Expand All @@ -38,13 +42,14 @@
cd ../cli
cargo build
```
7. Set your `DYLD_LIBRARY_PATH` and `LD_LIBRARY_PATH` environment variables to the path of `indy-sdk/libindy/target/debug`. You may want to put these in your `.bash_profile` to persist them.

# Note on running local nodes
## Note on running local nodes

In order to run local nodes on MacOS, it may be necessary to set up port mapping between the Docker container
and local host. Follow the instructions in [Indy SDK README](https://github.com/hyperledger/indy-sdk#how-to-start-local-nodes-pool-with-docker)

# IOError while running of whole set of tests on MacOS
## IOError while running of whole set of tests on MacOS

There is a possible case when some tests are failed if whole set of tests is run (`cargo test`).
But failed tests will be successful in case of separate runs.
Expand Down
47 changes: 47 additions & 0 deletions libindy/mac.build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

onred='\033[41m'
ongreen='\033[42m'
onyellow='\033[43m'
endcolor="\033[0m"

# Handle errors
set -e
error_report() {
echo -e "${onred}Error: failed on line $1.$endcolor"
}
trap 'error_report $LINENO' ERR

echo -e "${onyellow}Installing libindy...$endcolor"

if [[ "$OSTYPE" == "darwin"* ]]; then
xcode-select --version || xcode-select --install
brew --version || yes | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
cmake --version || brew install cmake # brew install cmake throws error, not warning if already installed
curl https://sh.rustup.rs -sSf | sh -s -- -y
export PATH="$HOME/.cargo/bin:$PATH" # so can use cargo without relog
brew install pkg-config \
https://raw.githubusercontent.com/Homebrew/homebrew-core/65effd2b617bade68a8a2c5b39e1c3089cc0e945/Formula/libsodium.rb \
automake \
autoconf \
openssl \
zeromq \
zmq
export PKG_CONFIG_ALLOW_CROSS=1
export CARGO_INCREMENTAL=1
export RUST_LOG=indy=trace
export RUST_TEST_THREADS=1
for version in `ls -t /usr/local/Cellar/openssl/`; do
export OPENSSL_DIR=/usr/local/Cellar/openssl/$version
break
done
cargo build
export LIBRARY_PATH=$(pwd)/target/debug
cd ../cli
cargo build
echo 'export DYLD_LIBRARY_PATH='$LIBRARY_PATH'
export LD_LIBRARY_PATH='$LIBRARY_PATH >> ~/.bash_profile
echo -e "${ongreen}Libindy installed.$endcolor"
else
echo -e "${onred}You are not running MacOS. This is a MacOS installer.$endcolor"
fi

0 comments on commit eb52f53

Please sign in to comment.