2020-10-06 18:44:53 +03:00
Build CCF from Source
=====================
2019-10-22 18:04:14 +03:00
2020-10-06 18:44:53 +03:00
Once you have setup your VM and installed all dependencies, you will be able to successfully build and run the CCF test suite that will deploy a local CCF network.
First, checkout the CCF repository:
.. code-block :: bash
$ git clone git@github.com:microsoft/CCF.git
2019-10-22 18:04:14 +03:00
2019-10-29 14:40:37 +03:00
To build CCF from source on a SGX-enabled machine, run the following:
2019-10-22 18:04:14 +03:00
.. code-block :: bash
$ cd CCF
$ mkdir build
$ cd build
$ cmake -GNinja ..
$ ninja
Alternatively, on a non-SGX machine, you can build a `virtual` instance of CCF:
.. code-block :: bash
$ cd CCF
$ mkdir build
$ cd build
2022-10-26 12:08:24 +03:00
$ cmake -GNinja -DCOMPILE_TARGET=virtual ..
2019-10-22 18:04:14 +03:00
$ ninja
.. note :: :
2020-10-06 18:44:53 +03:00
CCF defaults to building in the `RelWithDebInfo <https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html> `_ configuration.
2019-10-22 18:04:14 +03:00
2022-11-22 17:31:38 +03:00
.. warning ::
A machine with at least 32Gb of memory is recommended to build CCF with the default compiler.
2020-04-03 20:35:06 +03:00
Build Switches
2019-10-22 18:04:14 +03:00
--------------
The full list of build switches can be obtained by running:
.. code-block :: bash
$ cmake -L ..
2020-10-06 18:44:53 +03:00
The most common build switches include:
2019-10-22 18:04:14 +03:00
* **BUILD_TESTS** : Boolean. Build all tests for CCF. Default to ON.
* **SAN** : Boolean. Build unit tests with Address and Undefined behaviour sanitizers enabled. Default to OFF.
2022-10-26 12:08:24 +03:00
* **COMPILE_TARGET** : String. Target compilation platform. Defaults to `` sgx `` . Supported values are `` sgx `` , `` snp `` , or `` virtual `` .
2019-10-22 18:04:14 +03:00
2022-02-28 14:42:33 +03:00
Run Tests
---------
2019-10-22 18:04:14 +03:00
2020-10-06 18:44:53 +03:00
Tests can be started through the `` tests.sh `` wrapper for `` ctest `` .
2019-10-22 18:04:14 +03:00
.. code-block :: bash
$ cd build
2021-01-05 22:04:12 +03:00
$ ./tests.sh
2019-10-22 18:04:14 +03:00
2022-10-24 13:09:47 +03:00
Although CCF's unit tests can be run through `` ctest `` directly, the end-to-end tests that start a network require some Python infrastructure. :ccf_repo:`tests.sh </tests/tests.sh>` will set up a virtual environment with these dependencies and activate it before running `` ctest `` . Add `` -VV `` for verbose test output. Further runs will re-use that virtual environment.
2019-10-22 18:04:14 +03:00
.. note ::
2020-10-06 18:44:53 +03:00
On a full build of CCF, it is also possible to run tests with virtual enclaves by setting the `` TEST_ENCLAVE `` environment variable:
2019-10-22 18:04:14 +03:00
.. code-block :: bash
2021-01-05 22:04:12 +03:00
$ TEST_ENCLAVE=virtual ./tests.sh [-VV]
2019-10-22 18:04:14 +03:00
Tests that require enclave attestation will be skipped.
2021-06-01 13:39:31 +03:00
2022-02-28 14:42:33 +03:00
Build Older Versions of CCF
---------------------------
2022-11-03 19:13:11 +03:00
Building older versions of CCF may require a different toolchain than the one used to build the current `` main `` branch (e.g. 1.x CCF releases are built with `clang-8` ). To build an old version of CCF locally without having to install another toolchain that may conflict with the current one, it is recommended to use the `` ccfciteam/ccf-ci `` docker image (now `` ccfmsrc.azurecr.io/ccf/ci `` ). The version tag of the `` cci-ci `` (now `` ccf/ci `` ) image used to build the old version can be found in the :ccf_repo:`.azure-pipelines.yml` YAML file (under `` resources:container:image `` ).
2022-02-28 14:42:33 +03:00
.. code-block :: bash
$ export CCF_CI_IMAGE_TAG="oe0.17.2-clang-8" # e.g. building CCF 1.0.15
$ export LOCAL_CCF_CHECKOUT_PATH=/path/to/local/ccf/checkout
$ cd $LOCAL_CCF_CHECKOUT_PATH
$ git checkout ccf-1.0.15 # e.g. building CCF 1.0.15
2022-11-03 19:13:11 +03:00
$ docker run -ti --device /dev/sgx_enclave:/dev/sgx_enclave --device /dev/sgx_provision:/dev/sgx_provision -v $LOCAL_CCF_CHECKOUT_PATH:/CCF ccfmsrc.azurecr.io/ccf/ci:$CCF_CI_IMAGE_TAG-sgx bash
2022-02-28 14:42:33 +03:00
# container started, following lines are in container
$ cd CCF/
$ mkdir build_docker && cd build_docker
$ cmake -GNinja .. && ninja
The built libraries and binaries are then available outside of the container in the `` build_docker `` directory in the local CCF checkout.
Update the Documentation
------------------------
2021-06-01 13:39:31 +03:00
It is possible to preview local documentation changes by running
.. code-block :: bash
2022-02-28 14:42:33 +03:00
$ ./livehtml.sh
2021-06-01 13:39:31 +03:00
or if there are no Doxygen changes
.. code-block :: bash
2022-02-28 14:42:33 +03:00
$ SKIP_DOXYGEN=ON ./livehtml.sh