1Building Conscrypt 2================== 3 4Before you begin, you'll first need to properly configure the [Prerequisites](#Prerequisites) as 5described below. 6 7Then to build, run: 8 9```bash 10$ ./gradlew build 11``` 12 13To install the artifacts to your Maven local repository for use in your own project, run: 14 15```bash 16$ ./gradlew install 17``` 18 19Prerequisites 20------------- 21Conscrypt requires that you have __Java__, __BoringSSL__ and the __Android SDK__ configured as 22described below. 23 24#### Java 25The build requires that you have the `JAVA_HOME` environment variable pointing to a valid JDK. 26 27#### Android SDK 28[Download and install](https://developer.android.com/studio/install.html) the latest Android SDK 29and set the `ANDROID_HOME` environment variable to point to the root of the SDK 30(e.g. `export ANDROID_HOME=/usr/local/me/Android/Sdk`). 31 32#### BoringSSL 33Before you can build BoringSSL, you'll first need to set up its 34[prerequisites](https://boringssl.googlesource.com/boringssl/+/HEAD/BUILDING.md#Build-Prerequisites). 35 36Once the environment is properly configured, follow the steps below for your platform. 37 38##### Download 39Checkout BoringSSL to a directory of your choice and then build as follows: 40 41```bash 42git clone https://boringssl.googlesource.com/boringssl 43cd boringssl 44 45# Also need to set an environment variable to point to the installation location. 46export BORINGSSL_HOME=$PWD 47``` 48 49##### Building on Linux/OS-X 50To build in the 64-bit version on a 64-bit machine: 51```bash 52mkdir build64 53cd build64 54cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \ 55 -DCMAKE_BUILD_TYPE=Release \ 56 -DCMAKE_ASM_FLAGS=-Wa,--noexecstack \ 57 -GNinja .. 58ninja 59``` 60 61To make a 32-bit build on a 64-bit machine: 62```base 63mkdir build32 64cd build32 65cmake -DCMAKE_TOOLCHAIN_FILE=../util/32-bit-toolchain.cmake \ 66 -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \ 67 -DCMAKE_BUILD_TYPE=Release \ 68 -DCMAKE_ASM_FLAGS="-Wa,--noexecstack -m32 -msse2" \ 69 -GNinja .. 70ninja 71``` 72 73##### Building on Windows 74This assumes that you have Microsoft Visual Studio 2017 installed along 75with both the Windows 8.1 and 10 SDKs and that your machine is capable of 76compiling 64-bit. 77 78Unlike earlier versions, Visual Studio 2017 doesn't appear to set an 79environment variable to simplify building from the command line. The 80instructions below assume the default installation of the community 81edition. To use another edition or a non-standard install path, you'll 82need to modify the paths below as appropriate. 83 84To build in 64-bit mode, set up with this command line: 85 86```bat 87call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 88mkdir build64 89cd build64 90``` 91 92To build in 32-bit mode, set up with this command line: 93 94```bat 95call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 96mkdir build32 97cd build32 98``` 99 100In either the 64-bit or 32-bit case, run this afterward: 101 102```bat 103cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ^ 104 -DCMAKE_BUILD_TYPE=Release ^ 105 -DCMAKE_C_FLAGS_RELEASE=/MT ^ 106 -DCMAKE_CXX_FLAGS_RELEASE=/MT ^ 107 -GNinja .. 108ninja 109``` 110 111Running tests on Java 6 112------------------------- 113Conscrypt is built with Java 8+, but targets the Java 6 runtime. To run the tests 114under Java 6 (or any Java runtime), you can specify the `javaExecutable64` property from the command line. 115 This will run all tests under `openjdk` and `openjdk-integ-tests` with the specified 116 runtime. 117 118```bash 119./gradlew check -DjavaExecutable64=${JAVA6_HOME}/bin/java 120``` 121