diff --git a/README.md b/README.md index 41677adab..e890fe3b8 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,9 @@ Adds Sovrin's token functionality to HyperLedger's Indy-SDK. 1. cargo test +### How to build Libsovtoken from source +* [Windows](doc/build-guides/windows-build.md) + ## How To Contribute diff --git a/doc/build-guides/windows-build.md b/doc/build-guides/windows-build.md new file mode 100644 index 000000000..91ff760a2 --- /dev/null +++ b/doc/build-guides/windows-build.md @@ -0,0 +1,21 @@ +# Building Libsovtoken for Windows + +### Step 1 Build Liibndy +Go through [indy sdk on windows build documentation](https://github.com/hyperledger/indy-sdk/blob/master/docs/build-guides/windows-build.md) to get libindy artifacts. +The most important steps are: +* [Downloading of the Indy prebuilt dependencies](https://github.com/hyperledger/indy-sdk/blob/master/docs/build-guides/windows-build.md#getbuild-dependencies) +* [Libindy building]( https://github.com/hyperledger/indy-sdk/blob/master/docs/build-guides/windows-build.md#build) + +### Step 2 Environment Configuration +For this example +- all libraries and prebuilt indy-sdk dependencies was put in `C:\BIN\x64` + +Set the following environment variables: +``` +SET OPENSSL_DIR=C:\BIN\x64 +SET SODIUM_LIB_DIR=C:\BIN\x64\lib +SET LIBINDY_DIR={libindy source directory}\target\[debug | release] +``` + +### Step 4 Building Libsovtoken +Build libsovtoken using the standard `cargo build` command diff --git a/libsovtoken/build.rs b/libsovtoken/build.rs index feffe40b6..7225c1b3f 100644 --- a/libsovtoken/build.rs +++ b/libsovtoken/build.rs @@ -11,6 +11,18 @@ fn main() { Err(..) => panic!("Missing required environment variable LIBINDY_DIR") }; + let target = env::var("TARGET").unwrap(); + println!("target={}", target); + + if target.find("-windows-").is_some() { + println!("cargo:rustc-link-lib=indy.dll"); + println!("indy_dir={}", libindy_lib_path); + let libindy_lib_path = Path::new(libindy_lib_path.as_str()); + + println!("cargo:rustc-flags=-L {}", libindy_lib_path.as_os_str().to_str().unwrap()); + return; + } + println!("cargo:rustc-link-search=native={}",libindy_lib_path); if let Ok(_mode) = env::var("LIBINDY_STATIC") { @@ -19,8 +31,6 @@ fn main() { println!("cargo:rustc-link-lib=dylib=indy"); } - let target = env::var("TARGET").unwrap(); - println!("target={}", target); if target.contains("linux-android") { let openssl = match env::var("OPENSSL_LIB_DIR") { @@ -41,12 +51,5 @@ fn main() { println!("cargo:rustc-link-lib=dylib=ssl"); println!("cargo:rustc-link-search=native={}", sodium); println!("cargo:rustc-link-lib=static=sodium"); - }else if target.find("-windows-").is_some() { - println!("cargo:rustc-link-lib=dylib=ssleay32"); - println!("cargo:rustc-link-lib=dylib=zmq"); - println!("cargo:rustc-link-lib=dylib=sodium"); - let prebuilt_dir = env::var("INDY_PREBUILT_DEPS_DIR").unwrap(); - println!("cargo:rustc-flags=-L {}\\lib", prebuilt_dir); - return; } }