xref: /aosp_15_r20/external/pigweed/third_party/boringssl/docs.rst (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker.. _module-pw_third_party_boringssl:
2*61c4878aSAndroid Build Coastguard Worker
3*61c4878aSAndroid Build Coastguard Worker=========
4*61c4878aSAndroid Build Coastguard WorkerBoringSSL
5*61c4878aSAndroid Build Coastguard Worker=========
6*61c4878aSAndroid Build Coastguard Worker
7*61c4878aSAndroid Build Coastguard WorkerThe ``$dir_pw_third_party/boringssl`` module provides the build files to
8*61c4878aSAndroid Build Coastguard Workercompile and use BoringSSL. The source code of BoringSSL needs to be provided by
9*61c4878aSAndroid Build Coastguard Workerthe user. It is recommended to download it via Git submodules.
10*61c4878aSAndroid Build Coastguard Worker
11*61c4878aSAndroid Build Coastguard Worker-------------
12*61c4878aSAndroid Build Coastguard WorkerBuild support
13*61c4878aSAndroid Build Coastguard Worker-------------
14*61c4878aSAndroid Build Coastguard Worker
15*61c4878aSAndroid Build Coastguard WorkerThis module provides support to compile BoringSSL with GN. This is required when
16*61c4878aSAndroid Build Coastguard Workercompiling backends modules that use BoringSSL, such as some facades in
17*61c4878aSAndroid Build Coastguard Worker:ref:`module-pw_crypto`
18*61c4878aSAndroid Build Coastguard Worker
19*61c4878aSAndroid Build Coastguard WorkerSubmodule
20*61c4878aSAndroid Build Coastguard Worker=========
21*61c4878aSAndroid Build Coastguard Worker
22*61c4878aSAndroid Build Coastguard WorkerThe recommended way to include BoringSSL source code is to add it as a
23*61c4878aSAndroid Build Coastguard Workersubmodule:
24*61c4878aSAndroid Build Coastguard Worker
25*61c4878aSAndroid Build Coastguard Worker.. code-block:: sh
26*61c4878aSAndroid Build Coastguard Worker
27*61c4878aSAndroid Build Coastguard Worker   git submodule add https://boringssl.googlesource.com/boringssl/ \
28*61c4878aSAndroid Build Coastguard Worker       third_party/boringssl/src
29*61c4878aSAndroid Build Coastguard Worker
30*61c4878aSAndroid Build Coastguard WorkerGN
31*61c4878aSAndroid Build Coastguard Worker==
32*61c4878aSAndroid Build Coastguard WorkerThe GN build file depends on a generated file called ``BUILD.generated.gni``
33*61c4878aSAndroid Build Coastguard Workerwith the list of the different types of source files for the selected BoringSSL
34*61c4878aSAndroid Build Coastguard Workerversion.
35*61c4878aSAndroid Build Coastguard Worker
36*61c4878aSAndroid Build Coastguard Worker.. code-block:: sh
37*61c4878aSAndroid Build Coastguard Worker
38*61c4878aSAndroid Build Coastguard Worker   cd third_party/boringssl
39*61c4878aSAndroid Build Coastguard Worker   python src/util/generate_build_files.py gn
40*61c4878aSAndroid Build Coastguard Worker
41*61c4878aSAndroid Build Coastguard WorkerThe GN variables needed are defined in
42*61c4878aSAndroid Build Coastguard Worker``$dir_pw_third_party/boringssl/boringssl.gni``:
43*61c4878aSAndroid Build Coastguard Worker
44*61c4878aSAndroid Build Coastguard Worker#. Set the GN ``dir_pw_third_party_boringssl`` to the path of the BoringSSL
45*61c4878aSAndroid Build Coastguard Worker   installation.
46*61c4878aSAndroid Build Coastguard Worker
47*61c4878aSAndroid Build Coastguard Worker   - If using the submodule path from above, add the following to the
48*61c4878aSAndroid Build Coastguard Worker     ``default_args`` in the project's ``.gn``:
49*61c4878aSAndroid Build Coastguard Worker
50*61c4878aSAndroid Build Coastguard Worker     .. code-block::
51*61c4878aSAndroid Build Coastguard Worker
52*61c4878aSAndroid Build Coastguard Worker        dir_pw_third_party_boringssl = "//third_party/boringssl/src"
53*61c4878aSAndroid Build Coastguard Worker
54*61c4878aSAndroid Build Coastguard Worker#. Having a non-empty ``dir_pw_third_party_boringssl`` variable causes GN to
55*61c4878aSAndroid Build Coastguard Worker   attempt to include the ``BUILD.generated.gni`` file from the sources even
56*61c4878aSAndroid Build Coastguard Worker   during the bootstrap process before the source package is installed by the
57*61c4878aSAndroid Build Coastguard Worker   bootstrap process. To avoid this problem, set this variable to the empty
58*61c4878aSAndroid Build Coastguard Worker   string during bootstrap by adding it to the ``virtualenv.gn_args`` setting in
59*61c4878aSAndroid Build Coastguard Worker   the ``env_setup.json`` file:
60*61c4878aSAndroid Build Coastguard Worker
61*61c4878aSAndroid Build Coastguard Worker   .. code-block:: json
62*61c4878aSAndroid Build Coastguard Worker
63*61c4878aSAndroid Build Coastguard Worker      {
64*61c4878aSAndroid Build Coastguard Worker        "virtualenv": {
65*61c4878aSAndroid Build Coastguard Worker          "gn_args": [
66*61c4878aSAndroid Build Coastguard Worker            "dir_pw_third_party_boringssl=\"\""
67*61c4878aSAndroid Build Coastguard Worker          ]
68*61c4878aSAndroid Build Coastguard Worker        }
69*61c4878aSAndroid Build Coastguard Worker      }
70*61c4878aSAndroid Build Coastguard Worker
71*61c4878aSAndroid Build Coastguard Worker#. Alternatively, set the GN ``pw_third_party_boringssl_ALIAS`` to your
72*61c4878aSAndroid Build Coastguard Worker   boringssl build target if you would like to use your own build target instead
73*61c4878aSAndroid Build Coastguard Worker   of the one provided by Pigweed. This should be used instead of
74*61c4878aSAndroid Build Coastguard Worker   ``dir_pw_third_party_boringssl``. This fixes diamond dependency conflicts
75*61c4878aSAndroid Build Coastguard Worker   caused by two build targets using the same source files.
76*61c4878aSAndroid Build Coastguard Worker
77*61c4878aSAndroid Build Coastguard WorkerAfter this is done a ``pw_source_set`` for the BoringSSL library is created at
78*61c4878aSAndroid Build Coastguard Worker``$dir_pw_third_party/boringssl``.
79