xref: /aosp_15_r20/external/conscrypt/BUILDING.md (revision cd0cc2e34ba52cdf454361820a14d744e4bd531d)
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 publish the artifacts to your Maven local repository for use in your own project, run:
14
15```bash
16$ ./gradlew publishToMavenLocal
17```
18
19Prerequisites
20-------------
21Conscrypt requires that you have __Java__, __BoringSSL__ and the __Android SDK__ configured as
22described below.
23
24#### Java
25The build uses a version of Gradle which requires a __Java 11__ JRE to run, however to ensure
26backward compatibility Conscrypt itself is compiled with a __Java 8__ JDK using Gradle's
27recent Java toolchain support.  At the least, you will need to install __Java 11__ to run
28Gradle, but if you do not also have __Java 8__ then depending on the OS, Gradle will
29try and install it automatically.
30
31#### Android SDK
32[Download and install](https://developer.android.com/studio/install.html) the latest Android SDK
33and set the `ANDROID_HOME` environment variable to point to the root of the SDK
34(e.g. `export ANDROID_HOME=/usr/local/me/Android/Sdk`).
35
36#### BoringSSL
37Before you can build BoringSSL, you'll first need to set up its
38[prerequisites](https://boringssl.googlesource.com/boringssl/+/HEAD/BUILDING.md#Build-Prerequisites).
39
40Once the environment is properly configured, follow the steps below for your platform.
41
42##### Download
43Checkout BoringSSL to a directory of your choice and then build as follows:
44
45```bash
46git clone https://boringssl.googlesource.com/boringssl
47cd boringssl
48
49# Also need to set an environment variable to point to the installation location.
50export BORINGSSL_HOME=$PWD
51```
52
53##### Building on Linux
54To build the 64-bit version on a 64-bit machine:
55```bash
56mkdir build64
57cd build64
58cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \
59      -DCMAKE_BUILD_TYPE=Release \
60      -DCMAKE_ASM_FLAGS=-Wa,--noexecstack \
61      -GNinja ..
62ninja
63```
64
65##### Building on macOS.
66When building Conscrypt on macOS it will build libraries for both x86 and ARM, and so BoringSSL
67must also be build for each of these.
68
69To build the x86_64 version:
70```bash
71mkdir build.x86
72cd build.x86
73cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \
74      -DCMAKE_BUILD_TYPE=Release \
75      -DCMAKE_ASM_FLAGS=-Wa,--noexecstack \
76      -DCMAKE_OSX_ARCHITECTURES=x86_64 \
77      -GNinja ..
78ninja
79```
80
81To build the arm64 version:
82```bash
83mkdir build.arm
84cd build.arm
85cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \
86      -DCMAKE_BUILD_TYPE=Release \
87      -DCMAKE_ASM_FLAGS=-Wa,--noexecstack \
88      -DCMAKE_OSX_ARCHITECTURES=arm64 \
89      -GNinja ..
90ninja
91```
92
93
94##### Building on Windows
95This assumes that you have Microsoft Visual Studio 2017 installed along
96with both the Windows 8.1 and 10 SDKs and that your machine is capable of
97compiling 64-bit.
98
99Unlike earlier versions, Visual Studio 2017 doesn't appear to set an
100environment variable to simplify building from the command line. The
101instructions below assume the default installation of the community
102edition. To use another edition or a non-standard install path, you'll
103need to modify the paths below as appropriate.
104
105To build in 64-bit mode, set up with this command line:
106
107```bat
108call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
109mkdir build64
110cd build64
111cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ^
112      -DCMAKE_BUILD_TYPE=Release ^
113      -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ^
114      -GNinja ..
115ninja
116```
117
11832-bit mode is no longer supported.
119
120Coverage
121--------
122To see coverage numbers, run the tests and then execute the jacocoTestReport rule
123
124```bash
125./gradlew check jacocoTestReport
126```
127
128The report will be placed in `openjdk/build/reports/jacoco/test/html/index.html`
129