blob: a53cb392f69b73469be3ce1e0615d1c7baa5d1f2 [file] [log] [blame]
(window.webpackJsonp=window.webpackJsonp||[]).push([[83],{428:function(e,t,a){"use strict";a.r(t);var s=a(11),i=Object(s.a)({},(function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[a("h1",{attrs:{id:"build-system"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#build-system"}},[e._v("#")]),e._v(" Build System")]),e._v(" "),a("p",[e._v("The Teaclave's build system utilizes CMake to coordinate compilation, linking,\nsigning, etc. for various components written in different languages (e.g., Rust, C,\nPython) for different targets (e.g., Linux and SGX). In this document, we will\nintroduce our build system in details.")]),e._v(" "),a("h2",{attrs:{id:"quick-start"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#quick-start"}},[e._v("#")]),e._v(" Quick Start")]),e._v(" "),a("ol",[a("li",[e._v("Download and "),a("a",{attrs:{href:"https://cmake.org/install/",target:"_blank",rel:"noopener noreferrer"}},[e._v("install")]),e._v(" CMake, the minimum\nrequired version is 3.10.")]),e._v(" "),a("li",[e._v("Open a shell and create a build directory.")])]),e._v(" "),a("div",{staticClass:"language- extra-class"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("$ mkdir build && cd build\n")])])]),a("ol",{attrs:{start:"3"}},[a("li",[e._v("Run the following command to configure with "),a("code",[e._v("TEST_MODE")]),e._v(" on.")])]),e._v(" "),a("div",{staticClass:"language- extra-class"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("$ cmake -DTEST_MODE=ON ..\n")])])]),a("ol",{attrs:{start:"4"}},[a("li",[e._v("Build the whole platform.")])]),e._v(" "),a("div",{staticClass:"language- extra-class"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("$ make\n")])])]),a("p",[e._v("When making changes, run:")]),e._v(" "),a("ul",[a("li",[a("code",[e._v("make format")]),e._v(": Format current source code.")]),e._v(" "),a("li",[a("code",[e._v("make run-tests")]),e._v(": Make sure all tests are passed.")])]),e._v(" "),a("p",[e._v("You can find more detailed configurations and targets in the following sections.")]),e._v(" "),a("h2",{attrs:{id:"variables-and-options"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#variables-and-options"}},[e._v("#")]),e._v(" Variables and Options")]),e._v(" "),a("p",[e._v("There are a lot of variables and options you can configure to control the build\nsystem.")]),e._v(" "),a("p",[e._v("To set a variable or option, you can pass "),a("code",[e._v("-DXXX=")]),e._v(" to "),a("code",[e._v("cmake")]),e._v(". For example,\n"),a("code",[e._v("cmake -DTEST_MODE=ON ..")]),e._v(" to enable the "),a("code",[e._v("TEST_MODE")]),e._v(" option.")]),e._v(" "),a("h3",{attrs:{id:"variables"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#variables"}},[e._v("#")]),e._v(" Variables")]),e._v(" "),a("ul",[a("li",[a("code",[e._v("SGX_SDK")]),e._v(": Set (or get from env vars) the path of Intel SGX SDK. Defaults to\n"),a("code",[e._v("/opt/sgxsdk")]),e._v(".")]),e._v(" "),a("li",[a("code",[e._v("RUSTFLAGS")]),e._v(": Set (or get from env vars) flags passed to rustc.")]),e._v(" "),a("li",[a("code",[e._v("MESAPY_VERSION")]),e._v(": Set the commit hash to the upstream MesaPy version.")]),e._v(" "),a("li",[a("code",[e._v("RUSTUP_TOOLCHAIN")]),e._v(": Set the Rust toolchain version.")]),e._v(" "),a("li",[a("code",[e._v("CMAKE_BUILD_TYPE")]),e._v(": Set the build type. Defaults to debug.")])]),e._v(" "),a("h3",{attrs:{id:"options"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#options"}},[e._v("#")]),e._v(" Options")]),e._v(" "),a("ul",[a("li",[a("code",[e._v("COV")]),e._v(": Build with coverage information. Defaults to OFF.")]),e._v(" "),a("li",[a("code",[e._v("OFFLINE")]),e._v(": Compile Rust code with "),a("code",[e._v("cargo --offline")]),e._v(". Defaults to ON.")]),e._v(" "),a("li",[a("code",[e._v("TEST_MODE")]),e._v(": Build with mock data and disabling some functions for testing.\nDefaults to OFF.")]),e._v(" "),a("li",[a("code",[e._v("SGX_SIM_MODE")]),e._v(": Build in SGX simulation mode. Defaults to OFF.")]),e._v(" "),a("li",[a("code",[e._v("DCAP")]),e._v(": Use DCAP instead of IAS as the attestation service. Defaults to OFF.")]),e._v(" "),a("li",[a("code",[e._v("GIT_SUBMODULE")]),e._v(": Sync submodules with the upstream repositories. Defaults to\nON.")]),e._v(" "),a("li",[a("code",[e._v("CLP")]),e._v(": Enable "),a("code",[e._v("cargo clippy")]),e._v(" to lint Rust code during the compilation.\nDefaults to OFF.")]),e._v(" "),a("li",[a("code",[e._v("DOC")]),e._v(": Generate document with "),a("code",[e._v("cargo doc")]),e._v(" during the compilation. Defaults to OFF.")]),e._v(" "),a("li",[a("code",[e._v("USE_PREBUILT_MESAPY")]),e._v(": Whether to use the prebuilt MesaPy for SGX library. If\nset to OFF, will build the library from the source code. Defaults to ON.")]),e._v(" "),a("li",[a("code",[e._v("EXECUTOR_BUILTIN")]),e._v(": Compile with the Builtin executor. Defaults to ON.")]),e._v(" "),a("li",[a("code",[e._v("EXECUTOR_MESAPY")]),e._v(": Compile with the MesaPy executor. Defaults to ON.")]),e._v(" "),a("li",[a("code",[e._v("EXECUTOR_WAMR")]),e._v(": Compile with the WebAssembly Micro Runtime executor. Defaults to ON.")])]),e._v(" "),a("h2",{attrs:{id:"targets"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#targets"}},[e._v("#")]),e._v(" Targets")]),e._v(" "),a("p",[e._v("The followings are supported targets you can call with "),a("code",[e._v("make")]),e._v(". For example, to build a specific\nservice like execution service, you can just run "),a("code",[e._v("make teaclave_execution_service")]),e._v(".")]),e._v(" "),a("h3",{attrs:{id:"app-enclave"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#app-enclave"}},[e._v("#")]),e._v(" App/Enclave")]),e._v(" "),a("p",[e._v("An SGX application has two parts: the app part and the enclave part. You can\ncompile them separately or together using with these targets:")]),e._v(" "),a("ul",[a("li",[a("code",[e._v("sgxapp-teaclave_{service_name}")]),e._v(": Build the app part of a service.")]),e._v(" "),a("li",[a("code",[e._v("sgxlib-teaclave_{service_name}")]),e._v(": Build the enclave part of a service.")]),e._v(" "),a("li",[a("code",[e._v("teaclave_{service_name}")]),e._v(": Build (compile, link and sign, etc.) the app and\nenclave of a service.")]),e._v(" "),a("li",[a("code",[e._v("sgxapp-teaclave_{test_name}")]),e._v(": Build the app part of a test driver.")]),e._v(" "),a("li",[a("code",[e._v("sgxlib-teaclave_{test_name}")]),e._v(": Build the enclave part of a test driver.")]),e._v(" "),a("li",[a("code",[e._v("teaclave_{test_name}")]),e._v(": Build (compile, link, and sign, etc.) the app and\nenclave of a test driver.")])]),e._v(" "),a("p",[e._v("These targets are automatically generated from the\n"),a("code",[e._v("cmake/tomls/Cargo.sgx_{}.toml")]),e._v(" files. Basically, they are:")]),e._v(" "),a("ul",[a("li",[a("code",[e._v("test_name")]),e._v(" can be: "),a("code",[e._v("function_tests")]),e._v(", "),a("code",[e._v("unit_tests")]),e._v(", "),a("code",[e._v("integration_tests")]),e._v(", etc.")]),e._v(" "),a("li",[a("code",[e._v("service_name")]),e._v(" can be: "),a("code",[e._v("access_control_service")]),e._v(", "),a("code",[e._v("authentication_service")]),e._v(",\n"),a("code",[e._v("storage_service")]),e._v(", "),a("code",[e._v("execution_service")]),e._v(", "),a("code",[e._v("frontend_service")]),e._v(",\n"),a("code",[e._v("management_service")]),e._v(", "),a("code",[e._v("scheduler_service")]),e._v(", etc.")])]),e._v(" "),a("h3",{attrs:{id:"client-sdk"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#client-sdk"}},[e._v("#")]),e._v(" Client SDK")]),e._v(" "),a("p",[e._v("Build Teaclave client SDK and install the compiled dynamic/static libraries to\nthe release folder.")]),e._v(" "),a("ul",[a("li",[a("code",[e._v("teaclave_client_sdk")]),e._v(": Build the client SDK to both dynamic and static\nlibraries.")])]),e._v(" "),a("h3",{attrs:{id:"bin"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#bin"}},[e._v("#")]),e._v(" Bin")]),e._v(" "),a("ul",[a("li",[a("code",[e._v("teaclave_cli")]),e._v(": Build the Teclave command line tool.")]),e._v(" "),a("li",[a("code",[e._v("teaclave_dcap_ref_as")]),e._v(": Build the reference implementation of DCAP's\nattestation service.")]),e._v(" "),a("li",[a("code",[e._v("teaclave_sgx_tool")]),e._v(": Build the SGX tool.")])]),e._v(" "),a("p",[e._v("Above targets are automatically generated from the\n"),a("code",[e._v("cmake/tomls/Cargo.unix_app.toml")]),e._v(" files.")]),e._v(" "),a("h3",{attrs:{id:"linting"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#linting"}},[e._v("#")]),e._v(" Linting")]),e._v(" "),a("ul",[a("li",[a("code",[e._v("format")]),e._v(": Format all code.")]),e._v(" "),a("li",[a("code",[e._v("clippy")]),e._v(": Run "),a("code",[e._v("cargo clippy")]),e._v(" for linting. Same with "),a("code",[e._v("make CLP=1")]),e._v(".")])]),e._v(" "),a("h3",{attrs:{id:"doc"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#doc"}},[e._v("#")]),e._v(" Doc")]),e._v(" "),a("ul",[a("li",[a("code",[e._v("doc")]),e._v(": Run "),a("code",[e._v("cargo doc")]),e._v(" to generate documents. Same with "),a("code",[e._v("make DOC=1")]),e._v(".")])]),e._v(" "),a("h3",{attrs:{id:"tests"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#tests"}},[e._v("#")]),e._v(" Tests")]),e._v(" "),a("ul",[a("li",[a("code",[e._v("run-tests")]),e._v(": Run all test cases.")]),e._v(" "),a("li",[a("code",[e._v("run-integration-tests")]),e._v(": Run integration tests only.")]),e._v(" "),a("li",[a("code",[e._v("run-funtional-tests")]),e._v(": Run functional tests only.")]),e._v(" "),a("li",[a("code",[e._v("run-sdk-tests")]),e._v(": Run tests of client SDK only.")]),e._v(" "),a("li",[a("code",[e._v("run-examples")]),e._v(": Run all examples.")]),e._v(" "),a("li",[a("code",[e._v("cov")]),e._v(": Aggregate coverage results and generate report, needs to config cmake\nwith "),a("code",[e._v("-DCOV=ON")]),e._v(".")])]),e._v(" "),a("h3",{attrs:{id:"misc"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#misc"}},[e._v("#")]),e._v(" Misc")]),e._v(" "),a("ul",[a("li",[a("code",[e._v("clean")]),e._v(": Cleanup all building intermediates.")])]),e._v(" "),a("h2",{attrs:{id:"codebase"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#codebase"}},[e._v("#")]),e._v(" Codebase")]),e._v(" "),a("p",[e._v("You can find source code to learn more about our build system in the\n"),a("code",[e._v("CMakeLists.txt")]),e._v(" file and the "),a("code",[e._v("cmake")]),e._v(" directories.")])])}),[],!1,null,null,null);t.default=i.exports}}]);