mirror of
https://github.com/Bareflank/hypervisor
synced 2026-08-17 06:23:04 -04:00
This patch addresses several bugs with the build system: - Lack of Windows support - Clang Tidy was not working properly - Making modifications to the source code would compile, but would not re-link resulting in issues - Removed excess file copying - Make clean now works - Removed unused or confusing folders in the build folder as part of the build process. It is now much easier to traverse the build folder for dependencies - The targets didn't work with extensions. This has been fixed. In addition, the following was also done under this patch - Intrinsics was moved to the top level and out of the VMM - Platform files are now in a folder called "platform" instead of "arch" - All subprojects have the same include/src/tests files structure - All intel specific code is properly organized to match intended namespacing - Removed dead code - A small part of the VMCS was converted to use the delegate pattern - All dependencies are now downloaded at configure time instead of compile time. - The cache directory is now cached by Travis CI - CMake output better matches old build system - Added make rebuild and separate clean targets to remove various parts of the build depending on needs. - Added targets for Clean, Tidy, Rebuild and Format for each subproject - Re-organized the cmake logic so that macros are not spread out - New validation removes unneeded complexity - Removed the need for the compiler wrapper, and in doing so, we now provide a simpilar set of toolchain files - Removed the need for Git repos. All external dependencies are downloaded using a zip or tarball - Libcxx and Libcxxabi are now in their own files. Much similar logic - Unit test CMake files have been greatly simplified - Each subproject is unaware of it's prefix and no long use VMM, USERSPACE or TEST variables in their cmake files - Fixed bugs with the flags - Renamed the varbiables in the default.cmake config to be more consistent and easier to follow in the rest of the code Signed-off-by: “rianquinn” <“rianquinn@gmail.com”>
140 lines
4.4 KiB
Markdown
140 lines
4.4 KiB
Markdown
# Configuring and Building the Bareflank Hypervisor
|
|
|
|
## Dependencies
|
|
|
|
Although Bareflank can be made to run on most systems, the following are the
|
|
official supported platforms and their dependencies:
|
|
|
|
* Arch Linux:
|
|
```
|
|
sudo pacman -S git linux-headers nasm clang cmake base-devel
|
|
```
|
|
|
|
* Ubuntu 17.04 (or Higher):
|
|
```
|
|
sudo apt-get install git build-essential linux-headers-$(uname -r) nasm clang cmake
|
|
```
|
|
|
|
Next, create a workspace to hold all Bareflank related source code, build
|
|
artifacts and extensions...
|
|
|
|
```
|
|
mkdir ~/bareflank
|
|
cd ~/bareflank
|
|
```
|
|
|
|
...then clone the Bareflank hypervisor repository, and create a build directory:
|
|
|
|
```
|
|
git clone -b dev https://github.com/bareflank/hypervisor.git
|
|
mkdir build
|
|
cd build
|
|
```
|
|
|
|
Your Bareflank workspace should look like this:
|
|
```
|
|
| bareflank
|
|
| - build
|
|
| - hypervisor
|
|
```
|
|
|
|
Bareflank uses CMake (version 3.6+) to build VMM components, dependencies, and
|
|
Bareflank extension projects. In general, CMake requires that you create a
|
|
separate build directory for each build you would like to perform.
|
|
Build directories can be located anywhere, but we suggest keeping them
|
|
at the level of your Bareflank workspace to keep build outputs
|
|
close (but separate) from source code and extensions. Unless otherwise noted,
|
|
the rest of this document assumes you are building on Ubuntu 17.04 from within a
|
|
Bareflank workspace and build directory at ```~/bareflank/build```
|
|
|
|
## Basic Usage
|
|
|
|
By default, Bareflank will configure itself for the host operating system and
|
|
architecture that you are currently building on. To configure and build with
|
|
default settings, run the following from your build directory:
|
|
|
|
```
|
|
cmake ../hypervisor
|
|
make
|
|
```
|
|
|
|
To speed up the build process, Bareflank also supports parallel
|
|
builds:
|
|
|
|
```
|
|
cmake ../hypervisor
|
|
make -j<#-of-cores + 1>
|
|
```
|
|
|
|
## Configuring Build Options
|
|
|
|
You can change the default build options using a few different methods.
|
|
For changing only a few configurations, the easiest method is to specify them
|
|
as command line arguments to CMake. You can run cmake as many times as
|
|
necessary, specifying different options each time. For example:
|
|
|
|
```
|
|
cmake ../hypervisor -DBUILD_VERBOSE=ON
|
|
cmake ../hypervisor -DBUILD_TYPE=Release -DBUILD_TARGET_ARCH=x86_64
|
|
```
|
|
|
|
If you would like to specify many build configuration options at once, you
|
|
should use a Bareflank build configuration file. By default, Bareflank
|
|
creates a file named *bfconfig.cmake* in your build directory, and uses any
|
|
options specified there (using CMake syntax) to configure your build.
|
|
An example bfconfig.cmake file might look like the following:
|
|
|
|
```
|
|
# ~/bareflank/build/bfconfig.cmake (comments start with '#')
|
|
|
|
set(BUILD_TYPE Release)
|
|
set(BUILD_TARGET_ARCH x86_64)
|
|
|
|
set(BUILD_VMM_SHARED OFF)
|
|
set(BUILD_VMM_STATIC ON)
|
|
set(ENABLE_DEVELOPER_MODE ON)
|
|
```
|
|
|
|
You can also specify a relative path to a Bareflank configuration file
|
|
explicity:
|
|
|
|
```
|
|
cmake ../hypervisor -DBFCONFIG=/path/to/bfconfig.cmake
|
|
```
|
|
|
|
To view and configure *all* of the provided build configuration options at once,
|
|
you can use the CMake configuration tools *ccmake* (from a command line) and
|
|
*cmake-gui* (for a graphical user interface). From your build directory:
|
|
|
|
```
|
|
sudo apt-get install cmake-curses-gui
|
|
cmake ../hypervisor
|
|
ccmake .
|
|
```
|
|
|
|
Each time you reconfigure Bareflank with new build options, the build system
|
|
validates your new build configuration. If you attempt to configure Bareflank
|
|
with (a combinations of) options that aren't supported, the build system
|
|
will fail and warn about options that need to be changed. If your build was
|
|
configured properly, a usage message will guide you to the next steps (usually
|
|
to run ```make```).
|
|
|
|
## Developer features
|
|
Some build features that may be particularly useful if you would like to modify
|
|
Bareflank or develop your own extensions include:
|
|
* ENABLE_BUILD_TEST - Enables unit testing support. You can can also turn unit
|
|
tests for specific projects on/off using the various UNITTEST_<PROJECT_NAME>
|
|
configurations
|
|
* ENABLE_TIDY - Enable support for clang-tidy static analysis checks
|
|
* ENABLE_ASTYLE - Enable support for astyle code formatting checks
|
|
* ENABLE_DEVELOPER_MODE - Enable all of the above options and automatically run
|
|
them on each build. These are the same checks performed by Bareflank CI before
|
|
pull requests will be accepted
|
|
|
|
Additionally, developers may want to use Ninja to build Bareflank efficiently.
|
|
This is supportted by specifying ninja as a generator to CMake:
|
|
|
|
```
|
|
cmake ../hypervisor -G Ninja
|
|
ninja
|
|
```
|