Home | History | Annotate | Download | only in conscrypt
      1 Building Conscrypt
      2 ==================
      3 
      4 Before you begin, you'll first need to properly configure the [Prerequisites](#Prerequisites) as
      5 described below.
      6 
      7 Then to build, run:
      8 
      9 ```bash
     10 $ ./gradlew build
     11 ```
     12 
     13 To install the artifacts to your Maven local repository for use in your own project, run:
     14 
     15 ```bash
     16 $ ./gradlew install
     17 ```
     18 
     19 Prerequisites
     20 -------------
     21 Conscrypt requires that you have __Java__, __BoringSSL__ and the __Android SDK__ configured as
     22 described below.
     23 
     24 #### Java
     25 The 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
     29 and 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
     33 Before 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 
     36 Once the environment is properly configured, follow the steps below for your platform.
     37 
     38 ##### Download
     39 Checkout BoringSSL to a directory of your choice and then build as follows:
     40 
     41 ```bash
     42 git clone https://boringssl.googlesource.com/boringssl
     43 cd boringssl
     44 
     45 # Also need to set an environment variable to point to the installation location.
     46 export BORINGSSL_HOME=$PWD
     47 ```
     48 
     49 ##### Building on Linux/OS-X
     50 To build in the 64-bit version on a 64-bit machine:
     51 ```bash
     52 mkdir build64
     53 cd build64
     54 cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \
     55       -DCMAKE_BUILD_TYPE=Release \
     56       -DCMAKE_ASM_FLAGS=-Wa,--noexecstack \
     57       -GNinja ..
     58 ninja
     59 ```
     60 
     61 To make a 32-bit build on a 64-bit machine:
     62 ```base
     63 mkdir build32
     64 cd build32
     65 cmake -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 ..
     70 ninja
     71 ```
     72 
     73 ##### Building on Windows
     74 This assumes that you have Microsoft Visual Studio 2017 installed along
     75 with both the Windows 8.1 and 10 SDKs and that your machine is capable of
     76 compiling 64-bit.
     77 
     78 Unlike earlier versions, Visual Studio 2017 doesn't appear to set an
     79 environment variable to simplify building from the command line. The
     80 instructions below assume the default installation of the community
     81 edition. To use another edition or a non-standard install path, you'll
     82 need to modify the paths below as appropriate.
     83 
     84 To build in 64-bit mode, set up with this command line:
     85 
     86 ```bat
     87 call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
     88 mkdir build64
     89 cd build64
     90 ```
     91 
     92 To build in 32-bit mode, set up with this command line:
     93 
     94 ```bat
     95 call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86
     96 mkdir build32
     97 cd build32
     98 ```
     99 
    100 In either the 64-bit or 32-bit case, run this afterward:
    101 
    102 ```bat
    103 cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ^
    104       -DCMAKE_BUILD_TYPE=Release ^
    105       -DCMAKE_C_FLAGS_RELEASE=/MT ^
    106       -DCMAKE_CXX_FLAGS_RELEASE=/MT ^
    107       -GNinja ..
    108 ninja
    109 ```
    110 
    111 Running tests on Java 6
    112 -------------------------
    113 Conscrypt is built with Java 8+, but targets the Java 6 runtime. To run the tests
    114 under 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